Originally posted by: SystemAdmin
>
> Hi there,
>
> In Java, how would I do the following:
>
> IloIntVar b(env, 0, 1);
> model.add(b == (x >= y));
>
> For b == (x >= y), would I have to use 2 IfThen constraints?
>
I think so. I would go with:
IloCplex cplex = new IloCplex();
IloNumVar b = cplex.boolVar();
cplex.add(cplex.ifThen(cplex.eq(b, 1), cplex.ge(x, y)));
cplex.add(cplex.ifThen(cplex.ge(x, y), cplex.eq(b, 1)));
Personally, though, I don't use ifThen constraints; I make up my own "big M" constraints. CPLEX turns ifThens into "big M" type constraints internally, and I usually trust my ability to find a tight model-specific value of M more than I trust CPLEX's internal heuristics for selecting M. (No disrespect to CPLEX here: Ed Klotz, in a presentation at INFORMS, pretty much advised the audience to do this when we have any sort of intuition about the size of M.)
/Paul
Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
#CPLEXOptimizers#DecisionOptimization