Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Flexible Job Shop - simple Job problem

    Posted Tue November 12, 2019 11:59 AM

    Originally posted by: kcapt


    Hello good people!

    As I said before I'm new to Cplex and programming languages so I'm sorry in advance If I don't understand something.

    The example sched_jobshopflex works wonderfull for jobs that have 3 or more operations, and for that I'm thankfull.

    However, when a job has only 2 operations ( Position 0 and Position 1). I want to create a this restriction:

    When a job has got only 2 operations.

    Cplex can choose the first machine to perform the first operation (Position 0).

    However, the second operation (Position 1) must be carried out on a machine that is dependent position 0.

     

    To be more precise, when a job has got ONLY 2 OPERATIONS it can be either one of these cases:

    • Machine 1 perfoms the first operation (position 0) and the machine 6 perfomns the second (position 1).
    • Machine 2 perfoms the first operation (position 0) and the machine 7 perfomns the second (position 1).
    • Machine 3 perfoms the first operation (position 0) and the machine 8 perfomns the second (position 1).

    Take a look in the image below, it will help to understand.

    I have also attached the files. Thanks!

    ----------------------------------------------------------------------------------------

    I have tried to do something like this but this won't work...

    forall (j in Jobs, m1 in Modes, m2 in Modes: m1.opId==j && m2.opId==1+m1.opId , o1 in Ops, o2 in Ops: o1.jobId==j && o2.jobId==j && o1.pos==0  && o2.pos==1) 
                if(m1.mch==2){
                        m2.mch==7;
                        }

    ----------------------------------------------------------------------------------

    Can a alternative opl constrain or a presenceOf solve this problem? I'm really lost...


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: Flexible Job Shop - simple Job problem

    Posted Fri November 15, 2019 05:30 AM

    Originally posted by: PhilippeLaborie


    Sure, here you should use constraints between the presence of interval variables.For instance if itv_0_i denotes the (possible) execution of first operation to machine i and itv_1_j the (possible) execution of second operation to machine j, then you would add constraints:
     

    presenceOf(itv_0_1) == presenceOf(itv_1_6)
    presenceOf(itv_0_2) == presenceOf(itv_1_7)
    presenceOf(itv_0_3) == presenceOf(itv_1_8)
    

    This way, if the first operation is allocated to machine 1 (itv_0_1 is the one selected to be present by the alternative constraint), then necessarily, the second operation will be allocated to machine 6 (as the equality constraint on presence, will enforce itv_1_6 to be present).

    This is the classical way to formulate dependency between resource allocation in CP Optimizer.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: Flexible Job Shop - simple Job problem

    Posted Fri November 15, 2019 08:11 AM

    Originally posted by: kcapt


    Yes, now it starts to make some sense. But in this case I should adapt the presenceOf(<TUPLE>) ==presenceOf(<TUPLE>), right? Is there any example of PresenceOf with tuples?

     

     

    Correct me If I'm wrong, in this case I'll have to compare the presenceOf machines in Modes (check the image) :

      forall (j in Encomendas,o1 in Ops, o2 in Ops: o1.jobId==j && o2.jobId==j && o2.pos==1+o1.pos)

           forall(m1 in Modes, m2 in Modes: m2.opId==1+m1.opId)
                   presenceOf(<m1.opId,   1  ,m1.pt>) == presenceOf(<m2.opId,  6   ,m2.pt>);

                   presenceOf(<m1.opId,   2  ,m1.pt>) == presenceOf(<m2.opId,  7   ,m2.pt>);

                   presenceOf(<m1.opId,  3  ,m1.pt>) == presenceOf(<m2.opId,  8   ,m2.pt>);

    Sorry, I know this code has got many erros...

    Thank you!

    (Note: the processing times are allways the same, not sure if that can help in this case)


    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: Flexible Job Shop - simple Job problem

    Posted Fri November 15, 2019 08:53 AM

    Originally posted by: PhilippeLaborie


    No, presenceOf(x) is a constraint, it should be posted on decision variables, here interval variables. So something like:

    presenceOf(modes[md1]) == presenceOf(modes[md2]);

    Where md1 and md2 are tuples corresponding to the adequate combinations of operations and machines.

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: Flexible Job Shop - simple Job problem

    Posted Tue November 19, 2019 10:19 AM

    Originally posted by: kcapt


    Sorry for the late reply but it did work! Thanks.

    Both 1 and 2 works, which one do you think it's better to use ?

    ----------------------------------------------------------------------------------------
      1 -forall(md1 in Modes, md2 in Modes: md2.opId==1+md1.opId && md2.mch==5+md1.mch)    

    (or)
       2-  //forall(o1 in Ops, o2 in Ops,md1 in Modes, md2 in Modes: o2.pos==1+o1.pos && md2.opId==1+md1.opId && md2.mch==5+md1.mch)         
               c7:
          presenceOf(modes[md1]) == presenceOf(modes[md2]);

    ----------------------------------------------------------------------------------------

    Again, thank you very much!


    #ConstraintProgramming-General
    #DecisionOptimization


  • 6.  Re: Flexible Job Shop - simple Job problem

    Posted Wed November 20, 2019 05:31 AM

    Originally posted by: PhilippeLaborie


    In the end, the CPO model will be the same I think, but version 1 looks more efficient from an OPL point of view as the scope of the iteration (without the filtering condition) is smaller...


    #ConstraintProgramming-General
    #DecisionOptimization