Sune
Sune

Reputation: 239

Getting the node depth of current node

I have made a user cut callback that adds some cuts to the model I am working on. This works perfectly fine. I want to add these cuts, only to the top nodes of the search tree. The problem is, that I cannot figure out how to retrieve the depth of the current node. I have made a node callback that increments an integer variable every time it is called. This means that I can just do nothing in the cut callback when this integer exceeds some number. But then I do not now, if cplex has fx. only created nodes on left branches, meaning that no cuts are added to nodes on right branches or vise versa.
Looking in the documentation for node callbacks
http://pic.dhe.ibm.com/infocenter/cosinfoc/v12r4/index.jsp?opic=%2Filog.odms.cplex.help%2Frefpythoncplex%2Fhtml%2Fcplex.callbacks.NodeCallback-class.html
I see that there is a getDepth() method, that takes as argument a node identifier. But how to get this identifier, I simply cannot figure out.

Upvotes: 1

Views: 888

Answers (3)

Tiago Januario
Tiago Januario

Reputation: 21

CPLEX version 12.10.0.0 has the method

getCurrentNodeDepth()

You can call it inside your ILOUSERCUTCALLBACK method and it will give the current node depth as a long value.

You can check for more details here: https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.cplex.help/refdotnetcplex/html/M_ILOG_CPLEX_Cplex_MIPCallback_GetCurrentNodeDepth.htm

Upvotes: 2

Frops
Frops

Reputation: 1

I was trying the same thing in C++.

I was trying to work with the function getDepth(), that takes as argument a node identifier. But I couldn't figure out how to obtain the node identifier.

It is not clear from the documentation, but: When the node callback is invoked, the next node to be processed is the node at index 0.

Then, to know the depth of the current node, you need to use index 0 as the identifier.

Upvotes: 0

Gunes
Gunes

Reputation: 1

Using the callable library:

CPXgetcallbacknodeinfo(env, cbdata, wherefrom, 0, CPX_CALLBACK_INFO_NODE_DEPTH, &depth);

Sorry, I do not know much about the concert technology.

Upvotes: -1

Related Questions