Topic
• 6 replies
• Latest Post - ‏2012-09-18T16:48:29Z by GGR
623 Posts

# Pinned topic How to express adjacent intervals in OPL

‏2012-09-17T14:14:39Z |
Hi,I will create a scheduling model. I have some interval variables represent the container ship unloading tasks.The chain of intervals is non-overlap and between adjacent tasks need transition time.I want to decide the order of the tasks.Could you tell me how to express the adjacent tasks in OPL so that I can constrain them ? Could you give me a example?
Sorry for my english and hope you can understand me.
Updated on 2012-09-18T16:48:29Z at 2012-09-18T16:48:29Z by GGR
• AlexFleischer
200 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-17T15:01:55Z
Hi

have you tried endBeforeStart ?

The following precedence constraint states that the end of interval c plus 5 time units is less than or equal to the start of interval d.

``````
endBeforeStart(c,d,5);```
```

regards
623 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-17T15:54:44Z
Hi

have you tried endBeforeStart ?

The following precedence constraint states that the end of interval c plus 5 time units is less than or equal to the start of interval d.

<pre class="jive-pre">``` endBeforeStart(c,d,5);``` </pre>
regards
But, how to determine interval c and d are adjacent tasks? I don't know the order of the tasks in the tasks chain.
• AlexFleischer
200 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-17T16:11:54Z
But, how to determine interval c and d are adjacent tasks? I don't know the order of the tasks in the tasks chain.
Hi

so then you should use noOverlap which is used to prevent intervals in a sequence from overlapping and (optionally) to enforce a minimal distance between consecutive intervals.

regards
• GGR
83 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-17T17:20:05Z
Hi

If you mean by adjacent c is the immediate predecessor of d in the sequence, you have also to add the constraint telling it

``````
dvar interval CD[1..2*Nb] =
/* the set of c's, d's */   dvar sequence unloader in CD;
/* ... */   subject to
{
/* .. */ noOverlap(unloader); forall(i in 1..Nb)
{ endBeforeStart(CD[2*i],CD[2*i + 1],5); previous(unloader, CD[2*i], CD[2*i + 1]);
}
/*...*/
}```
```

Eventually, in this case, there is a stronger model. In fact the unloader will sequence the block (c->d). That is the span of (c, d)
``````
dvar interval CD[1..2*Nb] =
/* the set of c's */   dvar interval Chains[1..Nb] dvar sequence unloader in Chains;
/* ... */   subject to
{
/* .. */ noOverlap(unloader); forall(i in 1..Nb)
{ endBeforeStart(CD[2*i],CD[2*i+1],5); span(Chains[i], all (j in 1..2*Nb, div(j, 2) == i));
}
/*...*/```
```

in practice the second model is more <<natural>> as it adjusts the tasks in the sequence by using the hierarchy of the model.
623 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-18T16:27:06Z
• GGR
• ‏2012-09-17T17:20:05Z
Hi

If you mean by adjacent c is the immediate predecessor of d in the sequence, you have also to add the constraint telling it

<pre class="jive-pre">``` dvar interval CD[1..2*Nb] = /* the set of c's, d's */ dvar sequence unloader in CD; /* ... */ subject to { /* .. */ noOverlap(unloader); forall(i in 1..Nb) { endBeforeStart(CD[2*i],CD[2*i + 1],5); previous(unloader, CD[2*i], CD[2*i + 1]); } /*...*/ }``` </pre>
Eventually, in this case, there is a stronger model. In fact the unloader will sequence the block (c->d). That is the span of (c, d)
<pre class="jive-pre">``` dvar interval CD[1..2*Nb] = /* the set of c's */ dvar interval Chains[1..Nb] dvar sequence unloader in Chains; /* ... */ subject to { /* .. */ noOverlap(unloader); forall(i in 1..Nb) { endBeforeStart(CD[2*i],CD[2*i+1],5); span(Chains[i], all (j in 1..2*Nb, div(j, 2) == i)); } /*...*/``` </pre>

in practice the second model is more <<natural>> as it adjusts the tasks in the sequence by using the hierarchy of the model.
Thank you.
That's what I mean. However, could explain your text code? I can not accurately understand. I'm new to OPL.
• GGR
83 Posts

#### Re: How to express adjacent intervals in OPL

‏2012-09-18T16:48:29Z
Hi

First I made a mistake, in OPL div (the integer division) must be used as an operator. That is you write

``````
j div 2```
```