Are your constraints instances of IloRange or are they more complicated things? If they are not instances of IloRange then you have no choice but to parse the stringified version of the constraint :-( If they are instances of IloRange then you can cast them to IloRange and use IloRange's functions to iterate over the constraint:
IloConstraint c = ...;
IloRangeI *impl = dynamic_cast<IloRangeI *>(c.getImpl());
if ( !impl )
// Not an IloRange instance, throw an exception, etc.
else {
IloRange r(impl);
IloExpr e(r.getExpr());
for (IloExpr::LinearIterator it = e.getLinearIterator(); it.ok(); ++it) {
...
}
}
A word of caution here: some C++ compilers require extra compiler flags so that dynamic_cast<> works correctly.
Also note that in more recent releases (12.4 and newer, I think) the API of IloRange has been improved so that you can now call IloRange::getLinearIterator() directly without taking the detour via the IloExpr instance.
#CPLEXOptimizers#DecisionOptimization