Originally posted by: pegonzalez
Dear Daniel,
I tried to follow your idea, but unfortunately I've failed.
First of all I tried to create a global variable to store the current NodeId. Following that thought, verifing if Cur_Node == getNodeId() would tell me whether or not I am at the same node. The first problem I encountered is how to define my Cur_Node, since I can neither create it as NodeID type, nor cast getNodeId() to int.
Supposing that problem can be solved, I went with something like that:
int Cur_Node = 0; //Global
int cuts_per_node = 0; //Global
ILOUSERCUTCALLBACK2(CortesClique, ProblemInstance& , p, IloNumVarMatrix, y)
{
inicio:
if(Cur_Node == getNodeNumber(getNodeId()) ){
if(cuts_per_node<11){
graph_t* G = graph_new(p.NbNode_Proib);
for (unsigned int i = 0; i < p.NPOINTS; ++i)
{
for(unsigned int r = 0; r < p.point[i].NumRadii ; ++r){
G->weights[p.mapIRToNode[make_pair(i,r)]] = getValue(y[i][r]);
}
}
for(int i = 0; i<p.NbNode_Proib-1; ++i){
for(int j = i+1; j<p.NbNode_Proib; ++j){
if(p.DIST[p.mapNodeToIR[i].first][p.mapNodeToIR[j].first] < (p.RADII[p.mapNodeToIR[i].second] + p.RADII[p.mapNodeToIR[j].second] - p.ALPHA[p.mapNodeToIR[i].second][p.mapNodeToIR[j].second])){
GRAPH_ADD_EDGE(G,i,j);
}
}
}
MaxWeightCliqueHeur CU(G);
vector<int> Sol = CU.FindMaxWeightClique();
double clique = CU.GetWeight(Sol);
IloExpr Clique(getEnv());
if(clique >= 1){
for(vector<int>::iterator it=Sol.begin(); it != Sol.end(); ++it){
Clique+=y[p.mapNodeToIR[*it].first][p.mapNodeToIR[*it].second];
}
add(Clique<=1);
cuts_per_node++;
}
}
}else{
Cur_Node = getNodeNumber(getNodeId()) ;
cuts_per_node = 0;
goto inicio;
}
}
Can you help me make that work ?
Best regards.
#CPLEXOptimizers#DecisionOptimization