Originally posted by: SystemAdmin
And if you do not have the constraint stored in an array then use IloModel::Iterator:
bool feasible = true;
for (IloModel::Iterator it(B); it.ok(); ++it) {
IloExtractable e = *it;
if (e.isConstraint() && A.getValue(e.asConstraint()) < 0.5) {
feasible = false;
break;
}
}
if (feasible)
std::cout << "Solution satisfies all constraints in B" << std::endl;
else
std::cout << "Solution is not feasible for B" << std::endl;
The code-snippet above exploits the fact that you can give an arbitrary constraint as argument to IloCplex::getValue(). The function will return 1 if the current solution satisfies the constraint and 0 otherwise.
#CPLEXOptimizers#DecisionOptimization