Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  How can i implement this constraint

    Posted 03/21/16 03:12 AM

    Originally posted by: valkiri


    Hello.

     If i have two variables  IloIntVar var(env,0,10);  IloIntVar  b(env,0,1);

    I want to implement this constraint :  if var is upper than 5 variable b must take 1 and must take 0 else.

    Thanks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How can i implement this constraint

    Posted 03/21/16 04:00 PM

    You cannot do exactly what you want. Your choices are: to say var > 5 => b = 1, var < 5 => b = 0 and var == 5 is ambiguous (b could take either value); or to say var >= 5 + epsilon => b = 1, var <= 5 => b = 0 and 5 < var < 5 + epsilon is forbidden (for some small but not too small choice of epsilon); or do the second version but with the "forbidden zone" 5 - epsilon < var < 5.

    Try searching for "indicator constraint" in the CPLEX documentation.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How can i implement this constraint

    Posted 03/22/16 02:15 AM

    Paul, note that these are IloIntVar instances, so "upper than 5" is actually >=6. So I think this can be modeled as

    model.add(IloIfThen(env, var >= 6, b == 1));
    model.add(IloIfThen(env, var <= 5, b == 0));


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: How can i implement this constraint

    Posted 03/22/16 11:09 AM

    Oops, you are of course correct. I thought 'var' was IloNumVar. Should have read the question more closely.


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: How can i implement this constraint

    Posted 03/22/16 01:33 PM

    Originally posted by: valkiri


    Thanks  DanielJunglas 

    Thanks PaulRubin

    Its work perfectly.

    Valkiri.


    #CPLEXOptimizers
    #DecisionOptimization