Originally posted by: Cplex
I can understand this example.
But in my case I have to change the index of decision variable z in each of the scenarios. So three of the z[k] have to be equal to zero while the other ones should be equal to one. I tried to apply your example to this case but I don't know how to do that.
I tried it as follows, but there's an error:
//Indizes
range I =1..115; //RD: 115
range J =1..3766; //Häuser: 1635
range K =1..92; //KH: 92
range S =1..23; //RTW: 23
//Datenvariablen
float t[J][I] =...; //Distanz RD-Haus
float c[J][K] =...; //Distanz KH-Haus
int KH =...; //Anzahl KH
int RD =...; //Anzahl RD
int RTW =...; //Anzahl RTW
float a =...; //Wahrscheinlichkeit, dass RTW nicht verfügbar ist
int d =...; //Einwohner/Haus
int p[J][I] =...; //Zuordnung RD möglich?
int q[J][K] =...; //Zuordnung KH möglich?
//Entscheidungsvariablen
dvar boolean Cov[J][S]; //=1,falls Haus j von mind. s Fahrzeugen und einem KH abgedeckt ist
dvar boolean y[I]; //=1,falls RD i eröffnet wird
dvar boolean z[K]; //=1,falls KH k eröffnet wird
dvar int+ m[I]; //Anzahl stationierter RTW an RD i
dvar int e in 1..92;
dvar int f in 1..92;
dvar int g in 1..92;
//Zielfunktion
dexpr float Covering = sum(j in J, s in S) Cov[j][s] * d * (1-a) * a^(s-1);
maximize Covering;
//Nebenbedingungen
subject to{
z[e] == 0;
z[f] == 0;
z[g] == 0;
Opening_RD:
sum(i in I) y[i] == RD;
Opening_KH:
sum(k in K) z[k] == KH;
Covering_KH:
forall(j in J,s in S)
Cov[j][s] <= sum(k in K) q[j][k] * z[k];
Opening_KH_q_jk:
forall(k in K)
z[k] <= sum(j in J) q[j][k];
Covering_RD:
forall(j in J)
sum(s in S) Cov[j][s] <= sum(i in I) p[j][i] * m[i];
RD_RTW:
forall(i in I)
y[i]*RTW >= m[i];
RTW_stationieren:
sum(i in I) m[i] == RTW;
}
main
{
thisOplModel.generate();
for(var o=1;o<=92;o++){
for(var l=1;l<=92;l++){
for(var n=1;n<=92;n++){
thisOplModel.e.LB=o;
thisOplModel.e.UB=o;
thisOplModel.f.LB=l;
thisOplModel.f.UB=l;
thisOplModel.g.LB=n;
thisOplModel.g.UB=n;
cplex.solve();
thisOplModel.postProcess();
}
}}}
But it's not possible to equalize the three decision variables (z) to zero inside the constraints.
Do you understand what's my problem? Is it possible to change the Index for these constraints in each szenario??
#DecisionOptimization#OPLusingCPLEXOptimizer