Reputation: 1
I am trying to use decision variables Y to update index of decision variable X in constraint. However, it does not seem to work in Cplex. Any help is appreciated, thanks a lot in advance. Here is my code:
// Parameters
int Tmax = ...;
int u[i][r][m] = ...;
int b[i][r][m][a] = ...;
float t[i][r][j][s] = ...;
// Variables
dvar boolean X[i][r][m][j][s][n][k];
dvar boolean Y[i][r][m][k];
// Objective Function
dexpr float TotalDuration = sum(ci in i, cr in r, cm in m, cj in j, cs in s, cn in n, ck in k) t[ci][cr][cj][cs]*X[ci][cr][cm][cj][cs][cn][ck] + sum(ci in i, cr in r, cm in m, ck in k) u[ci][cr][cm]*Y[ci][cr][cm][ck];
minimize TotalDuration;
subject to {
forall(ci in i, cr in r, cm in m, cj in j, cs in s, cn in n, ck in k)
TimeConservative:
X[ci][cr][cm][cj][cs][cn][ck] == X[ci][cr][cm][cj][cs][cm+u[ci][cr][cm]*Y[ci][cr][cm][ck] + t[ci][cr][cj][cs]][ck];
}
Upvotes: 0
Views: 558
Reputation: 5930
With CPLEX you cannot use a decision variable as index. With CP this is possible. Since you have only boolean decision variables, you could try using CP to solve your problem. To do this you have to add using CP;
at the top of your .mod
file.
If you need/want to stick with CPLEX a common way to work around this limitation is to explicitly spell out the two cases for Y by using the logical "implies" constraint:
(Y[ci][cr][cm][ck] == 0) => (/* here comes the constraint that must be satisfied if Y==0);
(Y[ci][cr][cm][ck] == 1) => (/* here comes the constraint that must be satisfied if Y==1);
This is of course only useful if Y
is boolean or integer with a relative small domain.
Upvotes: 1