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:
IloCplex::HeuristicCallbackI::getCplexStatus()
andIloCplex::HeuristicCallbackI::getStatus()
. Nevertheless, both functions return theOptimal
status at every fractional and integer B&C node.IloCplex::MIPInfoCallbackI::hasIncumbent()
, it returnedtrue
at every fractional and integer B&B node soon after the first integer solution was found.IloCplex::ControlCallbackI::getFeasibility(my_var)
, and it always returnsInfeasible
(indeed it returns 1, which stands for Infeasible).
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.