Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

cumulFunction - Dynamic Capacity

  • 1.  cumulFunction - Dynamic Capacity

    Posted Tue September 12, 2017 12:50 PM

    Originally posted by: AndyHam


    Dear IBM,
    I am trying to model a dynamic capacity of resource using CP.
    I guess this topic might be already discussed in this forum, but I could not find it.

    Let me borrow the following code from Batch Scheduling example for illustration.
    cumulFunction ovenUsage[o in ovens] = sum(t in allTasks) pulse(taskOvenAlts[t][o], 1);

    forall(o in ovens)
        ovenUsage[o] <= ovenCapacity[o];

    Suppose oven[1] has a capacity of 5 between 7:00am and 9:59am, 4 between 10:00am and 11:59am, etc.
    Then, how can we incorporate this kind of dynamic capacity of ovens?
    I also tried to handle this constraint by adding MIP equations, but it has not been successful.

    Best Regards,
    Andy


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: cumulFunction - Dynamic Capacity

    Posted Wed September 13, 2017 04:05 AM

    Hi,

    let me give you a small example out of sched_cumul example:

    In the original example, you get workerUsage

     

    Now suppose some workers are not available for some time:

    You would write

    tuple extraWorker
    {
    int s;
    int e;
    int quantity;
    }

    {extraWorker} extraWorkers={<0,100,1>,<200,300,2>};

    and later change

    workersUsage <= NbWorkers;

    into

    workersUsage +sum(ew in extraWorkers) pulse(ew.s,ew.e,ew.quantity)<= NbWorkers;

    and then the display for workerUsage would be

     

     

    regards

     

    NB:

    The new .mod is

    using CP;

    int NbWorkers = ...;

    tuple extraWorker
    {
    int s;
    int e;
    int quantity;
    }

    {extraWorker} extraWorkers={<0,100,1>,<200,300,2>};


    int NbHouses  = ...;
    range Houses  = 1..NbHouses;

    {string} TaskNames   = ...;

    int Duration [t in TaskNames] = ...;

    tuple Precedence {
       string pre;
       string post;
    };

    {Precedence} Precedences = ...;

    int ReleaseDate[Houses] = ...;

    dvar interval itvs[h in Houses][t in TaskNames] in ReleaseDate[h]..(maxint div 2)-1 size Duration[t];

    cumulFunction workersUsage =
       sum(h in Houses, t in TaskNames) pulse(itvs[h][t],1);

    cumulFunction cash =
      sum (p in 0..5) step(60*p, 30000)
      - sum(h in Houses, t in TaskNames) stepAtStart(itvs[h][t], 200*Duration[t]);

    execute {
        cp.param.FailLimit = 10000;
    }

    minimize max(h in Houses) endOf(itvs[h]["moving"]);

    subject to {
      forall(h in Houses)
        forall(p in Precedences)
          endBeforeStart(itvs[h][p.pre], itvs[h][p.post]);

      workersUsage +sum(ew in extraWorkers) pulse(ew.s,ew.e,ew.quantity)<= NbWorkers;

      cash >= 0;
     
     
    }


    #DecisionOptimization


  • 3.  Re: cumulFunction - Dynamic Capacity

    Posted Wed September 13, 2017 09:59 AM

    Originally posted by: AndyHam


    Thanks you so much all your help.
    I combined two suggestions.
    It works like a magic ^^
    I am using this feature to model a dynamic capacity of engineer that changes at every shift.
    Thanks again!


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: cumulFunction - Dynamic Capacity

    Posted Wed September 13, 2017 05:50 AM

    Originally posted by: PhilippeLaborie


    In addition to Alex's answer, you can use the alwaysIn constraint to restrict the availability of the resources over some fixed (or even variable) intervals of time.

    Suppose oven[1] has a capacity of 5 between 7:00am and 9:59am, 4 between 10:00am and 11:59am, etc.

    I would model it as a set of constraints (of course, replace the date values by the corresponding integers):
    alwaysIn(ovenUsage[o], 7:00am, 10:00am, 0, 5);
    alwaysIn(ovenUsage[o], 10:00am, 12:00am, 0, 4);

    The syntax is:
    alwaysIn(cumul_function, start, end, value_min, value_max);

    And there is even a more genral version where [start,end) is a variable interval:
    alwaysIn(cumul_function, interval_var, value_min, value_max);


    #DecisionOptimization
    #OPLusingCPOptimizer