Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

makeBranch, NodeData and getNodeData

  • 1.  makeBranch, NodeData and getNodeData

    Posted Thu October 23, 2008 07:30 PM

    Originally posted by: SystemAdmin


    [claud10 said:]

    Hi, I'm trying to realize how to include NodeData information during the branch callback for use in the cut callback. Mainly, the C++ structure cplex uses I do not get it 100% (My background is mainly in maths more than CS). For simplifying the reading, supose that I have already implemented a subclass of NodeData called MyNodeData. I have a constructor that receives one extra parameter (vector<IloRange> V), as well as two functions, get() (that returns an object of the class IloRange) and empty() (that is true if the vector V is empty).

    In the BranchCallback I do

    NodeData* MND1 = new (getEnv()) MyNodeData(IR1);
    NodeData* MND2 = new (getEnv()) MyNodeData(IR2);
    makeBranch(z[i] <= 0, objval1, MND1);<br />makeBranch(z[i] >= 1, objval2, MND2);

    while in the cut callback I have tried several combinations but I do not get the good one. The one I wrote now is

    NodeData* ND = getNodeData();
    if(ND != 0)
    {
    MyNodeData* MND = (MyNodeData*) ND;
    while(!(*MND).empty())
    {
    IloRange rng((*MND).get());
    add(rng);
    }
    ND = 0;
    return;
    }


    The error I get is
    Exception: CPLEX Error  1200: Index is outside range of valid values
    And this error appears just after calling the function getNodeData().

    Thanks for your help,
    Claudio
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: makeBranch, NodeData and getNodeData

    Posted Sat October 25, 2008 07:52 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    [quote author=claud10 link=topic=632.msg1922#msg1922 date=1224772201]
    NodeData* MND1 = new (getEnv()) MyNodeData(IR1);
    NodeData* MND2 = new (getEnv()) MyNodeData(IR2);
    makeBranch(z[i] <= 0, objval1, MND1);<br />makeBranch(z[i] >= 1, objval2, MND2);


    I haven't written C++ in years (and just recently got over the nightmares), so I could be way off, but I think perhaps this should be

    NodeData MND1 = new (getEnv()) MyNodeData(IR1);
    NodeData MND2 = new (getEnv()) MyNodeData(IR2);
    makeBranch(z[i] <= 0, objval1, &MND1);<br />makeBranch(z[i] >= 1, objval2, &MND2);

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization