IBM ILOG Dispatcher User's Manual > Transportation Industry Solutions > Pickup and Delivery by Multiple Vehicles from Multiple Depots > Model > Define the Depot::fillModel function

The class Depot also requires the ability to synchronize its internal model with a routing solution. To perform this you first empty the model of the visit models which previously comprised the model. You then scan the solution for the vehicles which are based at this depot, and for each one, find out which visits are made by these vehicles. These visits (or more accurately, the models pertaining to these visits) must then be placed in the depot model. You keep track of which visits are in the model in the array _visits.

Step 5   -  

Fill the depot model

Add the following code after the comment //Fill the depot model

  void Depot::fillModel(IloRoutingSolution rs) {
  IloInt i;
  for (i = 0; i < _visits.getSize(); i++)
    _model.remove((IloModelI *)_visits[i].getObject());
  _visits.end();
  _visits = IloVisitArray(_env);
  for (i = 0; i < _vehicles.getSize(); i++) {
    for (IloRoutingSolution::RouteIterator r(rs, _vehicles[i]); r.ok(); ++r) {
      IloVisit visit = *r;
      if ( !visit.isFirstVisit() && !visit.isLastVisit() ) {
        _visits.add(visit);
        _model.add( (IloModelI*)visit.getObject() );
      }
    }
  }
}