Originally posted by: istenc
Hello,
I want to inherit data from parents to children. To this end, I use 'makeBranch' and 'NodeData'. At each node, I call makeBranch twice to generate two children as below. Since I don't want to interfere with the branching scheme of Cplex, I use 'makeBranch(IloInt,NodeData*)' constructor. Note that this code is only for test purpose and does not make much sense, accordingly. When I use the callback named as 'MyBranch', I get error on the first call of the second 'makeBranch' command in the callback.
I couldn't figure out why it gives error and appreciate if you can help me.
Best, İstenç
IloInt current_branch_id = 0;
class myNodeData : public IloCplex::MIPCallbackI::NodeData {
public:
IloInt Id;
myNodeData(IloInt i) : Id(i){};
};
ILOBRANCHCALLBACK0(MyBranch) {
myNodeData * a_new_node_data;
if (getNodeId()._id == 0) {
a_new_node_data = new myNodeData(current_branch_id);
this->setNodeData(a_new_node_data);
}
else
{
a_new_node_data = dynamic_cast <myNodeData *> (getNodeData());
}
if (getBranchType() != BranchOnVariable)
return;
current_branch_id++;
myNodeData * myNodeData01 = new myNodeData(current_branch_id);
current_branch_id++;
myNodeData * myNodeData02 = new myNodeData(current_branch_id);
makeBranch(myNodeData01->Id, myNodeData01);
makeBranch(myNodeData02->Id, myNodeData02); //ERROR OCCURS UPON THE FIRST CALL OF THİS MAKEBRANCH
}
#CPLEXOptimizers#DecisionOptimization