Decision Optimization

 View Only
  • 1.  Two intensity intervals

    Posted Fri May 13, 2022 04:13 AM

    Hello,

    I currently have a stepwise function for the intensity of an interval. However, I needed to add another interval in the middle of that where the intensity is also 0.
    What i got currently is:

    stepFunction F = stepwise (i in 0..1000,j in 0..1) { 100*j -> (480 + i * 1440) + (540 * j);0 };

    I needed to add another interval [720i , 780i], anyone knows how i could do so?

    Thank you in advance.



    ------------------------------
    Vasco Ferreira
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Two intensity intervals

    Posted Fri May 13, 2022 06:34 AM
    Hi,

    you could write a complex formula for the stepFunction or use the trick from How to with OPL

    How to describe a stepwise function with breakpoints instead of jumps ?

         tuple breakpoint // y=f(x)
         {
          key float x;
          float y;
         }
         
         sorted { breakpoint } breakpoints={<0,0>,<1,1>,<2,4>};
          
         stepFunction f=stepwise(b in breakpoints:b!=first(breakpoints))
         { prev(breakpoints,b).y->b.x; last(breakpoints).y } ;
         
         
        assert forall(b in breakpoints) f(b.x)==b.y;​


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



  • 3.  RE: Two intensity intervals

    Posted Fri May 13, 2022 06:42 AM
    Hi Alex,
    Thank you for the answer.
    I don't think I can declare it with breakpoints, as it can't be a fixed interval. Basically those values represent the shift work time, and i am scheduling something for the upcoming days, so I need to check it for the next days aswell and I can't make that static ( unless I declared a variable with the breakpoints for the maximum upcoming days that I would schedule ).
    Do you have an idea of how I could write that complex formula? Otherwise I guess I'll write the breakpoints for like 180 days in advance.

    ------------------------------
    Vasco Ferreira
    ------------------------------



  • 4.  RE: Two intensity intervals

    Posted Fri May 13, 2022 09:37 AM
    Ok then let me rewrite

    stepFunction F1 = stepwise (i in 0..1000,j in 0..1) 
    { 100*j -> (480 + i * 1440) + (540 * j);0 };​


    into

    int rates[0..1]=[0,100];
    int steps[0..1]=[480,480+540];
    
    stepFunction F1bis= stepwise (i in 0..1000,j in 0..1) 
    { rates[j] ->  i * 1440 + steps[j];0 };


    which is the same but more generic and that will let you add some periodic values easily



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



  • 5.  RE: Two intensity intervals

    Posted Fri May 13, 2022 10:52 AM
    Thank you so much, it's working like a charm :)

    ------------------------------
    Vasco Ferreira
    ------------------------------



  • 6.  RE: Two intensity intervals

    Posted Fri May 13, 2022 11:43 AM
    So easier to help when the question is in OPL ...

    https://www.linkedin.com/pulse/optimization-aka-prescriptive-analytics-should-we-write-fleischer/

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