Hi,I will create a scheduling model. I have some interval variables represent the container ship unloading tasks.The chain of intervals is nonoverlap 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.
Thanks in advance.
Topic

Re: How to express adjacent intervals in OPL
20120917T15:01:55ZThis is the accepted answer. This is the accepted answer.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 
Re: How to express adjacent intervals in OPL
20120917T15:54:44ZThis is the accepted answer. This is the accepted answer. AlexFleischer
 20120917T15: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.
<pre class="jivepre">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. 
Re: How to express adjacent intervals in OPL
20120917T16:11:54ZThis is the accepted answer. This is the accepted answer. SystemAdmin
 20120917T15:54:44Z
Thanks for your answer.
But, how to determine interval c and d are adjacent tasks? I don't know the order of the tasks in the tasks chain.
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 
Re: How to express adjacent intervals in OPL
20120917T17:20:05ZThis is the accepted answer. This is the accepted answer.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. 
Re: How to express adjacent intervals in OPL
20120918T16:27:06ZThis is the accepted answer. This is the accepted answer. GGR
 20120917T17: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="jivepre">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="jivepre">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.
That's what I mean. However, could explain your text code? I can not accurately understand. I'm new to OPL. 
Re: How to express adjacent intervals in OPL
20120918T16:48:29ZThis is the accepted answer. This is the accepted answer.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
About the model.
span(dvar interval master, dvar interval[] slaves) is a constraint that tell that master spans the slaves. That is a slave interval is in the master interval and the master interval start point is the minimum start point among the slaves intervals and conversely with end. please refer to item "Constraints on groups of interval variables in CP Optimizer" of CP Optimizer > CP Optimizer C++ API Reference Manual > Concepts entry of the CP Optimizer reference manual.
I want to build a sequence of C, D interval but I know that C[i] immediately precedes D[i] in the sequence. So, Hierarchically, the sequence is the sequence of block C[i]>D[i]. The block C[i]>D[i] is spanned by intervals CD[i] then I declare the sequence of CD[i].
The main advantage of this model is that the number interval variables of the sequence is minimal and it allows to model exactly the hierarchical structure of a solution 1) block (C precede D) and sequence of such block. Imagine the blocks are composed of 4 intervals instead of 2, the advantage appears quite evidently.
Hope that helps