Available with Network Analyst license.
In this exercise, your goal is to find the best routes for a fleet of vans to transport people who would otherwise not have access to transportation from their homes to different hospitals for medical appointments. You will accomplish this by solving a vehicle routing problem (VRP) analysis using order pairs, which relate and sequence two orders (stops) so that the vans will pick up riders and take them to their proper destinations. Using other features of the VRP analysis layer, you'll also make sure that additional requirements are met. For instance, you will enter a max transit time for order pairs so that riders don't spend too much time in transit. You'll use time windows on orders so that riders are not late for their appointments. Some riders require wheelchairs; you'll use specialties to match those riders with vans that have wheelchair lifts. Once the routes are determined, you will generate turn-by-turn directions of the resulting routes, which can be electronically distributed or printed and given to the drivers.
Preparing your display
- If you have Exercise08.mxd open in ArcMap, skip to step 6.
- Start ArcMap.
- On the ArcMap - Getting Started dialog box, click Existing Maps > Browse for more.
The Open ArcMap Document dialog box appears.
- Browse to C:\ArcGIS\ArcTutor\Network Analyst\Tutorial.
This is the default installation location for the tutorial data.
- Double-click Exercise08.mxd.
The map document opens in ArcMap.
- Enable the ArcGIS Network Analyst extension.
- Click Customize > Extensions.
The Extensions dialog box opens.
- Check Network Analyst.
- Click Close.
- Click Customize > Extensions.
- Click Customize > Toolbars > Network Analyst.
The Network Analyst toolbar is added to ArcMap.
- On the Network Analyst toolbar, click the Network Analyst window button .
The dockable Network Analyst window opens.
If the Network Analyst toolbar is not displayed, you need to add it.
If the Network Analyst window is not displayed, you need to add it.
You can dock or undock the Network Analyst window.
Creating the vehicle routing problem analysis layer
- Click Network Analyst on the Network Analyst toolbar and click New Vehicle Routing Problem.
The vehicle routing problem analysis layer is added to the Network Analyst window. The network analysis classes (Orders, Depots, Routes, Depot Visits, Breaks, Route Zones, Route Seed Points, Route Renewals, Specialties, Order Pairs, Point Barriers, Line Barriers, and Polygon Barriers) are empty.
The analysis layer is also added to the Table Of Contents window.
Adding specialties
The logistics company has three vans. One of the vans that operates in the downtown area is equipped to provide access for wheelchairs. You will add Wheelchair as a specialty so orders that require this specialty can be assigned to the route that has a wheelchair lift.
- In the Network Analyst window, right-click Specialties (0) and click Add Item.
A new specialty, Item 1, is added under the Specialties class in the Network Analyst window. The Properties window for the new specialty opens.
- In the Properties window, enter Wheelchair as the value of Name.
- Click OK.
Adding orders
A spreadsheet is provided with the tutorial data. It contains information about each patient, including their name and home address; the name and the address of the hospital they must be taken to; the time window within which the patient has to be picked up; and so on. The following table describes the fields in the spreadsheet:
Attribute | Description |
---|---|
OrderName1 | The name of the patient needing transportation |
PatientAddress | The location where the patient will be picked up |
OrderName2 | A unique name for the destination |
HospitalAddress | The location where the patient has the appointment |
PickFrom | The earliest time the patient may be picked up from PatientAddress |
PickTo | The latest time the patient may be picked up from PatientAddress |
TotalPassengers | The total number of passengers to be picked up |
MaxTransitTime | The maximum time the patient can spend in the van |
SpecialtyNames | Specifies the special needs that are required by the passenger, for example, a wheelchair |
In this case, the passengers and hospital visits are related to each other since each passenger has to visit a predetermined hospital. You can model this situation with order pairs—by loading both patient and hospital locations into the Orders network analysis class and relating them with new order pair objects.
In the following steps, you will geocode the patient and hospital addresses and load the resulting points as orders.
- Click File > Add Data > Geocoding > Geocode Addresses.
The Choose an Address Locator to use dialog box opens.
- Click SanFranciscoLocator.
The SanFranciscoLocator is included with Exercise08.mxd.
- Click OK.
The Geocode Addresses: SanFranciscoLocator dialog box opens.
- Click the browse button next to the Address table drop-down list.
The Choose a table containing addresses dialog box opens.
- Click the Look in drop-down list and choose Home - Tutorial.
The table that you will add is stored in an Excel spreadsheet that is included in the Network Analyst tutorial data.
- Double-click OrderPairs.xls.
- Double-click Patients$.
The Patients worksheet is added to the Address table drop-down list.
- In the Street or Intersection drop-down list, choose PatientAddress.
- Click the browse button next to the Output shapefile or feature class text box.
The Saving Data dialog box opens at the home location for Exercise08.mxd.
- Click the Look in drop-down list and choose Home - Tutorial.
- Click the Save as type drop-down list and choose File and Personal Geodatabase feature classes.
The list of files and workspaces is updated.
- Double-click SanFrancisco.gdb.
- Delete the name in the Name text box and type Patients.
Patients will be the name of the output feature class.
- Click Save.
The Output shapefile or feature class text box on the Geocode Addresses: SanFranciscoLocator dialog box is updated to show the new output path.
- Click OK.
The Geocoding Addresses dialog box opens and indicates that all 15 addresses were matched.
- Click Close.
The geocoded addresses are added to the map document as a point feature layer, Geocoding Result: Patients.
- Repeat steps 1–16 to load the patients' destination hospitals, but make the following changes:
- In step 8, set Street or Intersection to HospitalAddress.
- In step 13, type DestinationHospitals in the Name text box.
The Table of Contents window should now have two feature layers, Geocoding Results: DestinationHospitals and Geocoding Results: Patients.
- In the Table Of Contents window, uncheck the two geocoding results layers so that they are not visible in the map display.
- In the Network Analyst window, right-click Orders (0) and choose Load Locations.
The Load Locations dialog box opens.
- Choose Geocoding Results: Patients from the Load From drop-down list.
- Configure the properties that are listed in the Location Analysis Properties section so that they copy field values from the Geocoding Results: Patients layer in the way specified by the substeps below. (The next graphic highlights these changes.)
- Map the Name property to the OrderName1 field.
- Map the Description property to the PatientAddress field.
- Map the TimeWindowStart1 property to the PickFrom field.
- Map the TimeWindowEnd1 property to the PickTo field.
- Map the PickupQuantities property to the TotalPassengers field.
- Make sure that the SpecialtyNames property is automatically matched to the SpecialtyNames field.
- Type 2 under Default Value for the ServiceTime property.
All patient address locations that are loaded will have a ServiceTime value of 2 to account for the average time (in minutes) that is taken for passengers to board the van.
- Type 0 under Default Value for the MaxViolationTime1 property.
By setting all the MaxViolationTime1 properties to zero, the VRP solver will only search for routes that visit the orders within their time windows.
- Click OK.
Fifteen orders are loaded. You can see them in the map display and in the Network Analyst window.
- In the Network Analyst window, right-click Orders (15) and choose Load Locations.
The Load Locations dialog box opens.
- Choose Geocoding Results: DestinationHospitals from the Load From drop-down list.
- Configure the properties that are listed in the Location Analysis Properties section so that they copy field values from the Geocoding Results: DestinationHospitals layer in the way specified by the substeps below. (The next graphic highlights these changes.)
- Map the Name property to the OrderName2 field.
Note that the value for the Name attribute has to be unique in the Orders network analysis class. In this case, there are many patients who need to visit the same hospital. So if the hospital addresses were used to derive the value of the Name attribute for Orders, then the VRP solver would return error messages as there would be duplicate Name values.
- Map the Description property to the HospitalAddress field.
- Map the DeliveryQuantities property to the TotalPassengers field.
- Make sure that the SpecialtyNames property is automatically matched to the SpecialtyNames field.
- Map the Name property to the OrderName2 field.
- Type 2 under Default Value for the ServiceTime property.
- Click OK.
Thirty orders are listed in the Network Analyst window under the Orders network analysis class and are displayed as orders on the map in the Vehicle Routing Problem layer.
In the next steps, you will load these layers into the Orders network analysis class.
The Location Analysis Properties section on the Load Locations dialog box lets you specify which attributes of the Geocoding Results: Patients layer contain the values that Network Analyst will reference in this vehicle routing problem.
Adding order pairs
The passengers have to be taken to a predetermined hospital. By adding objects to the Order Pairs network analysis class, you can add the information that specifies which hospital the patients have to be taken to and the maximum time the patients can sit in the van during a one-way trip.
- In the Network Analyst window, right-click Order Pairs (0) and choose Load Locations.
The Load Locations dialog box opens.
- Click the browse button next to the Load From drop-down list.
- Click the Look in drop-down list and choose Home - Tutorial.
The table that you will add is stored in an Excel spreadsheet that is included in the ArcGIS Network Analyst extension tutorial data.
- Double-click OrderPairs.xls.
- Double-click Patients$.
The Patients table is added to the Load From drop-down list on the Load Locations dialog box.
- Configure the properties that are listed in the Location Analysis Properties section so that they pull field values from the Patients$ table in the way specified by the substeps below.
- Map the FirstOrderName property to the OrderName1 field.
- Map the SecondOrderName property to the OrderName2 field.
- Make sure that the MaxTransitTime property is automatically matched to the MaxTransitTime field.
- Click OK.
Fifteen order pairs are listed in the Network Analyst window under the Order Pairs network analysis class.
Adding depots
The logistics company operates vans from three depots whose locations are shown in the CentralDepots feature layer in ArcMap. You will now add these point features to the Depots network analysis class.
- In the Network Analyst window, right-click Depots (0) and choose Load Locations.
The Load Locations dialog box opens.
- Select CentralDepots from the Load From drop-down list.
- In the Location Analysis Properties section, make sure that the Name property is automatically matched to the Name field.
- Click OK.
Three depots are listed in the Network Analyst window under the Depots network analysis class and are displayed on the map in the Vehicle Routing Problem layer.
Adding routes
The logistics company has three vans, each with a maximum capacity of six passengers. The vans start and return to the depots after completing all the trips. One of the vans that operates within the downtown area has a lift to provide easy access for wheelchairs.
You will add three routes (one for each van) and set the property for the downtown van to include Wheelchair as a specialty.
- In the Network Analyst window, right-click Routes (0) and choose Add Item.
A new route, Item1, is added under the Routes network analysis class, and the route's Properties window opens.
- In the Properties window, specify the attributes for the route as shown in the table below, leaving the default values for the other attributes. The Description column in the table explains the use of particular values.
Attribute Value Description Name
Downtown
Name of the route.
StartDepotName
Downtown Depot
The van starts at the depot in the downtown area.
EndDepotName
Downtown Depot
The van returns to the depot in the downtown area at the end of the route.
Capacities
6
The van can carry a maximum of six passengers at a time.
SpecialtyNames
Wheelchair (Check Wheelchair to set it as the value.)
The van is equipped to provide access for wheelchairs.
- Click OK.
A new route, Downtown, is listed in the Network Analyst window.
- Repeat steps 1–3 to add two more routes representing the vans that operate in the North Bay and East Bay areas. Use the following tables for these new routes instead of the properties listed in step 2.
Attribute Value Name
North Bay
StartDepotName
North Bay Depot
EndDepotName
North Bay Depot
Capacities
6
Attribute Value Name
East Bay
StartDepotName
East Bay Depot
EndDepotName
East Bay Depot
Capacities
6
Note that these vans are not equipped to allow access for wheelchairs.
The Network Analyst window displays three route objects listed within the Routes network analysis class.
Adding route zones
The three vans used by the company are only licensed to service orders in a predetermined area. You will add route zones and associate them with the vans/routes.
- In the Network Analyst window, select Route Zones (0).
- Click the Create Network Location Tool on the Network Analyst toolbar.
- On the map display, digitize a polygon that roughly covers the downtown area as shown below.
Click to add vertices; double-click to complete the polygon.
A new route zone, Graphic Pick 1, is added to the route zones class in the Network Analyst window.
- In the Network Analyst window, double-click the new route zone object, Graphic Pick 1.
The route zone's Properties window opens.
- Set the properties of the route zone as shown in the table below.
Attribute Value Description RouteName
Downtown
The name of the route that this route zone is associated with.
IsHardZone
True
The van can't service orders that are outside the route zone. Setting this value to True ensures that the van is only assigned orders that are within the route zone.
- Repeat steps 1–6 to add two more route zones: one for the North Bay and one for the East Bay.
The map and the Network Analyst window should contain three route zone objects.
Setting up the properties for analysis
Next you will specify the properties for your vehicle routing problem analysis.
- Click the Analysis Layer Properties button on the Network Analyst window.
The Layer Properties dialog box opens.
- Click the Analysis Settings tab.
- Make sure that the Time Attribute drop-down list is set to TravelTime (Minutes).
The VRP solver will use this attribute to calculate time-based costs between orders and depots.
- Make sure that nothing is selected in the Distance Attribute drop-down list.
Since you are not using any distance-based cost parameters, such as CostPerUnitDistance or MaxTotalDistance, setting the distance attribute is not required.
- Set the Default Date to Day of Week. In the Day of Week drop-down list, choose Monday.
- Since the van capacity is measured only by the total number of passengers that can be accommodated, make sure that Capacity Count is set to 1.
If the capacity had been measured by the total number of passengers and the maximum number of wheelchairs that can be accommodated in the van, the capacity count would be 2.
- Leave the default options for the other properties.
- Click OK.
Run the process to determine the solution
- Click the Solve button on the Network Analyst toolbar.
The VRP solver calculates the routes for each van. Each route begins at a depot, picks up one or more people if the time they spend on the van is less than the MaxTransitTime specified in the order pair, drops them at their hospital locations, continues to pick up and drop off other people, and returns to the depot at the end. The routes only service orders in their assigned route zones.
Determine turn-by-turn directions for the routes
- Click the Directions Window button on the Network Analyst toolbar.
The Directions dialog box opens.
- You can optionally export the vehicle routing problem as a layer file (<filename>.lyr) on disk so that you can load it in a different map document.
- Exit ArcMap without saving any changes.