Originally posted by: A.Florio
I have code that works on Cplex 12.7 but has stopped working on 12.8. It is a simple TSP solver with SECs added dynamically.
Within the UserCutCallback, when the first SEC violation is identified (when solving the relaxation at the root node of branch-and-bound), I create IloRange and, when setting up the cut with setLinearCoefs, the execution simply halts. No exception is raised. CPU becomes idle.
Architecture: macOS 10.13.4
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Code:
ILOUSERCUTCALLBACK2(TSPSolverMinCut, IloNumVarArray, xijs, Instance, instance) {
const double CUTTOL=1e-2;
IloNumArray valscplex(getEnv());
getValues(valscplex, xijs);
vector<vector<double>> vals(instance.numNodes()+1,
vector<double>(instance.numNodes()+1, 0));
for (int k=0, i=0; i<=instance.numNodes(); ++i)
for (int j=0; j<=instance.numNodes(); ++j, ++k)
if (i!=j)
vals[i][j]=valscplex[k];
valscplex.end();
// subtour elimination constraints (fractional) (global cuts)
{
MinCutSolver mincut(vals);
MinCutSolution sol=mincut.solve();
if (sol.value()<1-CUTTOL) {
IloRange sec(getEnv(), 1, IloInfinity);
IloNumVarArray vars(getEnv());
IloNumArray coeffs(getEnv());
for (int i=0; i<=instance.numNodes(); ++i) {
if (sol.minCut()[i]) { // i is in the cut
for (int j=0; j<=instance.numNodes(); ++j) {
if (i!=j && !sol.minCut()[j]) { // j is NOT in the cut
vars.add(xijs[i*(instance.numNodes()+1)+j]);
coeffs.add(1.0);
}
}
}
}
try {
sec.setLinearCoefs(vars, coeffs); // Execution is halting HERE
} catch (...) { // No exceptions raised
cout<<"exception caught!"<<endl;
exit(-1);
}
add(sec);
vars.end();
coeffs.end();
}
}
}
#CPLEXOptimizers#DecisionOptimization