Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
  • 1.  Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)

    Posted Thu March 19, 2026 08:02 AM
    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
    ------------------------------


  • 2.  RE: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)

    Posted Thu March 19, 2026 12:29 PM

    @ALEX FLEISCHER I would appreciate it if you could take a look at my query above. 😅



    ------------------------------
    Francisco Yuraszeck
    Yuraszeck
    ------------------------------



  • 3.  RE: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)

    Posted Fri March 20, 2026 03:24 AM

    Instead of summing like you did why don't you rely on cumul functions ?

    regards



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 4.  RE: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)

    Posted Fri March 20, 2026 08:14 AM

    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
    ------------------------------



  • 5.  RE: Modeling time-dependent rewards for interval variables in OPL (CP Optimizer)

    Posted Fri March 20, 2026 12:33 PM

    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]
    ------------------------------