Originally posted by: SystemAdmin
Hello,
First I think that you should design your model at the level of Concert (using Ilo objects instead of Ilc). This holds both for CP Optimizer (IloIntervalVar) and Scheduler (IloActivity).
In CP Optimizer the notion of an
interval variable is atomic an is not, like in Scheduler a composite of integer variables. But it is of course possible to mix interval variables and integer variables in the model. For that, a set of integer
expressions are available, for instance IloStartOf(act,dval) that will represent the start value of interval variable
act if it is present and value dval (0 if omitted) if the interval is absent. You can use this type of integer expression in the objective and/or to post constraints. For instance, you can still do:
IloIntVar start ...;
IloIntervalVar act ...;
model.add(start == IloStartOf(act));
This being said, unless there is some good reason for it, it is better to avoid creating those additional integer variables if you can directly write your model with the integer expressions or even better, directly with constraints on the interval variables.
For instance for posting a precedence constraint, you should use:
model.add(IloEndBeforeStart(env, act1, act2)); Working with expressions like below would be less effective:
model.add(IloEndOf(act1)<=IloStartOf(act2)); And introducing additional integer variables would be even worse:
model.add(end1 == IloEndOf(act1)); model.add(start2 == IloStartOf(act2)); model.add(end1 <= start2); Philippe
#CPOptimizer#DecisionOptimization