I am working with a MILP formulation of a routing problem using Concert CPLEX 12.10. And I am implementing a greedy heuristic that uses the variables fractional values to attempt to construct an integer feasible solution. By what I have read in forums, the CPLEX class IloCplex::HeuristicCallbackI can be used for this purpose, the class documentation webpage confirms this:

In short, this callback allows you to attempt to construct an integer feasible solution at a node and pass it to the invoking instance of IloCplex to use as its new incumbent.

However, this type of callback is executed even when the branch and bound (B&B) node already contains an integral solution, i.e, when the B&B finds an integer feasible solution. And in my experiments, I want to count the number of times that the greedy heuristic succeeds, i.e., the number of times that the heuristic could find an integer feasible solution by using the fractional values. So, I've tried to use the following functions to solve this problem:

Also, I took a look at the IloCplex::NodeCallbackI class webpage to check if there is any function to do that, however, I couldn't find anything for my case. I would like to know if there is any way to determine whether the current B&B node is integer feasible.


1 Answer 1


Once you have gotten the values (in the node LP solution) for all variables, you can loop through the integer variables, computing the absolute difference between the value and the nearest integer. If any absolute difference exceeds the integrality tolerance (IloCplex::Param::MIP::Tolerances::Integrality), break out of the loop and treat the solution as not integer feasible. If you get through the loop with no violations, treat it as integer feasible.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.