Precomputing could work better:
using CP;
int H = 96;
int l=8;
int UP_u1_wh1[1..H] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
// compute all options
int potentialSum[st in 1..H]=sum(t in st..st+l-1:t<=H) UP_u1_wh1[t];
dvar interval u1_wh_1 in 25..41 size l;
dvar int c;
maximize c;
subject to
{
c==potentialSum[startOf(u1_wh_1)];
}
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
------------------------------
Original Message:
Sent: Fri March 20, 2026 08:13 AM
From: Francisco Yuraszeck
Subject: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)
I have tried to model this equivalently using cumulFunction, but without success. Could you please guide me on how to do it in terms of my example?
------------------------------
Francisco Yuraszeck
Yuraszeck
Original Message:
Sent: Fri March 20, 2026 03:23 AM
From: ALEX FLEISCHER
Subject: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)
Instead of summing like you did why don't you rely on cumul functions ?
regards
------------------------------
[Alex] [Fleischer]
[Data and AI Technical Sales]
[IBM]
Original Message:
Sent: Thu March 19, 2026 08:01 AM
From: Francisco Yuraszeck
Subject: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)
First, thank you for taking the time to review my query. I am working on a scheduling problem in OPL in which I need to determine the start times of a set of interval variables to maximize their total contribution over a planning horizon H. Below is an excerpt from my current work that illustrates the logic for the interval variable u1_wh_1.
using CP;
int H = 96;
int UP_u1_wh1[1..H] = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1];
dvar interval u1_wh_1 in 25..41 size 8;
dexpr int UP_contrib_wh1 = sum(t in 1..H)
((t >= startOf(u1_wh_1)) * (t < endOf(u1_wh_1)) * UP_u1_wh1[t]);
// This is the key part: I want UP_contrib_wh1 to account for the sum of the values of the vector UP_u1_wh1 over the periods during which the interval variable u1_wh_1 is active.
maximize UP_contrib_wh1;
The results obtained with CP Optimizer are consistent; however, as the number of interval variables increases, the solver struggles to find optimal solutions. This raises concerns about the formulation's efficiency and scalability, even though it appears correct. Could you suggest a more efficient alternative from a CP Optimizer perspective?
------------------------------
Francisco Yuraszeck
Yuraszeck
------------------------------