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

The RoutingSolver constructor takes an instance of RoutingModel as a parameter. The goal to instantiate cost is created using the function IloDichotomize. The goal to restore the solution is created using IloRestoreSolution. The goal used to find the first solution is created by the predefined first solution heuristic IloNearestAdditionGenerate. The nearest addition heuristic builds a first solution route by adding visits to the route. The visit added to the route is the visit closest--that is, the least costly to get to--to the end of the current partial route of the vehicle. After this visit is added, the heuristic finds the visit that is closest to the visit just added to the end of the current partial route, and so on until all visits are added. For more information about IloNearestAdditionGenerate, see ïtò^ A Predefined First Solution Heuristics. The neighborhood _nhood used for the improvement of the entire problem is smaller than that for the improvement of a depot. Here only IloRelocate and IloExchange are used to increase the solving performance on this large problem. A greedy search heuristic is used. This constructor will be called from the main function. This code is provided for you:

 RoutingSolver::RoutingSolver(RoutingModel& routingModel)
  : _routing( routingModel),
    _mdl(routingModel.getModel()),
    _solver(routingModel.getModel()),
    _dispatcher(_solver),
    _solution(routingModel.getModel())
{
  IloEnv env = getEnv();
  _instantiateCost =
    IloDichotomize(env, _dispatcher.getCostVar(), IloFalse);
  _restoreSolution = IloRestoreSolution(env, _solution);
  _fsGoal = IloNearestAdditionGenerate(env);

  _nhood = IloRelocate(env) + IloExchange(env);
  _greedy = IloImprove(env);

}