Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Sum on interval variables

    Posted 12/09/14 12:18 AM

    Originally posted by: noneless


    Hi all

    I have a problem with using cumulative function in MCRSP. The problem have 2 recourse with min and max level.I want to give a penalty when the tasks use between min and max,I mean sth like this:

    if(sum (m in Modes: m.dmdRenewable[r]>0) pulse(mode[m], m.dmdRenewable[r]) )>= minCapRenewableRsrc[r]

    penalty[r] = 1000;

    how can I declare it?!

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: Sum on interval variables

    Posted 12/09/14 11:33 AM

    Originally posted by: ChrisBr


    Hello Hadi,

    You can model such kind of expression by using an auxiliary dvar as following:

    cumulFunction level[r in resources] = sum (m in Modes: m.dmdRenewable[r]>0) pulse(mode[m], m.dmdRenewable[r]) )
    dvar int overflow[resources] in 0..1; 
    
    forall (r in resources) {
      level[r] <=  minCapRenewableRsrc[r]+overflow[r]*(maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]); 
      penalty[r] == 1000*overflow[r]; 
    }
    


    In this sample, you can also directly use 1000*overflow[r] in the cost expression.

    An other way to model such idea depending on other things you want to do is to use an optional interval variable (useMin) that will have to be absent if more than minCapRenewableRsrc[r] units or resource is used at some point:

    cumulFunction level[r in resources] = sum (m in Modes: m.dmdRenewable[r]>0) pulse(mode[m], m.dmdRenewable[r]) )
    
    dvar interval useMin[r in resources] optional in 0..horizon size horizon;
    cumulFunction useMinLevel[r in resources] = pulse(useMin[r], maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]);
    
    forall (r in resources) {  
      level[r] + useMinLevel[r] <= maxCapRenewableRsrc[r];
      penalty[r] == 1000*(1-presenceOf(useMin[r]));
    } 
    


    I hope this helps,

    Chris.
     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: Sum on interval variables

    Posted 12/11/14 10:24 AM

    Originally posted by: noneless


    Hello Chris

    Thanks for your answer,this codes catch the general overflow at all. How can I get each tasks's over flow?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: Sum on interval variables

    Posted 12/12/14 09:55 AM

    Originally posted by: Petr Vilím


    Hello Hadi,

    I do not understand what is "tasks overflow". When level of a cumul function overflows the minimum, it is typically not due to only single task. Could you be more specific please?

    Petr


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: Sum on interval variables

    Posted 12/11/14 12:17 PM

    Originally posted by: noneless


    Or how can I get each day over flow?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: Sum on interval variables

    Posted 12/12/14 09:53 AM

    Originally posted by: Petr Vilím


    Hello Hadi,

    you can use the second approach desribed by Chris but with multiple useMin interval variables - one variable for each day:

    level[r] + useMin[r][1] + useMin[r][2] + .. <= maxCapRenewableRsc[r];
    

    Where useMin[r][i] is optional interval variable that spans the day i (start and end are fixed but presence status is not - the variable is optional). To find a solution, CP Optimizer must decide for each useMin variable whether it will be "present" or "absent". If useMin variable is present for the given day then it cosumes the surpulous capacity and therefore level[r] cannot exceed the minimum level that day. If it is absent then level[r] can use up to maxCapRenewableRsc[r] that day. The expression presenceOf returns 1 if the interval is present and 0 if it is absent.

    I hope it helps,

    Petr


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: Sum on interval variables

    Posted 12/13/14 08:39 AM

    Originally posted by: noneless


    Hello Petr

    Thanks for your help.Let me explain the problem from the first.I want to get amount of over flow of each day.In my case minCapRenewableRsrc means if tasks consume over it,then a penalty is given(no penalty for 0 to minCapRenewableRsrc ), and of course we can't use over maxCapRenewableRsrc in a day. How can I get  amount of over flow of each day?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: Sum on interval variables

    Posted 12/16/14 09:04 AM

    Originally posted by: Petr Vilím


    Hello Hadi,

    I think I understand the problem now, but I'm not sure how the penalty is computed exactly. From your first question I understand that the penalty for given day is:

    • zero if maximum capacity used during that day is not above minCapRenewableRsc,
    • and 1000 otherwise.

    Therefore the exact capacity used during given day is not necessary to compute the penalty. All what is needed to is the fact whether it exceeds minCapRenewableRsc or not. If I return to what Chris suggested above (and I adjusted it for multiple days) then the penalty can be computed as:

    penalty[r][d] = (1-presenceOf(useMin[r][d]))*1000;
    

    Best regards,

    Petr


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: Sum on interval variables

    Posted 01/11/15 12:29 AM

    Originally posted by: noneless


    Thanx Petr

    That was very helpful


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 10.  Re: Sum on interval variables

    Posted 12/16/14 10:59 AM

    Originally posted by: ChrisBr


    Hello Hadi,

    In addition to Petr's answer, and in case you really need the amount of overflow each day one way to get it can be using a heightAtStart expression as follow:
     

    dvar interval useMin[r in resources][d in Days] in d..(d+1) size 1;
    cumulFunction useMinLevel[r in resources][d in Days] = pulse(useMin[r][d], 0, maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]);
    dexpr int overflow[r in resources][d in Days] = (maxCapRenewableRsrc[r]-minCapRenewableRsrc[r]) - heightAtStart(useMin[r][d], useMinLevel[r][d],0);
    

    Then you can set the value of penalty in a similar way than previously:
       penalty[r] == 1000 * (sum(d in Days) overflow[r][d] > 0);
    and you also have an information per day such that you can write:
       penalty[r][r] == 1000 * (overflow[r][d] > 0);

    Nevertheless, you need to know that one of the main interest of a scheduling CP Optimizer model (compared to a CPLEX MIP model for instance) is its ability to avoid defining one (or several) variables per time-unit.

    If in your problem, the time-unit is 1 day and you need one variable/expression per time-unit to evaluate the cost/penalty then you may loose some important advantages of CP Optimizer. In this case, you can think of using an approximated or relaxed version of the cost (for instance measuring the penalty on time windows larger than 1 day). Or you can use a CP Optimizer model to find feasible solutions that you can then inject in a MIP model using CPLEX warm start for instance.

    Of course, if your time granularity is smaller than 1 day and if the schedule horizon does not span a large number of days, then the proposed CP Optimizer model may be interesting.

    Regards,

    Chris.
     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 11.  Re: Sum on interval variables

    Posted 01/11/15 12:28 AM

    Originally posted by: noneless


    Thanx a lot

    That was very helpful:) .problem solved..


    #DecisionOptimization
    #OPLusingCPOptimizer