Specifying interval bounds

Though there are various methods for restricting bounds on interval variables, specifying the bounds in the declaration of the interval variable is recommended.

If you have to specify a minimal start time, a maximal end time or a range of possible values for the size of an interval, it is recommended specify these values in the declaration of the interval itself rather than through expressions IloStartOf, IloEndOf, and IloSizeOf.

Specifying the values at the time of declaration avoids difficulties related to the optionality of intervals variables. For instance, the following code segments are not equivalent:

IloIntervalVar a(env, 10, 20, IloTrue);

and

IloIntervalVar a(env);
a.setOptional();
m.add(IloSizeOf(a) >= 10);
m.add(IloSizeOf(a) <= 20);

The first sample specifies a range for the size of the interval variable if the interval is present. In particular, the model will be consistent even if a is absent. The second sample will be inconsistent if a is absent because the default value of IloStartOf(a) will be 0 if a is absent. An equivalent model would be something like:

IloIntervalVar a(env);
a.setOptional();
m.add(IloSizeOf(a,10) >= 10);
m.add(IloSizeOf(a,0) <= 20);

Additionally, specifying the range at the declaration of the interval is more effective in the optimizer.