Originally posted by: Claus Brech
Thank you for your answer. Regarding your questions:
-
solve() returns true and setSolution() is only invoked once each time the heuristic callback is called.
-
My model contains only linear constraints
-
I will try it out with disabled presolve, thanks for your idea!
I could not think of a small example, but maybe the general structure of my code makes it a bit more clear. The algorithm I am developping is based on Benders Decomposition and therefore I have a master and and sub problem. Here is some code to illustrate what I want to do:
IloCplex master = new IloCplex; //Benders Masterproblem
IloCplex sub = new IloCplex(); //Benders Subproblem
buildMaster(); //Method to set objective function and constraints for master problem
buildSub(); // //Method to set objective function and constraints for sub problem
sub.setParam(IloCplex.BooleanParam.PreInd, false);
master.use(new BendersCallback(this)); //Lazy Constraint Callback to generate Benders Cuts at each incumbent during B&B
master.use(new HybridACO(this)); // UserCutCallback generating heuristic solutions<- The solutions generated here are the ones I want to inject
master.use(new Injector(this)); // Heuristic callback that should inject solutions in case better solutions have been found by the UserCutCallback
Unfortunately, even though the injected solution is valid, CPLEX just seem to ignore it. However, I found a workaround that is not optimal but good enough for me.
The workaround involves:
-
I divided the algorithm in two phases. In phase 1 I use HybridACO (my heuristic within a UserCutCallback) to find heuristic solutions and store them.
-
In phase 2, I create a new instance of my master problem, add all benders cuts of phase 1 and the best solution found during phase two. Therefore, I inject the solution at the root node. Apparently CPLEX is fine with that as it accepts the solution immediatly.
I have another question: Do you have experience in implementing Benders Decomposition in CPLEX? My experience is, that preprocessing of the sub problem needs to be turned off, since otherwise I get a lot of null pointer exceptions accessing variables and constraints that CPLEX removed. Is there a way to iterate over the preprocessed model?
Best regards
Claus Brech
#CPLEXOptimizers#DecisionOptimization