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

The createVisits function is defined as in Chapter 4, Minimizing the Number of Vehicles, except that instead of directly adding each visit to the model, you add each visit to an array of unordered visits. This array of unordered array of visits will be ordered in the submodel and used to create a first solution. The visits created by this function are the customer visits. The return visits to the depot are created by a member function of the class RoutingSolver. See "Define the insertAllReturnVisits function".

Step 6   -  

Add the visit to the array of unordered visits

Add the following code after the comment
//Add the visit to the array of unordered visits

    _unorderedVisitArray.add(visit);

Likewise, the constraint on visit quantity is not added directly to the model. It is added by setting both the upper and lower bounds of the transit variable associated with the dimension _weight equal to quantity.

Step 7   -  

Add the constraint on visit quantity

Add the following code after the comment
//Add the constraint on visit quantity

    visit.getTransitVar(_weight).setBounds(quantity, quantity);

Here is the complete code for defining the createVisits function:

 void RoutingModel::createVisits(const char* visitsFileName) {
  IloCsvReader csvVisitReader(_env, visitsFileName);
  IloCsvReader::LineIterator  it(csvVisitReader);
  while(it.ok()){
    IloCsvLine line = *it;
    //read visit data from files
    char * visitName =  line.getStringByHeader("name");
    char * nodeName = line.getStringByHeader("node");
    IloNum quantity = line.getFloatByHeader("quantity");
    IloNode node = IloNode::Find(_env, nodeName);
    IloVisit visit(node, visitName);

    visit.getTransitVar(_weight).setBounds(quantity, quantity);

    _unorderedVisitArray.add(visit);

    ++it;
  }
  csvVisitReader.end();
}