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.