Originally posted by: SystemAdmin
[aroso said:]
Hello again,
I'm still trying to use the SolutionGoal method to inject an heuristic solution derived from an integer feasible one. However, the injected solution never gets admited as a new incumbent. Here's what I'm trying to do:
IloIntVarMap TVar;
IloIntVarMap TVar2;
IloIntVar TVarElement;
IloIntVar TVarElement2;
ILOCPLEXGOAL1(Polish, IloNum, eps) {
IloCplex::Goal goal = this;
if (isIntegerFeasible() == IloFalse) return AndGoal(BranchAsCplexGoal(getEnv()), goal);
else {
TVar = opl.getElement("T").asIntVarMap();
//same method is repeated for all decision variables, for both the main and sub mips
...
//new solution is built by solving a sub mip, this seems fine
cplex2.solve();
...
IloNumVarArray SolVars(env);
IloNumArray SolVals(env);
for (IloInt t=0;t<T;t++) {<br /> for (IloInt i=0;i<N;i++) {<br /> for (IloInt j=0;j<N;j++) {<br /> TVarElement = TVar.getSub(i+1).getSub(j+1).get(t+1);
TVarElement2 = TVar2.getSub(i+1).getSub(j+1).get(t+1);
SolVars.add(TVarElement);
SolVals.add((IloInt) round(cplex2.getValue(TVarElement2))); //same method is used for all decision vars
}
}
}
return AndGoal(SolutionGoal(SolVars,SolVals),this);
}
}
SolVars and SolVals both seem to have the correct variables and values, and the number of elements in each array match with the number of decision variables of the model. I'm using C++ and CPLEX 10.110.
Any idea on what might be wrong? All suggestions will be appreciated!
Thanks again,
Antonio
#CPLEXOptimizers#DecisionOptimization