Originally posted by: morris50
Hi, all,
I am currently writing some code in C++ with CPLEX 12.5 to customize the branching behavior of CPLEX for MIPs, and I'm running into some problems with my NodeCallback function. Specifically, I'm maintaining some external data structures to help me determine what the next node to branch on should be; in this external data structure, I store the NodeId of every unexplored node in the search tree (this is stored as a part of a branching callback), and I have a function defined as NodeId getNextNode() that I call to determine what to branch on next. Then I use getNodeNumber(NodeId) to convert that into the index of the the node I should branch on next.
The problem I have is that sometimes the NodeId returned by getNextNode() no longer exists in the tree (I assume this occurs when a previously-generated node is pruned after the objective function is updated or a new cut is added). I haven't been able to figure out a way to detect when this happens, so I have code that does the following:
void MyNodeCallback::main()
{
int next = -1;
while (next < 0)
{
NodeId nid = getNextNode();
try { next = getNodeNumber(nid) }
catch (IloCplex::Exception& e)
{
if (e.getStatus() != 1200) throw e;
}
}
}
In the above code, 1200 is the status code that indicates I'm trying to select a node that isn't available for branching. However, this seems like a really inefficient way of doing things (in fact, on some test problems I've run from MIPLIB, the majority of the time spent in the solution procedure is spent in this function). So, my question is, "Is there a better way to do this?" Specifically, is there any way to update my data structure when previously-generated nodes are pruned? Alternately, is there an efficient way to tell during the node callback that a particular NodeId doesn't exist in the tree?
Thanks!
#CPLEXOptimizers#DecisionOptimization