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