Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Very basic question about IloIntervalVars

  • 1.  Very basic question about IloIntervalVars

    Posted Mon February 25, 2013 11:27 AM

    Originally posted by: SystemAdmin


    Hi everyone
    I have a very basic quesiton about Interval Vars.
    I'm optimizing a time table. The "open hours" are 8AM to 4PM Monday through Thursday and 8AM to 1PM Friday. I want to schedule a task of fixed length of 2 hours with the open hours.
    Using this convention: the week starts at Sunday midnight; the open hours are these 5 constant ranges: 8-16,32-40,56-64,80-88,104-109. I want IloIntervalVar myvar with fixed length 2 to get values during the open hours.
    What is the best way to define this constraint?
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Very basic question about IloIntervalVars

    Posted Mon February 25, 2013 04:33 PM

    Originally posted by: SystemAdmin


    Hello.

    The best way to model that is constraint forbidExtent in OPL (in C++ it is IloForbidExtent). Using this constraint you can specify intervals of times that the interval variable cannot overlap. For task with fixed size you can achieve the same effect using also forbidStart or forbidEnd constraints, however forbidExtent is simpler.

    You can also have a look on sched_calendar example delivered with CPLEX Optimization Studio.

    Best, Petr
    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: Very basic question about IloIntervalVars

    Posted Tue February 26, 2013 05:44 AM

    Originally posted by: ChrisBr


    Hello,

    In addition to what Petr has answered, I would try to give you more details.
    One simple way would be to use a stepwise function and use it in a forbidExtent constraint.

    For example, you can define the stepwise function
    
    IloNumToNumStepFunction openHours(env); openHours.setValue(0, 5*24-1, 0);
    

    then define the open hours
    
    openHours.setValue(  8, 16, 100); openHours.setValue( 32, 40, 100); openHours.setValue( 56, 64, 100); openHours.setValue( 80, 88, 100); openHours.setValue(104,109, 100);
    

    Then you can use the forbidExtent constraint:
    
    IloIntervalVar myvar(env, 2); model.add(IloForbidExtent(env, myvar, openHours));
    

    which means that whenever interval variable myvar is present, it cannot contain a value t when openHours(t)=0.

    I hope that helps,

    Chris.
    #CPOptimizer
    #DecisionOptimization