Originally posted by: SystemAdmin
Hello,
There is nothing tricky in the syntax:
sum(t in T) ((z[t]==1) && (x<=t) && (t<=y)) == 1;
For a given t in T,
((z[t]==1) && (x<=t) && (t<=y)) is an integer (boolean) expression; you can sum up integer expressions, this gives an integer expression and you post the constraint that this expression is equal to 1.
What is not allowed in the OPL syntax is to use non-ground integer expressions or decision variables in the
scope of the sum, max, min.
Possible variant (but very close) is:
sum(t in T) minl(z[t], (x<=t), (t<=y)) == 1;
If [x,y] represents an interval of time (for instance an activity) and the domain of T is very large, you may also consider modeling [x,y] as an interval variable:
dvar interval act in T;
If you can leverage the scheduling concepts (constraints, expressions) provided in OPL around interval variables to avoid an explicit enumeration of time (t in T), that can result in a very efficient model. For a description of those scheduling concepts, have a look at this section of the documentation:
IDE and OPL > Optimization Programming Language (OPL) > Language Reference Manual > OPL, the modeling language > Scheduling
Philippe
#DecisionOptimization#OPLusingCPOptimizer