How can I write this code in a more compact way on CPLEX?
forall (j in J)
forall (i in I1)
{
if ( macc [i][j] == 1 || 2 || 4 || 5 || 7 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19) {
y[i][j][m] == 1;
}
else {
if (macc [i][j] == 3) {
y[i][j][3] == 1 || y[i][j][4] == 1;
}
}
CodePudding user response:
you can use "in" with data in an if condition:
{int} s={1,2,4,5,7,11,12,13,14,15,16,17,18,19};
int m=2;
dvar int x;
subject to
{
if (m in s) x==2;
}
works fine