Originally posted by: ChrisBr
Hello,
In addition to what Petr has answered, I would try to give you more details.
One simple way would be to use a stepwise function and use it in a forbidExtent constraint.
For example, you can define the stepwise function
IloNumToNumStepFunction openHours(env); openHours.setValue(0, 5*24-1, 0);
then define the open hours
openHours.setValue( 8, 16, 100); openHours.setValue( 32, 40, 100); openHours.setValue( 56, 64, 100); openHours.setValue( 80, 88, 100); openHours.setValue(104,109, 100);
Then you can use the forbidExtent constraint:
IloIntervalVar myvar(env, 2); model.add(IloForbidExtent(env, myvar, openHours));
which means that whenever interval variable myvar is present, it cannot contain a value t when openHours(t)=0.
I hope that helps,
Chris.
#CPOptimizer#DecisionOptimization