As we are concerned primarily with illustrating local search in this example, we do not spend much effort in finding a good first solution. It should be noted however that in many cases, finding a good first solution is often important for good local search performance. We use the IloRankForward
predefined goal and take the first feasible solution that is found.
IloGoal g = IloRankForward(env) && IloInstantiate(env, costVar);
solver.startNewSearch(g);
if(solver.next()) {
IlcInt best = (IlcInt)solver.getValue(costVar);
solver.out() << "Solution for Cost " << best << endl;
solver.printInformation();
globalSolution.store(scheduler);
lsSolution.store(scheduler);
}
|
After finding the solution, we call store on the lsSolution
so that we are then ready to begin local search.