Originally posted by: Didier Vidal
Hello biaigo,
Here is an example that initializes data in two ways - with an OPL statement (started) and with script (now and startTime).
Hope this helps,
Didier.
using CP; range tasks = 0..10; dvar interval myIntervals[tasks] size 4;
// Example of data initialization with an OPL statement - random value between 0 and 1
int started[t in tasks] = rand(2);
int startTime[tasks];
int now;
// Example of initialization of a variable in script execute
{ var current = 0; var t;
for (t = 0; t<= 10; t++)
if (started[t] == 1)
{ startTime[t] = current; current += 5;
}
else started[t] = -1; now = current;
} minimize max(t in tasks) endOf(myIntervals[t]); constraints
{ forall(t in tasks : started[t] == 1) startOf(myIntervals[t]) == startTime[t]; noOverlap(myIntervals);
}
#CPOptimizer#DecisionOptimization