Hi
I want to achieve the following objectives:
int shttp://1..nhttp://1..n = ... ;
dvar interval qhttp://i in 1..n;
dvar interval yhttp://i in 1..n;
subject to{
forall (i,j in 1..n)
if(startOf(q[i])<startOf(q[j]))
startOf(q[j]) >= startOf(y[i]) + s[i][j];
}
It doesn't work. How could I express the constraint corretly in OPL ?
Topic

Re: problem in OPL
20120919T03:56:58ZThis is the accepted answer. This is the accepted answer.int s[1..n][1..n] = ... ; dvar interval q[1..n] ; dvar interval y[1..n] ; subject to { forall (i,j in 1..n) if( startOf(q[i])<startOf(q[j]) ) startOf(q[j]) >= startOf(y[i]) + s[i][j]; }
How could I express the constraint corretly in OPL ?
Thanks. 
Re: problem in OPL
20120919T13:12:50ZThis is the accepted answer. This is the accepted answer.Hi
First af all I will suggest you to have a look on the reference and documentation manuals for OPL and CPO for scheduling. That is interval variable based models. You will find all information and OPL modeling language
IDE and OPL > Optimization Programming Language (OPL)
more particularly
IDE and OPL > Optimization Programming Language (OPL) > Language Reference Manual > OPL, the modeling language
and CP Optimizer > CP Optimizer C++ API Reference Manual > Concepts
more particularly
Introduction to Scheduling Concepts in CP Optimizer
For example in your sample code you 2 mistake
1) in OPL Modeling language
if(startOf(q[i])<startOf(q[j]))
is not allowed, the if must be a condition that can be computed by OPL interpreter not a constraint (that is a conditionn on solution of the model to solve).
2) in scheduling modeling
startOf(q[j]) >= startOf(y[i]) + s[i][j];
This is a bad idea. You should use a precedence constraint between interval
startBeforeStart(y[i]), g[j] s[i][j])
This precedences does not support the CP metaconstraint to express a disjunction (a or constraint between constraint). Instead of this an interval variable own a boolen variable the presence that you can acces using the constraint presenceOf on an interval variable. Each disjunction is then model using a pair of interval variable whose presence constraint us used to express the disjunction.
Hope that helps