Alex
Alex

Reputation: 81

How to define a sequence dependant constraint?

I want to model a constraint where I want to say if a mode mode1 is scheduled on a sequence before another mode mode2 then a mode mode3 on a parallel working machine (so in an other sequence) cannot be started before the end of mode1 in an other sequence. So more or less I want to code an if (before...) block for that. How does it work correctly?

forall(m1 in Modes, m2 in Modes, m3 in Modes: 
       m1.opId==1 && m2.opId==2 && 
       m3.opId==3 && m1.mch==m2.mch==1) {
    if (before(mchs[1], modes[m1], modes[m3]) == 1) {
        endBeforeStart(modes[m1],modes[m2);
    }
;}

Upvotes: 2

Views: 152

Answers (1)

Philippe Laborie
Philippe Laborie

Reputation: 446

Of course, you could post a constraint like (H is a large number):

(endOf(mode1,H) <= startOf(mode2,-H)) => (endOf(mode1,-H) <= startOf(mode3,H))

Explanation:

  • if mode1, mode2 and mode3 are all present, the constraint is: (endOf(mode1) <= startOf(mode2)) => (endOf(mode1) <= startOf(mode3))
  • if mode1 or mode2 is absent, because of the constants H, the left side of the implication is false, so it does not constrain mode3
  • if mode1 or mode3 is absent, the right side of the implication is true, so it does not constrain mode2

Now, if you have many triplets (mode1,mode2,mode3) on which this constraint holds, it will be very useful to consider a more global formulation that also exploits other constraints of the problem: what do mode2 and mode3 have in common so that if mode2 is executed after mode1 then mode3 also needs to be executed after? Is there some other temporal dependency between mode2 and mode3? Are there some logical constraints underneath (like presenceOf(mode1)==presenceOf(mode2)) ? etc.

In fact, the definition of the problem is still not clear to me. Let me summarize my understanding :

  • each job i consists of two activities: ‘prep_i’ followed by ‘op_i’
  • both ‘preparation’ and ‘operation’ activities must be allocated to some machines (a machine can only perform one activity at a time)
  • it is possible that the ‘preparation’ and ‘operation’ of a given job are performed on the same machine, but it is not required

Now what is still not clear:

  • it seems that, for a given machine M, if we denote ‘op_i1’ -> ’op_i2’ -> ‘op_i3’ … the sequence of operation on the machine, then the corresponding preparation activities ‘prep_i1’, ‘prep_i2’, ‘prep_i3’, … must also be ordered in the same way (even if they are not necessarily executed on the same machine). Is it true? And also could it be that you additionally want the ordering: ‘prep_i1’ -> ‘op_i1’-> ‘prep_i2’ -> ‘op_i2’ -> ‘prep_i3’ -> ‘op_i3’ … ?
  • if not, and if the problem is only that the preparation activities ‘prep_i’ additionally require some additional resources available in a limited number, why don’t you just model these additional resources using a cumul function (or other noOverlap if you need also to handle the allocation of these resources) to limit the number of preparation activities that can be executed in parallel ?

Upvotes: 1

Related Questions