Originally posted by: SystemAdmin
It may not be possible to do this after all.
Both the C++ and Java API docs (for CPLEX 12.4) say that ifThen generates an instance of IloConstraint and that addLazyConstraint adds an instance of IloConstraint. I just tried doing essentially the same thing you did, but in Java. It threw an exception, but not the one you saw. The Java exception was
java.lang.ClassCastException: ilog.cplex.CpxIfThen cannot be cast to ilog.cplex.CpxRange
That suggests that, documentation notwithstanding, addLazyConstraint is limited to instances of IloRange, and if-then constraints do not convert to ranges. (That last part is totally plausible to me.)
If I'm right, then (a) the docs are a bit less than totally forthcoming and (b) the C++ exception is a bit more cryptic than one might hope.
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