2

I'm trying to modify the way Cplex does its branch & bound during optimization, using it's C++ API. What I actually want to do :

-Set parameters before calling the solve() method. For example, using cplex.setParam(IloCplex::NodeSel, 0); tells Cplex to do a DFS in the branch & bound tree.

-Once cplex has found the first incumbent (ie an integer solution to the problem), I would like to set this parameter to one (cplex.setParam(IloCplex::NodeSel, 1);), which means Cplex should then do a best-bound search instead of a dfs in the tree.

I have tried to use the incumbent callback (which is executed whenever an integer solution is found) to set the parameter that way:

ILOINCUMBENTCALLBACK1(CustomIncumbentCallback, IloNumVarArray, vars){
  cplex.setParam(IloCplex::NodeSel, 1);
  ...
}

and in main(), before calling solve():

cplex.use(CustomIncumbentCallback(env));

However, it does not seem to work and the parameters keep their initial value, even when setParam is called in a callback (I have made sure this callback is executed when an integer solution is found). Note that the cplex variable is a global variable in my code.

My question is: Is it possible to modify the value of a parameter during the optimization (after solve() is called, but before the end of it), and if so, how ?

Yoctoboy
  • 322
  • 3
  • 13

1 Answers1

2

Your question is related to How to set UpperCutoff when using lazy constraint callback in CPLEX.

The answer is no. You cannot modify parameters during the optimization and setting a parameter from within a callback is not supported.

However, the advanced start switch parameter is set to 1 by default. The documentation states that:

For MIP models, setting 1 (one) will cause CPLEX to continue with a partially explored MIP tree if one is available. If tree exploration has not yet begun, setting 1 (one) specifies that CPLEX should use a loaded MIP start, if available. Setting 2 retains the current incumbent (if there is one), re-applies presolve, and starts a new search from a new root.

If you abort the solve once the first incumbent is found, change the parameter and then call solve again, it should continue where it left off as described above.

rkersh
  • 4,447
  • 2
  • 22
  • 31