Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Querying CP Optimizer's precedence graph

  • 1.  Querying CP Optimizer's precedence graph

    Posted Sun July 19, 2015 11:28 PM

    Originally posted by: JorisK


    Given the following 3 tasks, represented as Interval Variables.
    task t1. interval: [10,19]
    task t2. interval: [20,30]
    task t3. interval: [5,35]
    Assume that all tasks have duration 1 and are mandatory to schedule. From the time windows, it is apparent that task t1 has to be scheduled before task t2, but the exact sequence is still unclear as task t3 can happen before, between or after tasks t1 and t2.
    I'm trying to implement a custom constraint which requires me to get access to the precedence graph maintained by CP optimizer. Given a sequence variable ILCIntervalSequenceVar, how can I query whether a particular task has to occur before another tasks? As far as I can tell, the only two methods I have to my disposal are:
    -isEarlierInHead(IlcIntervalVar earlier, IlcIntervalVar later)
    -isEarlierInTail(IlcIntervalVar earlier, IlcIntervalVar later)
    However, in this simple example, neither of the tasks are sequenced, so they don't belong to the head or the tail of the sequence, yet there is a clear precedence relation between tasks t1 and t2?

    There is a method 'setBefore' to state that a particular task has to occur before another task, but there doesn't seem to be a method to query whether a particular task has to occur before another task? 


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Querying CP Optimizer's precedence graph

    Posted Mon July 20, 2015 12:17 PM

    Originally posted by: ol


    Hello,

    not sure of what you need exactly, but in your case why not just comparing the ending and starting times of the tasks?

    regards,

    Olivier


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Querying CP Optimizer's precedence graph

    Posted Mon July 20, 2015 12:24 PM

    Originally posted by: JorisK


    Hi Olivier,

    That could work, but it's a very poor solution. CP optimizer can deduce additional precedence relations which do not solely rely on start and end times of intervals. By just comparing the start and end times, you would miss a potentially large number of precedence relations. I just received the following reply from Philippe Laborie:

    Indeed, in cpext.h, I see that there is a function: 
    IlcIntervalSequenceVar:: isBefore(const IlcIntervalVar pred, const IlcIntervalVar succ) 
    That should implement what you want, but this function is not documented (I think it should). 
    In any case, you can use it. For that you need that a (complete) precedence graph is created on the sequence, this can be 
    achieved by setting parameter IloCP:: IntervalSequenceInferenceLevel to IloCP::Extended. 
    We will fix this lack of documentation. 

    This solves my problem.

     

    thanks,

    Joris Kinable 


    #CPOptimizer
    #DecisionOptimization