Decision Optimization

Decision Optimization

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

 View Only
  • 1.  CP - Cumulative Function: Varying Capacity

    Posted Mon February 28, 2022 02:55 PM

    Hi IBM, Thanks for the amazing CP modeling capability and solving speed! Suppose we have a resource that can handle multiple jobs simultaneously, but the capacity of the resource varies based on the time. How can we capture this?

    Time     Capacity
    (0, 5)     1
    (5, 15)   2
    (15, 20) 1
    (20, 25) 1
    (25, +)   2

    using CP;
    range jobs=1..10;
    dvar interval iJob[j in jobs] size 5;
    cumulFunction cumResource = sum(j in jobs) pulse(iJob[j],1);
    minimize max(j in jobs) endOf(iJob[j]);
    constraints {
    cumResource<=2;
    //(0, 5) 1
    //(5, 15) 2
    //(15, 20) 1
    //(20, 25) 1
    //(25, +) 2
    }



    ------------------------------
    Andy Ham
    ------------------------------

    #DecisionOptimization


  • 2.  RE: CP - Cumulative Function: Varying Capacity
    Best Answer

    Posted Tue March 01, 2022 04:21 AM

    Hi Andy,
    One way to model this is to initialize the profile of the capacity of the resource with a collection of fixed intervals.
    Then, jobs will consume capacity during their execution and one constrains available capacity to be positive.
    Here is how this could be done, based on your example:

    using CP;

    range jobs=1..10;
    dvar interval iJob[j in jobs] size 5;

    tuple Segment {
    int start;
    int end;
    int capacity;
    }
    {Segment} capacityProfile = {<0, 5, 1>, <5, 15, 2>, <15, 20, 1>, <20, 25, 1>, <25, 999, 2>};

    cumulFunction resourceCapacity = sum(<s, e, i> in capacityProfile) pulse(s, e, i);
    cumulFunction cumResource = resourceCapacity - sum(j in jobs) pulse(iJob[j],1);

    minimize max(j in jobs) endOf(iJob[j]);

    constraints {
    cumResource >= 0;
    //(0, 5) 1
    //(5, 15) 2
    //(15, 20) 1
    //(20, 25) 1
    //(25, +) 2
    }

    Best regards,
    Hugues



    ------------------------------
    Hugues Juille
    ------------------------------



  • 3.  RE: CP - Cumulative Function: Varying Capacity

    Posted Tue March 01, 2022 07:54 AM

    It works well. Thanks! I could not think of "Cumulative in another cumulative function". I learned another technique today.



    ------------------------------
    Andy Ham
    ------------------------------