Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloIntervalSequenceVar and get the starting times

    Posted 01/12/18 05:37 AM

    Originally posted by: MatthGond


    Hello,

    I have a problem in which I have to schedule some operation (or activities). Each operation Oi has a date date_op(Oi) before that it is preferable to start Oi.
    I would minimize the number of operations which start after their respective date_op.
    For example, operation O1 can be run between 10 and 500, has a duration of 50 and its date_op = 200 (which mean I would prefer run O1 before 200 than after).

    I use IloNoOverlap and I would also count the number of operation scheduled before their date_op.
    I do not know how get the starting time fiwed by the constraint IloNoOverlap of the operations.
    I try to write a constraint like : model.add(IloIfThen(env, St[i].??? <date, Theta[i]==1)).

     

    A short piece of my code  --------------

                IloBoolVarArray Theta(env, nb_Tache); // Theta[i]=1 if the operation i starts before date[i]
                for (int i = 0; i < nb_Tache; i++)
                {    Theta[i] = IloBoolVar(env);}

                 IloIntArray tp(env, nb_Tache );
                 IloTransitionDistance distance(env, nb_Tache );
                 IloIntervalVarArray St(env, nb_Tache) ; // All operations can start between 0 and 500.
                 IloIntervalSequenceVar operation(env, St, tp);
                 model.add(IloNoOverlap(env, operation, distance, IloTrue));

                for (int i = 0; i < nb_Tache; i++)
                {
                                int date=my_data.date_op[i]; // I want to know if operation i starts before "date_op" which is a data of my problem

                               model.add(IloIfThen(env, St[i].??? <date, Theta[i]==1));
                                // I would know the starting time of St[i] given by the constraint IloNoOverlap
                }

    ---------------------------------


    thank you very much for your help

    Matth


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: IloIntervalSequenceVar and get the starting times

    Posted 01/12/18 11:31 AM

    Originally posted by: ChrisBr


    Hello Matthieu,

    You can try:

      model.add(Theta[i] == (IloStartOf(St[i], 0) < my_data.date_op[i]))
    

    Actually you might not need the bool vars Theta. If you only want to minimize the number of operations which start after their respective date_op you can try:

    IloExpr count = IloIntExpr(env, 0);
    for (int i = 0; i < nb_Tache; i++)
      count += (IloStartOf(St[i], 0) >= my_data.date_op[i])
    model.add(IloMinimize(env, count);
    

    Another way is to use the function IloStartEval with a stepFunction.

    Note: In your piece of code there is:

    IloBoolVarArray Theta(env, nb_Tache); // Theta[i]=1 if the operation i starts before date[i]
    for (int i = 0; i < nb_Tache; i++)
    { Theta[i] = IloBoolVar(env);}
    

    Actually the "for(...)" is not needed, the bool vars are already created while the IloBoolVarArray is created.

    I hope this helps,

    Chris.


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: IloIntervalSequenceVar and get the starting times

    Posted 01/13/18 04:25 AM

    Originally posted by: MatthGond


    Thank you very much, it is very helpful.
     

    If operations are optional (St[i].setOptional())
    Do you know how can I get if the operation i is used by the IloNoOverlap constraint?
    I would like adding constraints like: if operation i is performed so ... But I do not know how write "if operation i is performed ".

     

    Regards,

     

    Matth

     

     


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: IloIntervalSequenceVar and get the starting times

    Posted 01/15/18 07:07 AM

    Originally posted by: ChrisBr


    Hello Matthieu,

    You might have a look at IloPresenceOf.
    But a better way is to take advantage of the absence value.
    For example, in the piece of code above there is
              count += (IloStartOf(St[i], 0) >= my_data.date_op[i])
    This means that if St[i] is not present, its start's value is 0 and the condition for increment count is false.
    The default value for absence is 0, but you can set what ever you need.
    Such absence values are available for all interval expressions (IloStartOf, IloStarEval, IloSizeOf, and so on).

    I hope this helps,

    Chris.


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: IloIntervalSequenceVar and get the starting times

    Posted 01/20/18 05:29 AM

    Originally posted by: MatthGond


    THank you very much Chris,


    #CPOptimizer
    #DecisionOptimization