IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Pickup and Delivery by Multiple Vehicles from Multiple Depots > Model > Define the Depot::improve function

You define a method improve that is used for improving the solution rs passed as an argument. A solver solver and a goal g to be executed at each move are also passed as parameters. The number of moves made is returned. First, the neighborhood and greedy metaheuristic are reset. Then, the improvement goal is created using IloSingleMove. An improvement loop is then entered, which stops when no move can improve the cost of the current solution. Finally, the number of moves made is returned. The following code is provided for you:

IloBool Depot::improve(IloSolver solver, IloRoutingSolution rs, IloGoal g) {
  _nhood.reset();
  _mh.reset();
  IloGoal improve = IloSingleMove(_env, rs, _nhood, _mh, g);
  solver.out() << "  Optimizing depot " << getName() << " "
               << rs.getSolution().getObjectiveValue() << flush;
  IloBool moves = 0;
  while (solver.solve(improve)) ++moves;
  solver.out() << " ---> " << rs.getSolution().getObjectiveValue() << endl;
  return (moves>0);
}