2
$\begingroup$

I have a decision variable R, indexed by n over N, where R[n] is equal to some integer value. I want a constraint that, for a specific window size, e.g. 5, gives a maximum to the summed values inside that window. I tried playing around with model.AddCumulative, but haven't got it to work.

For instance, the sum of values over R[0] to R[4] can be at maximum 10, same for R[1] to R[5] etc.

R = {}
for n in range(N):
    R[n] = model.NewIntVar(0, 1000, f'R{n}')
    R[n] == qty 

Any pointers on how to approach this? Using CP solver inside Python.

$\endgroup$

1 Answer 1

2
$\begingroup$

You can use fixed interval + demand to reduce the capacity of the cumulative.

See This example

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.