IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Pickup and Delivery by Multiple Vehicles from Multiple Depots > Solve > Define the RoutingSolver::improveDepots function

If a first solution is found, the solution is improved using local search. You iterate over all depots, using Depot::fillModel to populate each model. You then update the cost of the global solution according to the model of this depot. You use Depot::improve to attempt to reduce the cost of the routing for this depot. Finally, the solution is synchronized with the global model.

Step 16   -  

Improve the depots

Add the following code after the comment //Improve the depots

IloBool RoutingSolver::improveDepots() {
  IloEnv env = getEnv();
  _move =
    IloSingleMove(env, _solution, _nhood, _greedy, _instantiateCost);

  _solver.out() << endl << "Improvement loop" << endl;
  _solver.out() << "================" << endl;
  IloBool improved = IloTrue;
  IloInt nbOfDepots = _routing.getNumberOfDepots();
  improved = IloFalse;
  for (IloInt d = 0; d < nbOfDepots; ++d) {
    Depot* depot = _routing.getDepot(d);
    depot->fillModel(_solution);
    syncSolution(depot->getModel(), _solution, _instantiateCost);
    if ( depot->improve(_solver, _solution, _instantiateCost) ) {
      improved = IloTrue;
    }
  }

  // sync back to full model.
  syncSolution(_mdl, _solution, _instantiateCost);
  return improved;
}