Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Problems mapping NodeId to array index in NodeCallback

    Posted 08/19/13 11:41 AM

    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


  • 2.  Re: Problems mapping NodeId to array index in NodeCallback

    Posted 08/19/13 12:26 PM

    Yes, you can do. You can register user data with any node in the search tree. That user data must be a subclass of IloCplex::MIPCallbackI::NodeData. When a node gets deleted then the destructor of this user data will be invoked. This way you can notice when a node is deleted (pruned).

    To set the user data either pass it as last argument when creating a new branch in the branch callback or use the setNodeData() function available in various callbacks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Problems mapping NodeId to array index in NodeCallback

    Posted 08/19/13 12:40 PM

    Originally posted by: morris50


    Ah, perfect, this is just what I'm looking for.  Thanks!


    #CPLEXOptimizers
    #DecisionOptimization