Topic
• 2 replies
• Latest Post - ‏2012-09-19T13:12:50Z by GGR
623 Posts

Pinned topic problem in OPL

‏2012-09-18T16:40:01Z |
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 ?
Updated on 2012-09-19T13:12:50Z at 2012-09-19T13:12:50Z by GGR
623 Posts

Re: problem in OPL

‏2012-09-19T03:56:58Z
``````

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.
• GGR
83 Posts

Re: problem in OPL

‏2012-09-19T13:12:50Z
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 meta-constraint 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