I am new to cplex. In my ilp I have couple of if-else statement. I want to use cplex for solving my problem using java API. I don't know how to formulate if-else in cplex. example:
if x>0 then a=1
else if x=0 then a=0
I am new to cplex. In my ilp I have couple of if-else statement. I want to use cplex for solving my problem using java API. I don't know how to formulate if-else in cplex. example:
if x>0 then a=1
else if x=0 then a=0
I don't think that the Java API supports the if/then/else structure, however it is possible to do if/then
IloCplex cplex = new IloCplex();
IloNumVar x = cplex.numVar(-100, 100);
IloNumVar a = cplex.intVar(0, 1);
cplex.ifThen(cplex.ge(x, 100), cplex.eq(a, 1));
cplex.ifThen(cplex.eq(x, 0), cplex.eq(a, 0));