Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Conditionally define a decision expression (dexpr)

Archive User

Archive UserWed April 24, 2019 04:56 PM

  • 1.  Conditionally define a decision expression (dexpr)

    Posted Wed April 24, 2019 04:56 PM

    Originally posted by: Lav4n


    Hi all,

     

    hope you can help me with this:

     

    I have a decision expression, using the prev function on an index "period". In order to avoid an error I would like to constrain the calculation for all periods except the first one, where all values should be 0. So

     

    dexpr float CostCalc [t in period] = CostPrameter[t] * (varX[t] - varX[prev(period,t)])

     

    How could i prevend the error on t = 1 and condition it something like forall(t in period: t != 1)?

     

    Thanks for your help!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Conditionally define a decision expression (dexpr)

    Posted Wed April 24, 2019 05:29 PM

    Hi,

    you could use the ternary operator.

    Let me share a tiny example:

    range period=1..5;
    dvar int x[period];;

    dexpr float CostCalc [t in period] = (t==1)?0:sum(i in 1..t-1)x[i];

    regards

    https://www.linkedin.com/pulse/what-optimization-how-can-help-you-do-more-less-zoo-buses-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Conditionally define a decision expression (dexpr)

    Posted Thu April 25, 2019 05:56 PM

    Originally posted by: Lav4n


    Hi Alex,

     

    thanks for your quick and kind answer!

    That's exactly what I was searching for.

     

    Really appreciate your support in this community through all the years!

     

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer