Exercise 8: Finding best routes to service paired orders

Complexity: Beginner Data Requirement: ArcGIS Tutorial Data for Desktop Data Path: C:\ArcGIS\ArcTutor\Network Analyst\Tutorial Goal: Solve a vehicle routing problem analysis with order pairs.

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.

NoteNote:

The data for this exercise and the other exercises in the Network Analyst tutorial is available on ArcGIS.com. After downloading the data, you can extract it wherever you like. It may be helpful, however, to extract it to C:\arcgis\ArcTutor since the tutorial refers to this path as the default location for the data.

Preparing your display

Steps:
  1. If you have Exercise08.mxd open in ArcMap, skip to step 6.
  2. Start ArcMap by clicking Start > All Programs > ArcGIS > ArcMap 10.1.
  3. On the ArcMap - Getting Started dialog box, click Existing Maps > Browse for more.

    The Open ArcMap Document dialog box appears.

  4. Browse to C:\ArcGIS\ArcTutor\Network Analyst\Tutorial.

    This is the default installation location for the tutorial data.

  5. Double-click Exercise08.mxd.

    The map document opens in ArcMap.

  6. Enable the ArcGIS Network Analyst extension.
    1. Click Customize > Extensions.

      The Extensions dialog box opens.

    2. Check Network Analyst.
    3. Click Close.
  7. If the Network Analyst toolbar is not displayed, you need to add it.

  8. Click Customize > Toolbars > Network Analyst.

    The Network Analyst toolbar is added to ArcMap.

    The Network Analyst toolbar

  9. If the Network Analyst window is not displayed, you need to add it.

  10. On the Network Analyst toolbar, click the Network Analyst window button Network Analyst window.

    The dockable Network Analyst window opens.

    The Network Analyst window

  11. You can dock or undock the Network Analyst window.

Creating the vehicle routing problem analysis layer

Steps:
  1. Click Network Analyst on the Network Analyst toolbar and click New Vehicle Routing Problem.

    Choosing New OD Cost Matrix

    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 Network Analyst window with empty classes

    The analysis layer is also added to the Table Of Contents window.

    The vehicle routing problem analysis layer shown in the table of contents

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.

Steps:
  1. In the Network Analyst window, right-click Specialties (0) and click Add Item.

    Creating a specialty

    A new specialty, Item 1, is added under the Specialties class in the Network Analyst window. The Properties window for the new specialty opens.

  2. In the Properties window, enter Wheelchair as the value of Name.

    The specialty name set to Wheelchair

  3. 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.

Steps:
  1. Click File > Add Data > Geocoding > Geocode Addresses.

    The Choose an Address Locator to use dialog box opens.

  2. Click SanFranciscoLocator.

    The SanFranciscoLocator is included with Exercise08.mxd.

  3. Click OK.

    The Geocode Addresses: SanFranciscoLocator dialog box opens.

  4. Click the browse button Browse next to the Address table drop-down list.

    The Choose a table containing addresses dialog box opens.

  5. 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.

  6. Double-click OrderPairs.xls.
  7. Double-click Patients$.

    The Patients worksheet is added to the Address table drop-down list.

  8. In the Street or Intersection drop-down list, choose PatientAddress.
  9. Click the browse button Browse next to the Output shapefile or feature class text box.

    The Saving Data dialog box opens at the home location for Exercise08.mxd.

  10. Click the Look in drop-down list and choose Home - Tutorial.
  11. Click the Save as type drop-down list and choose File and Personal Geodatabase feature classes.

    The list of files and workspaces is updated.

  12. Double-click SanFrancisco.gdb.
  13. Delete the name in the Name text box and type Patients.

    Patients will be the name of the output feature class.

  14. 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.

    The completed Geocode Addresses: SanFranciscoLocator dialog box

  15. Click OK.

    The Geocoding Addresses dialog box opens and indicates that all 15 addresses were matched.

  16. Click Close.

    The geocoded addresses are added to the map document as a point feature layer, Geocoding Result: Patients.

  17. Repeat steps 1–16 to load the patients' destination hospitals, but make the following changes:
    1. In step 8, set Street or Intersection to HospitalAddress.
    2. In step 13, type DestinationHospitals in the Name text box.

      The Geocode Addresses: SanFranciscoLocator dialog box for hospital

      The Table of Contents window should now have two feature layers, Geocoding Results: DestinationHospitals and Geocoding Results: Patients.

  18. In the Table Of Contents window, uncheck the two geocoding results layers so that they are not visible in the map display.
  19. In the next steps, you will load these layers into the Orders network analysis class.

  20. In the Network Analyst window, right-click Orders (0) and choose Load Locations.

    The Load Locations dialog box opens.

  21. Choose Geocoding Results: Patients from the Load From drop-down list.
  22. 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.

  23. 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.)
    1. Map the Name property to the OrderName1 field.
    2. Map the Description property to the PatientAddress field.
    3. Map the TimeWindowStart1 property to the PickFrom field.
    4. Map the TimeWindowEnd1 property to the PickTo field.
    5. Map the PickupQuantities property to the TotalPassengers field.
    6. Make sure that the SpecialtyNames property is automatically matched to the SpecialtyNames field.
  24. 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.

  25. 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.

    The Load Locations dialog box

  26. Click OK.

    Fifteen orders are loaded. You can see them in the map display and in the Network Analyst window.

  27. In the next steps, you will load the destination hospitals as orders too.
  28. In the Network Analyst window, right-click Orders (15) and choose Load Locations.

    The Load Locations dialog box opens.

  29. Choose Geocoding Results: DestinationHospitals from the Load From drop-down list.
  30. 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.)
    1. 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.

    2. Map the Description property to the HospitalAddress field.
    3. Map the DeliveryQuantities property to the TotalPassengers field.
    4. Make sure that the SpecialtyNames property is automatically matched to the SpecialtyNames field.
  31. Type 2 under Default Value for the ServiceTime property.

    Load Locations dialog box

  32. 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.

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.

Steps:
  1. In the Network Analyst window, right-click Order Pairs (0) and choose Load Locations.

    The Load Locations dialog box opens.

  2. Click the browse button Browse next to the Load From drop-down list.
  3. 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.

  4. Double-click OrderPairs.xls.
  5. Double-click Patients$.

    The Patients table is added to the Load From drop-down list on the Load Locations dialog box.

  6. 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.
    1. Map the FirstOrderName property to the OrderName1 field.
    2. Map the SecondOrderName property to the OrderName2 field.
    3. Make sure that the MaxTransitTime property is automatically matched to the MaxTransitTime field.
  7. Click OK.

    Fifteen order pairs are listed in the Network Analyst window under the Order Pairs network analysis class.

    Order pairs in the Network Analyst window

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.

Steps:
  1. In the Network Analyst window, right-click Depots (0) and choose Load Locations.

    The Load Locations dialog box opens.

  2. Select CentralDepots from the Load From drop-down list.
  3. In the Location Analysis Properties section, make sure that the Name property is automatically matched to the Name field.

    The Load Locations dialog box

  4. 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.

Steps:
  1. In the Network Analyst window, right-click Routes (0) and choose Add Item.

    Choosing Add Item

    A new route, Item1, is added under the Routes network analysis class, and the route's Properties window opens.

  2. 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.

    Route Properties window

  3. Click OK.

    A new route, Downtown, is listed in the Network Analyst window.

  4. 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.

    Route analysis classes

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.

Steps:
  1. In the Network Analyst window, select Route Zones (0).
  2. Click the Create Network Location Tool Create Network Location Tool on the Network Analyst toolbar.
  3. 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.

    Creating a route zone
    A new route zone, Graphic Pick 1, is added to the route zones class in the Network Analyst window.

  4. In the Network Analyst window, double-click the new route zone object, Graphic Pick 1.

    The route zone's Properties window opens.

  5. 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.

    Route zone properties

  6. 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.

    The three route zones in the map display
    The three route zones in the Network Analyst window

Setting up the properties for analysis

Next you will specify the properties for your vehicle routing problem analysis.

Steps:
  1. Click the Analysis Layer Properties button on the Network Analyst window.

    Clicking the Layer Properties button

    The Layer Properties dialog box opens.

  2. Click the Analysis Settings tab.
  3. 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.

  4. 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.

  5. Set the Default Date to Day of Week. In the Day of Week drop-down list, choose Monday.
  6. 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.

  7. Leave the default options for the other properties.

    The Analysis Settings tab

  8. Click OK.

Run the process to determine the solution

Steps:
  1. Click the Solve button Solve 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.

    Results of the VRP analysis

Determine turn-by-turn directions for the routes

Steps:
  1. Click the Directions Window button Directions on the Network Analyst toolbar.

    The Directions dialog box opens.

  2. 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.
  3. Exit ArcMap without saving any changes.
7/2/2014