Originally posted by: fix
I am using CPLEX 12.7.0 under Visual Studio 2015 C++ with Goals to customize branching. When I run optimization to completion, all is fine. When I use a time limit to stop early with a feasible solution, I get a critical error at env.end();. The message says only a.exe has triggered a breakpoint.Same problem occurs with CPLEX 12.7.1. The goal definition is below. What's causing the problem?
ILOCPLEXGOAL5(MyBranchGoal, IloBoolVarArray, s, IloNumVarArray, x,
IloNumVarArray, y, const std::vector<int> &, order, const Data &, data) {
if (!isIntegerFeasible()) return AndGoal(BranchAsCplexGoal(getEnv()), this);
const IloNum eps = 1E-6;
const IloInt n = x.getSize(), m = s.getSize() / n;
IloNumArray sv(getEnv()), xv(getEnv()), yv(getEnv());
getValues(sv, s); getValues(xv, x); getValues(yv, y);
IloIntArray mach_of(getEnv(), n);
for (int j = 0; j < n; ++j) {
int i = 0;
while (sv[i * n + j] < eps) { ++i; rt_assert(i < m, ""); }
mach_of[j] = i;
}
IloCplex::Goal goal;
bool found = false;
for (auto it_k = 0; it_k < n; ++it_k) {
IloInt k = order[it_k];
IloInt pk = data.p(mach_of[k], k), rk = data.r(mach_of[k], k);
IloNum xk = xv[k], yk = yv[k];
for (auto it_j = 0; it_j < it_k; ++it_j) {
IloInt j = order[it_j];
IloInt pj = data.p(mach_of[j], j), rj = data.r(mach_of[j], j);
IloNum xj = xv[j], yj = yv[j];
if (xj - pj >= xk - eps) continue;
if (xk - pk >= xj - eps) continue;
if (mach_of[j] != mach_of[k]) {
if (yj - rj >= yk - eps) continue;
if (yk - rk >= yj - eps) continue;
}
IloCplex::Goal h_no_overlap = OrGoal(x[j] - x[k] >= pj, x[k] - x[j] >= pk);
if (mach_of[j] == mach_of[k])
goal = AndGoal(h_no_overlap, this);
else {
IloCplex::Goal v_no_overlap = OrGoal(y[j] - y[k] >= rj, y[k] - y[j] >= rk);
goal = AndGoal(OrGoal(h_no_overlap, v_no_overlap), this);
}
found = true;
break;
}
if (found) break;
}
mach_of.end();
yv.end(); xv.end(); sv.end();
return goal;
}
#CPLEXOptimizers#DecisionOptimization