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

The member function addDimensions is used to create the two dimensions, _weight and _distance, and add them to the model. The _weight dimension is defined as in Chapter 2, Modeling a Vehicle Routing Problem. The _distance dimension is computed using the shortest path from the road network graph, as in Chapter 4, Minimizing the Number of Vehicles. This code is provided for you:

void RoutingModel::addDimensions() {
  _weight =IloDimension1 (_env, "weight");
  _mdl.add(_weight);

  IloDistance SP_distance = IloGraphDistance (_graph);
  _distance =IloDimension2 (_env, SP_distance, "distance");
  _mdl.add(_distance);

}

In this example, you could also use the predefined distance functions IloEuclidean or IloManhattan or define your own distance function.