| Overview | Group | Index | Concepts | 
This is an advanced routine. Advanced routines typically demand a thorough understanding of the algorithms used by ILOG CPLEX. Thus they incur a higher risk of incorrect behavior in your application, behavior that can be difficult to debug. Therefore, ILOG encourages you to consider carefully whether you can accomplish the same task by means of other Callable Library routines instead.
The routine CPXsetnodecallbackfunc sets and modifies the
 user-written callback to be called during MIP optimization after ILOG CPLEX
 has selected a node to explore, but before this exploration is carried out.
 The callback routine can change the node selected by ILOG CPLEX to a node
 selected by the user.
Example
status = CPXgetnodecallbackfunc(env, mynodefunc, mydata);
See also the example admipex1.c 
 in the standard distribution.
Parameters
env
A pointer to the CPLEX environment, 
 as returned by CPXopenCPLEX.
nodecallback
A pointer to the current user-written node callback. If no callback has been set, the pointer evaluates to NULL.
cbhandle
A pointer to user private data. This pointer is passed to the user-written node callback.
Callback description
 int callback (CPXCENVptr env,
               void       *cbdata,
               int        wherefrom,
               void       *cbhandle,
               int        *nodeindex_p,
               int        *useraction_p);
 ILOG CPLEX calls the node callback after selecting the next node to explore. The user can choose another node by setting the argument values of the callback.
Callback return value
The callback returns zero if successful and nonzero if an error occurs.
Callback arguments
env
A pointer to the CPLEX environment, as returned by
 CPXopenCPLEX.
cbdata
A pointer passed from the optimization routine to the user-written callback that identifies the problem being optimized. The only purpose of this pointer is to pass it to the callback information routines.
wherefrom
An integer value indicating where in the optimization this function was
 called. It has the value CPX_CALLBACK_MIP_NODE.
cbhandle
A pointer to user private data.
nodeindex_p
A pointer to an integer that indicates the node number of the
 user-selected node. The node selected by ILOG CPLEX is node number 0 (zero).
 Other nodes are numbered relative to their position in the tree, and this
 number changes with each tree operation. The unchanging identifier for a
 node is its sequence number. To access the sequence number of a node, use
 the ILOG CPLEX Callable Library routine 
 CPXgetcallbacknodeinfo. 
 An error results if a user
 attempts to select a node that has been moved to a node file. (See the 
 ILOG CPLEX User's Manual for more information about node files.)
useraction_p
A pointer to an integer indicating the action to be taken on completion of the user callback. The table summarizes the possible actions.
| Value | Symbolic Constant | Action | 
|---|---|---|
0 | CPX_CALLBACK_DEFAULT | Use ILOG CPLEX-selected node | 
1 | CPX_CALLBACK_FAIL | Exit optimization | 
2 | CPX_CALLBACK_SET | Use user-selected node as defined in returned values |