Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Mon May 18, 2020 02:20 AM
    Hi,

    I try to modeling sequence-dependent setup times in a open shop scheduling problem with transition matrix and noOverlap constraint:
    forall(i in m)
    	noOverlap(mac[i], setup[i], 0);	

    But, I get a solution where setup times are executed before the jobs finish on the previous machines, like anticipated setup times. I would like a restriction that forces setups to be performed only after the job is finished on the previous machine.

    I try with sequence expressions, where s[i, j, k] is the setup time of job j processed after job k in machine i, mac is a sequence variable of permutation of jobs in each machine and job is a sequence variable of permutation of machines in each job.

    forall (i in m, j in n)
       startOfNext(mac[i], x[i, j], maxint, maxint) >= endOf(x[i, j], 0) + s[i][typeOfNext(mac[i], x[i, j], j, j)][j];
     
    forall (i in m, j in n)
    
     startOfNext(job[j], x[i, j], maxint, maxint) >= endOf(x[i, j], 0);// + s[typeOfNext(job[j], x[i, j], i, i)][j][*];
    


    * I need to indicate the index of the last job processed of the next machine of job j sequence

    Is there another form of modeling non-anticipatory setup times?

    or

    Can someone help me to model this constraint with sequence variables?

    Many Thanks,

    Levi Abreu

    ------------------------------
    Levi Abreu
    ------------------------------

    #DecisionOptimization


  • 2.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Mon May 18, 2020 03:25 PM
    Are you using interval variables for operations? If so, you might look at the endBeforeStart constraint, which lets you specify a delay (the sequence-dependent setup time) between the end of one interval (operation) and the start of another.

    ------------------------------
    Paul Rubin
    ------------------------------



  • 3.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Tue May 19, 2020 11:38 AM
    Oops! After reading Petr's reply, I remembered that endBeforeStart does not reserve the machine during the delay time. So it would be suitable for prepping the second job outside the machine after the first job finished (with the machine possibly doing something else during the prep time) but not for a setup on the machine. Petr is correct: you should use interval variables for the setups and sequence them like normal tasks.

    ------------------------------
    Paul Rubin
    ------------------------------



  • 4.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Tue May 19, 2020 04:44 AM
    Hello,

    If I understand correctly, setup time before x[i,j] should not start while operation on the previous machine x[i-1, j] is still executing. Indeed, I don't see a way how to model it using standard setup times. One possibility I see is to introduce additional interval variables setup[i,j] for the setup just before x[i,j]. Then we can constrain the setup to start after x[i-1, j] by:
    endBeforeStart(x[i-1, j], setup[i, j]);
    The operation must start right after the setup:
    endAtStart(setup[i, j]), x[i, j]);
    And length of the setup depends on the type of previous interval on the sequence:
    lengthOf(setup[i,j]) == s[i][typeOfPrev(mac[i], setup[i,j], j, j)][j];
    In the constraint above it is necessary to be careful about the case when the setup is the first interval in the sequence variable. Then typeOfPrev will be j (the third parameter of typeOfPrev) and I assume that s[i,j,j] is 0, therefore the length of the first setup is 0.
    Note that intervals setup[i, j] must be part of sequence variable mac[i] therefore they also must have a type (in declaration of a sequence variable it is possible to specify types of the intervals in the sequence). Types of setup[i, j] doesn't matter though since there shouldn't be two consecutive setups on the sequence. Therefore all setups can use one single type (for example).

    Depending on other constraints in your model, it may be possible to simplify the model above: use just one interval variable xwithsetup[i,j] for both x[i, j] and setup[i, j]. Then we have simple precedence between operations in one job:
    endBeforeStart(xwithsetup[i-1, j], xwithsetup[i, j]);
    And length of xwithsetup is a sum of length of the operation itself (lets say we have a 2D array length[i, j] for this purpose) and the setup:
    lengthOf(xwithsetup[i,j]) == length[i,j] + s[i][typeOfPrev(mac[i], xwithsetup[i,j], j, j)][j];

    Best regards, Petr

    ------------------------------
    Petr Vilím
    IBM
    ------------------------------



  • 5.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Sun May 24, 2020 10:31 AM
    Hello @Petr Vilím and @Paul Rubin,

    Thanks for all your reply, I could model non-anticipatory setup times with additional interval variable (setup[i, j])​​​​, but I needed to create a new sequence variable (job[j]) and a new constraint (UniqueMaqJobAtTime) to prevent that an operation (setup + process time) cannot be processed in more of one machine in the same time. There is no sequence order of operation in each machine.

    The final code is bellow:
    dvar interval x[i in m, j in n] size p[i, j];
    dvar interval setup[i in m, j in n];
    dvar sequence mac[i in m] in append(all(j in n) x[i, j], all(j in n) setup[i, j]) types append(t, t);
    dvar sequence job[j in n] in append(all(i in m) x[i, j], all(i in m) setup[i, j]) types append(t, t);
    
    minimize max(i in m, j in n) endOf(x[i, j]);//Makespan minimization
     
    subject to{
      
    UniqueJobMaqAtTime:    
    forall(i in m)
        noOverlap(mac[i]);
        
    UniqueMaqJobAtTime:    
    forall(j in n)
        noOverlap(job[j]);
        
    SetupBeforeProc:  	
    forall(i in m, j in n)
      	endAtStart(setup[i, j], x[i, j]);
      
    SetupDepSeq:	
    forall(i in m, j in n)
      	lengthOf(setup[i,j]) == s[i][j][typeOfPrev(mac[i], setup[i,j], j, j)];
    
    };​​


    And I will try to simplify the model, adding xwithsetup interval variable. I have another question about typeOfPrev. How to use this function in python docplex? I modeling "SetupDepSeq:" constraint but I get a error when acess index of s matrix (a numpy array):

    for i in m:
        for j in n:
            k = modelo.type_of_prev(mac[i], setup[i][j], j, j)
            modelo.add( modelo.length_of(setup[i][j]) == s[i][j][k] )

    typeOfPrev(mac[i], setup[i,j], j, j) returns "docplex.cp.expression.CpoFunctionCall" and gets an error to access index k in setup matrix:

    IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices


    How to access the integer index of the type of operation in type_of_prev function?

    Many Thanks,



    ------------------------------
    Levi Abreu
    ------------------------------



  • 6.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Mon May 25, 2020 04:44 AM
    Hello @Levi Abreu,

    I think that in Python the problem is the expression s[i][j][k] because k is not a constant (at modeling time), it is an integer expression. A different syntax is needed to index an array using integer expression: element. Here is the doc: https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.modeler.py.html?highlight=operator#docplex.cp.modeler.element .

    Best regards, Petr

    ------------------------------
    Petr Vilím
    IBM
    ------------------------------



  • 7.  RE: How to modelling non-antecipatory setup times in CP Optimizer?

    Posted Fri May 29, 2020 01:35 PM
    Thank you so much for your reply, it works perfectly! :)

    Many Thanks,

    ------------------------------
    Levi Abreu
    ------------------------------