0
votes

I'm implementing a two-phase method in CPLEX OPL.

I would like to create a set containing the unitary values of a variable obtained during my initial phase. In order to initialize my second phase, I make a getValue(X) to recover the optimal values for that boolean variable indexed in i,j,k. Later, inside a double loop on indices "j" and "k" I try to declare the set "S" of the unitary values of "X" along the i-dimension.

However, I fail to make a proper set declaration... I've already tried using:

var S = {i | i in I : X[i][j][k] == 1};
int S = {i | i in I : X[i][j][k] == 1};
{int} S = {i | i in I : X[i][j][k] == 1};

But I always get the error: "Illegal use of a reserved keyword". I know that my set declaration isn't good but have no idea of how to declare it in order to have my set S containing the values of I for which X[i][j][k] == 1.

Could you please provide some help? Best regards

1

1 Answers

0
votes

range I=1..2; range J=1..2; range K=1..2; int X[i in I][j in J][k in K]=(i==1)&&(j==1)&&(k==1)?1:0;

int v[i in I]=1<=sum(j in J,k in K )(X[i][j][k] == 1); {int} S = {i | i in I : v[i] == 1};

execute { writeln(S); }

could help

regards