Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  constraint If-else in OPL

    Posted 10/06/18 07:09 AM

    Originally posted by: MachexC


    Hi Alex,

    I have a constraint as following, which don't be a constraint Big M.

    B(i) = a*X(i) + b*Y(i) -c*F (i);

    I want to convert to a logic constraint in OPL.

    If F(i) = 0 then B(i) = a*X(i) + b*Y(i);

    If F(i) = 1 then B(i) = a*X(i) + b*Y(i) - c;

     

    Thank you for your help.

    Mac

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: constraint If-else in OPL

    Posted 10/06/18 04:41 PM


  • 3.  Re: constraint If-else in OPL

    Posted 10/06/18 09:30 PM

    Originally posted by: MachexC


    Hi Alex,

    For F(i) =1, we have B[i] == a*X[i] + b*Y[i] - c * (F[i]==1);

    In this case, F(i) = 0, how is?

     

    Thank you,

    Mac


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: constraint If-else in OPL

    Posted 10/07/18 04:17 AM

    Hi,

    if you write

    B[i] == a*X[i] + b*Y[i] - c * (F[i]==1);

    then when you have F[i] equals 0, you get

    B[i] == a*X[i] + b*Y[i]

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: constraint If-else in OPL

    Posted 10/07/18 05:34 AM

    Originally posted by: MachexC


    Hi Alex,

    With such way, it is the same, we write as follow. Right?

    forall i = 1..n {

    F[i] = 1 => B[i] == a*X[i] + b*Y[i] - c ||

    F[i] = 0 => B[i] == a*X[i] + b*Y[i] ;

    }

     

    Thank you,

    Bests and regards,

    Mac


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: constraint If-else in OPL

    Posted 10/08/18 03:43 AM

    Hi,

    you may write

    If F(i) = 0 then B(i) = a*X(i) + b*Y(i);

    If F(i) = 1 then B(i) = a*X(i) + b*Y(i) - c;

    as

    (F[i]==0) => (B[i]==a*X[i] + b*Y[i] );

    (F[i]==1) => (B[i]==a*X[i] + b*Y[i] - c);

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: constraint If-else in OPL

    Posted 10/09/18 01:50 AM

    Originally posted by: MachexC


    Hi Alex,

    Thank you for your suggestion.

    When I use case 1, then model run faster but the results don't see any F[i] = 0. This is model reads only values F[v] =1. Meanwhile, the case 2 is run with the very slow runtime, the engine log can not see. Could you explain for me know?

    Case 1:

    forall i = 1..n {

    F[i] = 1 => B[i] == a*X[i] + b*Y[i] - c;

    }

    Case 2:

    forall i = 1..n {

    (F[i]==1) => (B[i]==a*X[i] + b*Y[i] - c);

    F[i]==0) => (B[i]==a*X[i] + b*Y[i] );

    }

    Bests,

    Mac

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: constraint If-else in OPL

    Posted 10/09/18 02:23 AM

    Hi,

    that is why I would write

    B[i] == a*X[i] + b*Y[i] - c * (F[i]==1);

    Your case 1 and 2 are not equivalent with each other. Case 2 is the same as what I suggest

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer