IBM ILOG Dispatcher User's Manual > The Basics > Modeling a Vehicle Routing Problem > Model > Define the createVisits function |
Define the createVisits function |
INDEX
![]() |
As you remember from Chapter 1, IBM ILOG Dispatcher Concepts, visits occur at a single node and are performed by only one vehicle. A visit must be associated to a node, its location. A visit also has a quantity--the amount of goods delivered to the location. A visit can have a minimum time and a maximum time during which it can be performed--a time window. Additionally, visits have a drop time--the amount time required to perform the visit.
In this lesson, you will use the csv reader functionality to input this visit data from a csv file. You use the classes IloCsvReader
, IloCsvReader::Iterator
, and IloCsvLine
. This code is provided for you:
Next, you use the static member function IloNode::Find
to find the node associated with the visit.
Step 18 - | Find the visit node |
Add the following code after the comment //Find the visit node
IloNode node = IloNode::Find(_env, nodeName); |
Next, you create a visit using an instance of IloVisit
. The constructor for IloVisit
takes two parameters: an instance of IloNode
and a name for debug and trace purposes. The instance of IloNode
represents the location of the visit. You add the constraint that the amount of delay time at the visit must equal the drop time. You add the constraint that the amount of weight dropped off at the visit must equal the quantity of goods to be delivered at the visit. You also add the constraint that the visit must be performed within the visit time window.
Step 19 - | Create the visit and add constraints |
Add the following code after the comment //Create the visit and add constraints
IloVisit visit(node, visitName); _mdl.add(visit.getDelayVar(_time) == dropTime); _mdl.add(visit.getTransitVar(_weight) == quantity); _mdl.add(minTime <= visit.getCumulVar(_time) <= maxTime); |
Then, you add the visit to the model.
Step 20 - | Add the visit to the model |
Add the following code after the comment //Add the visit to the model
_mdl.add(visit); |
Finally, you move to the next line in the csv file. When the end of the file is reached, you deallocate the memory used by the csv reader. This code is provided for you:
++it; } csvVisitReader.end(); } |
© Copyright IBM Corp. 1987, 2009. Legal terms. | PREVIOUS NEXT |