Originally posted by: dlbur
Hello,
I'm attempting to use goals to implement a custom Branch-and-Cut algorithm for an MIP. I've used the ILOCPLEXGOAL3 macro to define a goal that solves a separation problem and adds global cuts. When I run my code, a cut is identified in the goal's execute function, but this same cut keeps occuring in all the subsequent iterations (producing an infinite loop). It seems that the cut isn't actually being incorporated into the B&C search. I verified this by exporting the formulation in the first line of the execute function. Here is my goal definition:
ILOCPLEXGOAL3(kPathsGoal, algorithm*, alg, IloIntVarArray, vars, ofstream&, summary_stream) {
alg->rmp_inst->rmp_cplex.exportModel(filename);
IloCplex::Goal goal = this;
bool foundCut = false;
int c;
// solve k_psp for each commodity
for (c = 0; c < alg->pars->ncommodities; c++) {
IloExpr cut(getEnv()); //alg->rmp_inst->env
if (alg->k_psp_inst->bc_iter(alg->opts, alg->pars, summary_stream, alg->rmp_inst, c, cut)) {
foundCut = true;
goal = AndGoal(GlobalCutGoal(cut <= 0), goal);
cerr << cut << " <= 0" << endl;
}
}
//If no cuts were found, start Benders feasibility cuts
if(!foundCut)
goal = AndGoal(BendersFeasGoal(getEnv(),alg,vars,summary_stream),goal);
return goal;
}
You'll notice that if no cuts are found in the for loop, the Goal object is aggregated with a BendersFeasGoal object, which is another goal I define to identify Benders feasibility cuts. (I've omitted the definition of this goal, since the program never reaches this condition). Also, here's how I call the solve method:
rmp_cplex.solve(kPathsGoal(env, alg,x,summary_stream))
The argument x is an IloIntVarArray consisting of the binary variables in the MIP.
So, can anyone think of a reason why the cuts aren't being added?
Thanks.
#CPLEXOptimizers#DecisionOptimization