Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
6 replies Latest Post - ‏2012-09-18T16:48:29Z by GGR
SystemAdmin
SystemAdmin
623 Posts
ACCEPTED ANSWER

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.
Thanks in advance.
Updated on 2012-09-18T16:48:29Z at 2012-09-18T16:48:29Z by GGR
  • AlexFleischer
    AlexFleischer
    75 Posts
    ACCEPTED ANSWER

    Re: How to express adjacent intervals in OPL

    ‏2012-09-17T15:01:55Z  in response to SystemAdmin
    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
    • SystemAdmin
      SystemAdmin
      623 Posts
      ACCEPTED ANSWER

      Re: How to express adjacent intervals in OPL

      ‏2012-09-17T15:54:44Z  in response to AlexFleischer
      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.
      • AlexFleischer
        AlexFleischer
        75 Posts
        ACCEPTED ANSWER

        Re: How to express adjacent intervals in OPL

        ‏2012-09-17T16:11:54Z  in response to SystemAdmin
        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
    GGR
    68 Posts
    ACCEPTED ANSWER

    Re: How to express adjacent intervals in OPL

    ‏2012-09-17T17:20:05Z  in response to SystemAdmin
    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.
    • SystemAdmin
      SystemAdmin
      623 Posts
      ACCEPTED ANSWER

      Re: How to express adjacent intervals in OPL

      ‏2012-09-18T16:27:06Z  in response to GGR
      Thank you.
      That's what I mean. However, could explain your text code? I can not accurately understand. I'm new to OPL.
  • GGR
    GGR
    68 Posts
    ACCEPTED ANSWER

    Re: How to express adjacent intervals in OPL

    ‏2012-09-18T16:48:29Z  in response to SystemAdmin
    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