IBM ILOG Dispatcher User's Manual > The Basics > Minimizing the Number of Vehicles > Solve > Define the RoutingSolver constructor

The RoutingSolver constructor is defined as in Chapter 3, Solving a Vehicle Routing Problem. It takes an instance of RoutingModel as a parameter. The environment, model, solver, dispatcher, and solution are initialized. The goal to instantiate cost is created using the function IloDichotomize. You use the predefined first solution generation heuristic IloSavingsGenerate to create the first solution. The goal to restore the solution is created using IloRestoreSolution. This constructor will be called from the main function. This code is provided for you:

 RoutingSolver::RoutingSolver(RoutingModel mdl):
  _env(mdl.getEnv()),
  _mdl(mdl.getModel()),
  _solver(mdl.getModel()),
  _dispatcher(_solver),
  _solution(mdl.getModel()){
    _instantiateCost =
        IloDichotomize(_env, _dispatcher.getCostVar(), IloFalse);
    _generateGoal = IloSavingsGenerate(_env) && _instantiateCost;
    _restoreSolution = IloRestoreSolution(_env, _solution);
  }