Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

How to use IFTHEN constraints with STRICTLY positive variable

  • 1.  How to use IFTHEN constraints with STRICTLY positive variable

    Posted Wed July 02, 2014 12:23 PM

    Originally posted by: Nodame


    While solving an optimization problem, I am calling cplex solver from C#. I would like to add some IFTHEN constraints to describe some sort of Indicator variable.

    My two variables are x  ( x  takes non negative double values) and y (y is binary: 0 or 1) . I would like a constraint that does the following:

    if x > 0 then y = 1 and

    if x = 0 then y = 0.

     

    I have tried describing the positiveness of x, but I cannot seem to find a 'STRICTLY' ' Greater Method (the only one I could find was the cplex.Ge()). 

    To get around this problem, I tried using two conditions ">=" and "Not="  (Ge and Neq) for expressing ">"  . However  cplex.Neq(x, 0) does not seem to work (gives me an error). Any suggestion to solve this problem would be very appreciated.

    So far, this is what I have:

    IConstraint positiveX = (cplex.Ge(x, 0)) && (cplex.Neq(x, 0));//the cplex.Neq gives an error
    IConstraint oneY = cplex.Eq(y,1) ;
    IConstraint zeroX = cplex.Eq(x, 0);
    IConstraint zeroY = cplex.Eq(y, 0);
    
    cplex.Add(cplex.IfThen(positiveX, oneY));
    cplex.Add(cplex.IfThen(zeroX, zeroY));
    

     

     

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: How to use IFTHEN constraints with STRICTLY positive variable

    Posted Wed July 02, 2014 04:41 PM

     

    It's not possible. Linear and mixed integer linear programs require closed feasible regions. Strict inequalities less to feasible regions that are not closed. The best you can do is replace x>0 with x>= epsilon for some small positive epsilon, and hope that the optimal solution does not have 0<x<epsilon. This is a FAQ. If you search the forum, you'll find answers to it.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: How to use IFTHEN constraints with STRICTLY positive variable

    Posted Wed July 02, 2014 06:48 PM

    Originally posted by: Nodame


    Thanks. That works for me.


    #CPLEXOptimizers
    #DecisionOptimization