Originally posted by: JamesNeuf
I seem to get this very strange bug when using OPL script to set the values of an array. Here is the stripped-down code:
test.dat: varIn = [0 0 0];
test.mod: string period[0..3];
execute setPeriod {
for(var i=0; i<=3; i++) {
if (i >= 1) period[i] = "A";
else period[i] = "B";
}
}
{int} rng1 = union(s in 0..3 : period[s] != "B") {s};
{int} rng2 = union(s in 0..3 : period[s] != "B") {s};
int varIn[rng1] = ...;
execute {
writeln(period);
writeln(rng1);
writeln(rng2);
writeln(varIn);
}
> oplrun test.mod test.dat
IBM ILOG License Manager: "IBM ILOG Optimization Suite for Academic Initiative" is accessing CPLEX 12 with option(s): "e m b q ".
["B" "A" "A" "A"]
{0 1 2 3}
{1 2 3}
[0 0 0 0]
What that output
should look like:
["B" "A" "A" "A"]
{0 1 2}
{1 2 3}
[0 0 0]
What is weird is that the "rng1" set changes elements because it is used when reading in a variable! Any ideas?
#DecisionOptimization#OPLusingCPLEXOptimizer