Originally posted by: SystemAdmin
Hello,
There is no direct way to get this area under CumulFunction in CP Optimizer.
You could approximate this tank overflow by partitioning the schedule horizon into a set of contiguous time windows Aj=[Sj,Ej] and use an expression that measures the peak usage of the tank over the (fixed) time window Aj. For doing that you can introduce one interval variables aj for each time window Aj (with fixed start and end value) that contributes with a pulse of variable height hj and represents the "free" amount of tank assuming a max capacity Q (much bigger than the actual capacity C). The objective will be related with maximizing this free level. The peak tank level over Aj will be (Q-hj) and the max overflow over Aj will be max((Q-hj),C).
Pseudocode w[i]: interval variables
p: cum function (fixed) for input in tank
z: cum function for withdrawn volume
ui: cum function for unconstrained inventory
a[j]: interval variables for time-windows (fixed start S[j] and end E[j])
h[j]: integer expression, height of contribution of intervals a[j]
C: capacity of tank
Q: large integer
f: cumul function measuring the "free" reservoir level under Q
u: cum function for measuring peak usage
z = sum_i step(w[i])*s
ui = i0 + p - z
f = sum_j pulse(a[j],0,Q-C)
h[j] = heightAtStart(f,a[j]); // <=Q-C so C<=Q-hj
u = ui + f
u <= Q;
objective (upper bound on the actual objective): sum_j (Ej-Sj)*(Q-h[j])
If you would introduce one interval a[j] per time unit (Ej-Sj=1), then you would get the exact objective. But of course that would introduce a huge number of decision variables (the heights h[j]).
This being said, I'm not expecting CP Optimizer to behave very well on this type of problem. These types of problems are often handled in two steps: a planning steps that roughtly allocates the activities to some time-buckets in order to balance the tank usage (and here, minimize tank overflow) followed by a detailed scheduling step that tries to schedule the activities in (or as close as possible to) the time-bucket they were allocated to and this steps handles more detailed scheduling constraints and objectives on the tasks. The CPLEX algorithm is particularly well adapted for the first step, whereas CP Optimizer is more adapted to the detailed scheduling step.
Philippe
#CPOptimizer#DecisionOptimization