Originally posted by: SystemAdmin
Hello,
In fact, the modulo expression (%) is not supported in Solver. If you want to remove some possible values from the domain of the start time of an activity, you have two options:
(1) either directly define a start variable with the discrete set of possible values:
// Option (1) IloIntArray possStarts(env);
for (IloInt i=0; i<horizon; i+=300)
{ possStarts.add(i);
} IloIntVar startDate(env, possStarts); model.add(act.startsAt(startDate));
(2) or, in Scheduler by defining a calendar on a resource with shift objects:
// Option (2) IloDiscreteResource res(env, 10000);
// Large capacity IloIntervalList noStart(env, 0, horizon);
for (IloInt i=0; i<horizon; i+=300)
{ noStart.addInterval(i+1, i+300);
// Activities cannot start on [i+1,i+300)
} IloShiftListObject shifts(env, noStart, IloShiftListObject::OnStart); IloCalendar cal(env); cal.addShiftObject(shifts); res.setCalendar(cal); model.add(act.requires(res));
The advantage of the second option is that the calendar will be applied to all activities requiring the resource.
In a more general context, you could also replace (x%a) by (x - a*IloDiv(x,a)).
Hope it helps.
#CPOptimizer#DecisionOptimization