Originally posted by: open_ball
Hi,
I am receiving the following error.
Exception in thread "main" ilog.cplex.CpxException: CPLEX Error 1006: Error during callback.
at ilog.cplex.CplexI.CALL(CplexI.java:4969)
at ilog.cplex.CplexI.setStatus(CplexI.java:6301)
at ilog.cplex.CplexI.access$500(CplexI.java:120)
at ilog.cplex.CplexI$SolveHandle.stop(CplexI.java:2941)
at ilog.cplex.CplexI.solve(CplexI.java:2964)
at ilog.cplex.IloCplex.solve(IloCplex.java:10254)
I intend to separate the sub problem into multiple problems. Just to explain what I am doing, I will take the TSP example provided by cplex as a reference. In Neighbor class, here are the changes I am making. Please note that I try my best to keep the example provided as small as possible.
private static final class Neighbor {
private final IloCplex[] cplex;
private final IloNumVar[] u;
private IloObjective[] obj;
public Neighbor(int size) throws IloException {
this.cplex = new IloCplex[size];
this.u = new IloNumVar[size];
for(int i=0; i< size ; i++) {
u[i] = cplex[i].numVar(0.0, Double.POSITIVE_INFINITY,
IloNumVarType.Float);
this.obj[i] = cplex[i].minimize();
cplex[i].setOut(null);
cplex[i].add(u[i]);
cplex[i].add(obj[i]);
}
//Create dual constraints
public IloRange[] separate(IloNumVar[] x, IloNumVar[] estObj, double[] xSol, double[] Z) throws IloException {
IloRange[] cut = new IloRange[size];
for(int i=0; i< size ; i++) {
cut[i] =null;
cplex[i].remove(obj[i]);
}
for (int i = 0; i < size; i++) {
IloLinearNumExpr objExpr = cplex[i].linearNumExpr();
//fill objExpr
obj[i] = cplex[i].minimize(objExpr);
cplex[i].add(obj[i]);
cplex[i].solve();
IloCplex.Status status = cplex[i].getStatus();
IloLinearNumExpr expr = cplex[i].linearNumExpr();
if (status == IloCplex.Status.Optimal) {
if (zMaster[i] > cplex[i].getObjValue() + 0.0001) {
// create the cut
cut[i] = (IloRange) cplex[i].le(estObj[i],expr);
}
}else {
// An unexpected status occurred -- report it but do nothing.
System.err.println("\n!!! Unexpected subproblem solution status: "
+ status + "\n");
}
These are the changes I made and the problem occurs in the callback function. The place where I receive the exact error is;
// teardown
if (context.inThreadDown()) {
neighbors[threadNo] = null;
return;
}
Right before the return keyword, I get the error. Can anyone help me out?
#CPLEXOptimizers#DecisionOptimization