IBM ILOG Dispatcher User's Manual > The Basics > Adding Visit Disjunctions > Model > Define the addDimensions function

The addDimensions function is defined as in Minimizing the Number of Vehicles. The _time and _distance dimensions are computed using the shortest path from the road network graph. This code is provided for you:

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

  IloDistance SP_time =   IloGraphDistance (_graph);
  _time  =IloDimension2 (_env, SP_time, "time");
  _mdl.add(_time);

  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.