IBM ILOG Dispatcher User's Manual > The Basics > Multiple Tours per Vehicle > Solve > Define the main function

After you finish creating the RoutingModel and RoutingSolver classes and the printInformation function, you use them in the main function. You can use command line syntax to pass the names of input files to the model. If you do not specify input files, the defaults will be used. In the main function, you first create an environment. Then you create an instance of the RoutingModel class, which takes the environment and input files as parameters. You create an instance of the RoutingSolver class, which takes the model as a parameter. You call the member function RoutingSolver::insertAllReturnVisits to add the return visits to the first solution. You call the member function RoutingSolver::orderVisits to create a submodel and order the customer visits. This member function takes two parameters: the unordered visit array and the graph from the routing model mdl. You call the member function RoutingSolver::insertCustomerVisits to insert the ordered customer visits into the first solution. You use Solver to improve the first solution and print this solution. The following code is provided for you:

int main(int argc, char * argv[]) {
  IloEnv env;
  try {
    RoutingModel mdl(env, argc, argv);
    RoutingSolver solver(mdl);
    solver.insertAllReturnVisits();
    solver.orderVisits(mdl.getUnorderedVisitArray(), mdl.getGraph());
    if (solver.insertCustomerVisits()) {
      solver.improveWithNhood();
      solver.printInformation("***Solution after improvements with nhood***");
    }
  } catch(IloException& ex) {
    cerr << "Error: " << ex << endl;
  }
  env.end();
  return 0;
}

Step 22   -  

Compile and run the program

Compile and run the program. You will get results that show the routing plan and information for the improved solution. The solution uses 4 vehicles. Each vehicle makes one return visit to the depot, that is, each vehicle performs two tours. There are 12 unused return visits. See "Complete Output" for details. The solution improvement phase finds a solution using 4 vehicles with a total cost of 2114.8 units after making 139 cost-decreasing moves:

Inserting return visits
Producing insertion order
Inserting customer visits
Improving solution
***Solution after improvements with nhood***
Number of fails               : 0
Number of choice points       : 0
Number of variables           : 2196
Number of constraints         : 132
Reversible stack (bytes)      : 192984
Solver heap (bytes)           : 687828
Solver global heap (bytes)    : 1021680
And stack (bytes)             : 20124
Or stack (bytes)              : 48264
Search Stack (bytes)          : 4044
Constraint queue (bytes)      : 13164
Total memory used (bytes)     : 1988088
Elapsed time since creation   : 0.016
Number of nodes               : 101
Number of visits              : 132
Number of vehicles            : 8
Number of dimensions          : 2
Number of accepted moves      : 139
===============
Cost         : 2114.8
Number of vehicles used : 4

The complete program and output are listed in "Complete Program". You can also view it online in the YourDispatcherHome/examples/src/multitr.cpp file.