It works well. Thanks! I could not think of "Cumulative in another cumulative function". I learned another technique today.
Original Message:
Sent: Tue March 01, 2022 04:20 AM
From: Hugues Juille
Subject: CP - Cumulative Function: Varying Capacity
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
Original Message:
Sent: Mon February 28, 2022 02:54 PM
From: Andy Ham
Subject: CP - Cumulative Function: Varying Capacity
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