I would go on with the overlapLength idea and instead of sum I would use bigger interval than size 1
Original Message:
Sent: Thu March 26, 2026 05:34 PM
From: Francisco Yuraszeck
Subject: Performance issues modeling per-period consumption with interval variables in OPL
Thanks, @ALEX FLEISCHER, for your reply. Using overlapLength as you suggested has been effective; however, it presents similar performance issues to my original approach based on startOf and endOf.
On the other hand, your idea of defining Load_u1 as a cumulFunction is clear to me. However, it does not seem suitable for computing consumption costs over the planning horizon, so I would have to discard it as an alternative. Do you agree?
------------------------------
Francisco Yuraszeck
Yuraszeck
------------------------------
Original Message:
Sent: Thu March 26, 2026 12:56 PM
From: ALEX FLEISCHER
Subject: Performance issues modeling per-period consumption with interval variables in OPL
Hi,
how to fix your syntax error ?
using CP;int H = 96;int B_u1[i in 1..H] = i;int U = 10; float Cost[t in 1..H] = (t <= 28) ? 0.06: (t <= 72) ? 0.13: (t <= 88) ? 0.29: 0.14; dvar interval u1_wh_1 in 25..41 size 8; cumulFunction Load_u1= pulse(u1_wh_1, 50000)+sum(i in 1..H) pulse(i,i+1,B_u1[i]); subject to{Load_u1<=10000000;}
Using startOf and endOf is not very efficient and I recommend overlapLength
using CP;int H = 96;int B_u1[i in 1..H] = i;int U = 10; float Cost[t in 1..H] = (t <= 28) ? 0.06: (t <= 72) ? 0.13: (t <= 88) ? 0.29: 0.14; dvar interval u1_wh_1 in 25..41 size 8; dvar int Load_u1[t in 1..H]; dexpr float TC_u1 = sum(t in 1..H)(Cost[t] * Load_u1[t]); minimize TC_u1;subject to{ forall(t in 1..H) Load_u1[t] == B_u1[t] + U * (overlapLength(u1_wh_1,t,t+1)); }
works better
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Wed March 25, 2026 08:09 AM
From: Francisco Yuraszeck
Subject: Performance issues modeling per-period consumption with interval variables in OPL
Thanks @ALEX FLEISCHER for your reply. Unfortunately, I don't think I can use pulse-at least not the way I tried. I attempted to definecumulFunction Load_u1[t in 1..H] = B_u1[t] + pulse(u1_wh_1, 50000);, but OPL returned the error: 'Operator not available for int + cumulFunction'. Additionally, I need to access the value of Load_u1 in each period t to calculate the total cost TC_u1. Is there an alternative approach you would suggest?
------------------------------
Francisco Yuraszeck
Yuraszeck
Original Message:
Sent: Wed March 25, 2026 02:37 AM
From: ALEX FLEISCHER
Subject: Performance issues modeling per-period consumption with interval variables in OPL
Hi,
can you turn Load_u1 into a cumulFunction and replace " (t >= startOf(u1_wh_1) && t < endOf(u1_wh_1)) " by a pulse ?
regards
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]