Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  DOCPLEX - Add a setup time between two intervals depending on the gap between the two

    Posted 03/11/22 09:57 AM
    Hello,

    I use a cp model with Docplex to schedule orders from a factory under certain constraints. There are a number of orders that can run on a certain machine. I also model transition times (setup) between 2 jobs on the same machine. For example, if job 1 has a black color and job 2 has a red color, I have a transition matrix that represents the time between these two types.

    Here is how I model this:
    On each machine, I create a sequence_var with the intervals, their setup and their type (for exemple, on machine 1, I have job 1 which have setup 1 and wtasks 1 and type 1, type depend on color and others things).

    I get the type of the previous job:
    prev_type = model.type_of_prev(span_sequence, iv, first_type, current_type)

    If types are the same, setup will be absent:
    model.add(model.presence_of(su) == (prev_type != current_type))
    After that, I use my transition matrix:
    model.add(model.length_of(su, setup_matrix_dc[current_type][current_type]) == model.element(prev_type,setup_matrix_dc[current_type]))

    But now I would like to add a setup (of a fixed size) when there is a certain time T between the beginning of a task and the end of the previous task.
    For example, if I want to add a setup when there is more than 10 hours of space between two tasks, I would like to do like this:

    Setup is present if type_prev!=current_type OR model.strat_of(iv) - model.end_of_prev(span_sequence, iv) > 1000.

    Then, I set the size according to the reason of presence of the setup:
    • if model.start_of(iv) - model.end_of_prev(span_sequence > 1000, I set the size to 500 (5 hours)
    • if not, I set the size as I already did with model.length_of(su, setup_matrix_dc[current_type][current_type]) == model.element(prev_type, setup_matrix_dc[ current_type])

    I have the idea but my application is not the right one for the second point.
    I hope I've made myself clear.

    Anyone have an idea?

    It would be appreciated

    Regards,

    Yanis Sellaï
    Integrator / Analytical Developer
    Novipro INC


    ------------------------------
    Yanis Sellaï
    ------------------------------

    #DecisionOptimization


  • 2.  RE: DOCPLEX - Add a setup time between two intervals depending on the gap between the two

    Posted 03/14/22 05:47 AM
    Dear Yanis,

    I suggest you have a look at the https://ibmdecisionoptimization.github.io/tutorials/html/Scheduling_Tutorial.html#Chapter-3.-Adding-workers-and-transition-times-to-the-house-building-problem page. It will show you how to use the no_overlap constraint which does exactly what you need.
    If you define each of the "jobs" interval variable with a type that can be used to index the transition time table, you'll be able to write:
       model.add(model.no_overlap(jobs, setup_matrix_dc))

    I hope this helps.
        Cheers,

    ------------------------------
    Renaud Dumeur
    ------------------------------



  • 3.  RE: DOCPLEX - Add a setup time between two intervals depending on the gap between the two

    Posted 03/14/22 07:33 AM
    Edited by System Admin 01/20/23 04:21 PM
    Dear Yanis,

    Regarding the second point, that is setting setup interval themselves, it could be done as a post processing phase which would introduce, when jobs have been separated by a transition time, the setup size using your rule.
    Would this solution suit your needs?
    Cheers,


    ------------------------------
    Renaud Dumeur
    ------------------------------



  • 4.  RE: DOCPLEX - Add a setup time between two intervals depending on the gap between the two

    Posted 03/14/22 10:36 AM
    Dear Yanis,

    I've also played a bit wht the sched_tcost example to add explicit setup intervals instead of using a post-processing phase.
    It seems to work. The model simply:
    - creates as many setup intervals as there are per-machine task alternatives
    - create a sequence "as" that contains all the task intervals + theirs setups
    - use nOverlap on "as" but without transition times
    - force endAtStart(setup, task) for each setup/task
    - force the presence of each setup to match the presence of the task
    - constrain the length of each setup to be the delay between the corresponding task and the previous task in the original sequence "s" (but here you can use whatever formula you want):

    subject to {
    forall (i in Tasks)
    alternative(a[i], all(m in Machines) alt[i][m]);
    forall (m in Machines) {
    // non overlapping jobs (transition is distance to next)
    noOverlap(s[m],tt[m],1);
    // no overlapping setup + job activities
    noOverlap(as[m]);
    forall(i in Tasks) {
    // setup is present if alternative is selected
    presenceOf(setups[i][m]) == presenceOf(alt[i][m]);
    // the setup ends at the start of activity
    endAtStart(setups[i][m], alt[i][m]);
    // length of setup is the distance between two intervals
    lengthOf(setups[i][m]) == (startOf(alt[i][m], 0) - endOfPrev(s[m], alt[i][m], 0));
    }
    }
    }

    I hope it helps,

    Cheers,

    ------------------------------
    Renaud Dumeur
    ------------------------------