Originally posted by: SystemAdmin
I'm probably missing something.
The expression you wrote:
sum(t in timeslots) sum(i in 1..n) pulse(s[i], qs[i]) - sum(j in 1..m) pulse(r[j], qr[j])
can be rewritten:
(sum(t in timeslots) sum(i in 1..n) pulse(s[i], qs[i])) - (sum(t in timeslots) sum(j in 1..m) pulse(r[j], qr[j]))
If the time-unit of the model is the same as the timeslots, we have:
(sum(t in timeslots) sum(i in 1..n) pulse(s[i], qs[i])) = sum(i in 1..n) lengthOf(s[i])*qs[i], and (sum(t in timeslots) sum(j in 1..m) pulse(r[j], qr[j])) = sum(j in 1..m) lengthOf(r[j])*qr[j]
So it is the expression I mentioned:
sum(i in 1..n) lengthOf(s[i])*qs[i] - sum(j in 1..m) lengthOf(r[j])*qr[j]
If you only want to compute the sum over some fixed intervals [tmin,tmax), you can use the overlapLength(x,tmin,tmax) expression that computes the length of the overlap between an interval variable x and a fixed interval:
sum(i in 1..n) overlapLength(s[i],tmin,tmax)*qs[i] - sum(j in 1..m) overlapLength(r[j],tmin,tmax)*qr[j]
Of course, as intervals s[i] are fixed in the above expressions, lengthOf(s[i]) and overlapLength(s[i],tmin,tmax) can be simplified to some constant.
Philippe
#CPOptimizer#DecisionOptimization