Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Can't extract constraint

    Posted 11/23/09 09:55 AM

    Originally posted by: Capablanca93


    IloActivity act;
    IloModel model;
    // act = ...
    // model = ...
    IloIntVar startDate(env);
    IloConstraint ct1 = act.startsAt(startDate);
    IloConstraint ct = ((startDate % (60*5)) == 0); // 5 minutes
    model.add(ct && ct1);

    with only ct1, model extracts, with ct && ct1, the model can't extract (because of ct according to the exception message).
    Where am I wrong ?

    Sincerly.
    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: Can't extract constraint

    Posted 12/03/09 11:20 AM

    Originally posted by: SystemAdmin


    Hello,
    In fact, the modulo expression (%) is not supported in Solver. If you want to remove some possible values from the domain of the start time of an activity, you have two options:

    (1) either directly define a start variable with the discrete set of possible values:

    
    
    // Option (1) IloIntArray possStarts(env); 
    
    for (IloInt i=0; i<horizon; i+=300) 
    { possStarts.add(i); 
    } IloIntVar startDate(env, possStarts); model.add(act.startsAt(startDate));
    


    (2) or, in Scheduler by defining a calendar on a resource with shift objects:

    
    
    // Option (2) IloDiscreteResource res(env, 10000); 
    // Large capacity IloIntervalList noStart(env, 0, horizon); 
    
    for (IloInt i=0; i<horizon; i+=300) 
    { noStart.addInterval(i+1, i+300); 
    // Activities cannot start on [i+1,i+300) 
    } IloShiftListObject shifts(env, noStart, IloShiftListObject::OnStart); IloCalendar cal(env); cal.addShiftObject(shifts); res.setCalendar(cal); model.add(act.requires(res));
    


    The advantage of the second option is that the calendar will be applied to all activities requiring the resource.
    In a more general context, you could also replace (x%a) by (x - a*IloDiv(x,a)).

    Hope it helps.
    #CPOptimizer
    #DecisionOptimization