Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Docplex CP Sequence_var issue

    Posted Wed April 09, 2025 10:21 PM

    Experts:

    I am developing a production scheduling application using Docplex CP and Python and have encountered an issue when using sequence variables

    I have distilled the problem in an attempt to isolate the issue as follows.

     

    I have a 2 stage production process as illustrated. Imagine it as a mixing process A followed by a bottling process B

     


    Both A and B have sequence variables with transition matrices. For A there are multiple colours, and for B there are multiple bottle sizes. Consider the intervening object a tank. There is a temporal constraint that states that activities on B must start_after A.

     

    THIS WORKS EXACTLY AS REQUIRED !!!

     

    The problem arises if there are alternatives at B, as below:

     


    If there is no sequence_var & transitions on A, it works fine, and sequences and transitions are respected and makespan is minimised per objective.

     

    BUT, when there are sequence variables on all three resources, the result is NO SOLUTION. The solver runs endlessly until solve time limit without finding a solution.

    NOTE: it is not infeasible

    I figure this means that at least one variable is not instantiated.


    Questions:
    1. Is there an issue with sequence_var's in DOCPLEX CP?

    2. How can I find which variable(s) are not instantiated during the solve?
    3. What additional constraints should I add to properly constrain the problem?

     

    Thanks

    Ross

     



  • 2.  RE: Docplex CP Sequence_var issue

    Posted 29 days ago

    Hello Ross,

                   You can define three "dummy" interval variables of null size lastA, firstB and firstB1.

     You constraint lastA to be the last in sequence A and firstB (respectively firstB1) to be the first in sequence B (respectively B1).

    See docplex.cp.modeler.last(sequence, interval) and docplex.cp.modeler.first(sequence, interval). 

    You must force lastA to finish before firstB and firstB1 start. See docplex.cp.modeler.end_before_start(a, b, delay=None).

    Regards,

    Thierry.



    ------------------------------
    Thierry Sola
    ------------------------------



  • 3.  RE: Docplex CP Sequence_var issue

    Posted 22 days ago

    Hi Thierry
    Thanks for the response. It looks like your solution is trying to create some "connection" between the upstream & downstream sequences to avoid 'ambiguity'?. If so can you help me understand the issue please?

    My problem is quite a bit more complicated than mentioned previously - as mentioned I simplified the model to isolate the problem.
    In reality the model is similar to:
    In addition there may be multiple stages - the above shows only two stages, ie there may be T3,T4,T5 etc feeding to C1,C2...

    So how would I apply your solution to this model. I think it will be problematic if I make the start of ALL intervals at B start_after ALL intervals at A.

    Greatly appreciate your advice. I am at an impasse right now

    Thanks

    Ross



    ------------------------------
    Ross Dye
    ------------------------------



  • 4.  RE: Docplex CP Sequence_var issue

    Posted 15 days ago

    Hello,

    You can simply add a dummy interval of size 0, say DI, between two phases to synchronize. Then constrain the last tasks (possibly dummy too as Thierry suggested to you)  of each sequenceVars of phase 1 to be before DI, and constrain the first tasks of the sequenceVars of phase 2 to be after DI.

    That way you will have a linear number of additional constraints instead of quadratic.



    ------------------------------
    Olivier Lhomme
    ------------------------------



  • 5.  RE: Docplex CP Sequence_var issue

    Posted 14 days ago

    Thierry, Olivier
    I have found the root cause..... my design!
    I will refactor the code and try again

    Thanks again, sorry to bother you



    ------------------------------
    Ross
    ------------------------------