Vehicle Routing Problem service

Various organizations service orders with a fleet of vehicles. For example, a large furniture store might use several trucks to deliver furniture to homes. A specialized grease recycling company might route trucks from a facility to pick up used grease from restaurants. A health department might schedule daily inspection visits for each of its health inspectors. The problem that is common to these examples is the vehicle routing problem (VRP). Each organization needs to determine which orders (homes, restaurants, or inspection sites) should be serviced by each route (truck or inspector) and in what sequence the orders should be visited. The primary goal is to best service the orders and minimize the overall operating cost for the fleet of vehicles. The VRP service can be used to determine solutions for such complex fleet management tasks. In addition, the service can solve more specific problems because numerous options are available, such as matching vehicle capacities with order quantities, providing a high level of customer service by honoring any time windows on orders, giving breaks to drivers, and pairing orders so they are serviced by the same route.

Consider an example of delivering goods to grocery stores from a central warehouse location. A fleet of three trucks is available at the warehouse. The warehouse operates only within a certain time window—from 8:00 a.m. to 5:00 p.m.—during which all trucks must return back to the warehouse. Each truck has a capacity of 15,000 pounds, which limits the amount of goods it can carry. Each store has a demand for a specific amount of goods (in pounds) that needs to be delivered, and each store has time windows that confine when deliveries should be made. Furthermore, the driver can work only eight hours per day, requires a break for lunch, and is paid for the amount of time spent on driving and servicing the stores. The service can be used to determine an itinerary for each route such that the deliveries can be made while honoring all the vehicle and order requirements and minimizing the total time spent on a particular route by the driver.

Dive-inDive-in:

The sequencing of orders performed by the service is always done using static travel times, even when the mode of transportation for the analysis uses an impedance that is based on dynamic travel times fluctuating according to traffic flows, in areas where traffic data is available. But when generating directions, the routes between the sequenced orders use dynamic travel speeds based on traffic.

Request URL

The vehicle routing problem service supports synchronous and asynchronous execution modes. Asynchronous and synchronous modes define how the application interacts with the service and gets the result. When using the synchronous execution mode, the application must wait for the request to finish and get the results. This execution mode is well-suited for requests that complete quickly (under 10 seconds). When using the asynchronous execution mode, the client must periodically check if the service has finished execution and once completed get the result. While the service is executing, the application is free to do other things. This execution mode is well-suited for requests that take a long time to complete.

CautionCaution:

The maximum time an application can use the vehicle routing problem service when using the asynchronous execution mode is 4 hours (14,400 seconds). If your request does not complete within the time limit, it will time out and return a failure. When using the synchronous execution mode, the request must complete within 60 seconds. If your request takes longer, the web server handling the request will time out and return the appropriate HTTP error code in the response.

A request to the vehicle routing problem service has a URL that is specific to the execution mode. When using the synchronous execution mode, the request is of the following form:

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblemSync/GPServer/EditVehicleRoutingProblem/execute?parameters

When using the asynchronous execution mode, the request is of the following form

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?parameters

Dive-inDive-in:

The service works in all of the supported countries as listed in the data coverage page. One or more countries are grouped together to form a region. When you pass in your inputs, the service determines the region containing all of the inputs based on the location of the first order in the orders parameter. The service does not support requests that span more than one region. Consequently, routes will be found only between those orders that are in the same region as the first order.

Request parameters

The vehicle routing problem request takes the parameters listed in the subsections below. The only required parameters are orders, depots, routes, token, and f. The optional parameters have default values that will be used if the parameter is not specified in the request.

Required parameters

orders

Use this parameter to specify the orders the routes should visit. An order can represent a delivery (for example, furniture delivery), a pickup (such as an airport shuttle bus picking up a passenger), or some type of service or inspection (a tree trimming job or building inspection, for instance).

A maximum of 100 orders can be specified for synchronous execution and 2,000 for asynchronous execution.

The orders parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the order geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents an order and contains the following properties:

  • geometry: Specifies the order geometry as a point containing x and y properties.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for orders

When specifying the orders, you can specify additional properties for orders such as their names or service times using attributes. The orders parameter can be specified with the following attributes:

  • Name: The name of the order. The name must be unique. If the name is left null, a name is automatically generated by the service.
  • ServiceTime: Specifies how much time will be spent at the order when the route visits it. This attribute can be used to model the time required to provide some kind of service while you are visiting the order location. A zero or null value indicates that the order requires no service time. The unit for this attribute value is specified by the time_units parameter.
  • TimeWindowStart1: The beginning time of the first time window for the order. A null value indicates no beginning time.

    A time window only states when a vehicle can arrive at an order; it doesn't state when the service time must be completed. If you want to account for the service time and leave the order before the time window is over, subtract ServiceTime from the TimeWindowEnd1 attribute value.

  • TimeWindowEnd1: The ending time of the first window for the order. A null value indicates no ending time.
  • TimeWindowStart2: The beginning time of the second time window for the order. A null value indicates that there is no second time window.

    If the first time window is null, as specified by the TimeWindowStart1 and TimeWindowEnd1 attributes, the second time window must also be null. If both time windows are nonnull, they can't overlap. Also, the second time window must occur after the first.

  • TimeWindowEnd2: The ending time of the second time window for the order. This field can contain a null value. When TimeWindowStart2 and TimeWindowEnd2 are both null, there is no second time window. When TimeWindowStart2 is not null but TimeWindowEnd2 is null, there is a second time window that has a starting time but no ending time. This is valid input.

The value for the TimeWindowStart1, TimeWindowEnd1, TimeWindowStart2, or TimeWindowEnd2 attributes can contain a time-only value or a date and time value. If the attributes have a time-only value (for example, 8:00 AM), the date is assumed to be the date specified by the default_date parameter. Using date and time values (for example, 7/11/2010 8:00 AM) allows you to set time windows that span multiple days.

The time value is interpreted as local to the time zone in which the street closest to the order is located. If your orders span multiple time zones, you should specify the time window values as local time for each order.

  • MaxViolationTime1: A time window is considered violated if the arrival time occurs after the time window has ended. This attribute specifies the maximum allowable violation time for the first time window of the order. It can contain a zero value but can't contain negative values. A zero value indicates that a time window violation at the first time window of the order is unacceptable; that is, the first time window is hard. On the other hand, a null value indicates that there is no limit on the allowable violation time. A nonzero value specifies the maximum amount of lateness; for example, a route can arrive at an order up to 30 minutes beyond the end of its first time window. The unit for the MaxViolationTime1 attribute value is specified by the time_units parameter.

    Time window violations can be tracked and weighted by the service. Because of this, you can direct the service to take one of three approaches:

    1. Minimize the overall violation time, regardless of the increase in travel cost for the fleet.
    2. Find a solution that balances overall violation time and travel cost.
    3. Ignore the overall violation time; instead, minimize the travel cost for the fleet.

    By assigning an importance level for the time_window_factor parameter, you are essentially choosing one of these three approaches. In any case, however, the service will return an error if the value set for MaxViolationTime1 is surpassed.

  • MaxViolationTime2: The maximum allowable violation time for the second time window of the order. This attribute is analogous to the MaxViolationTime1 attribute.
  • DeliveryQuantities: The size of the delivery. You can specify size in any dimension you want, such as weight, volume, or quantity. You can even specify multiple dimensions; for example, weight and volume.

    Enter delivery quantities without indicating units. For example, if a 300 pound object needs to be delivered to an order, enter 300. You will need to remember that the value is in pounds.

    If you are tracking multiple dimensions, separate the numeric values with a space. For instance, if you are recording the weight and volume of a delivery that weighs 2,000 pounds and has a volume of 100 cubic feet, enter 2000 100. Again, you need to remember the units—in this case, pounds and cubic feet. You also need to remember the sequence the values and their corresponding units are entered in.

    CautionCaution:

    Make sure that Capacities attribute of the routes parameter and the DeliveryQuantities and the PickupQuantities attributes of the orders parameter are specified in the same manner. That is, the values need to be in the same units, and if you are using multiple dimensions, the dimensions need to be listed in the same sequence for all the attributes. So if you specify weight in pounds, followed by volume in cubic feet for DeliveryQuantities, the capacity of your routes and the pickup quantities of your orders need to specified the same way: weight in pounds, then volume in cubic feet. If you mix units or change the sequence, you will get unwanted results without receiving any warning messages.

    An empty string or null value is equivalent to all dimensions being zero. If the string has an insufficient number of values in relation to the capacity count, or dimensions being tracked, the remaining values are treated as zeros. The DeliveryQuantities attribute can not have negative values.

  • PickupQuantities: The size of the pickup. You can specify size in any dimension you want, such as weight, volume, or quantity. You can even specify multiple dimensions; for example, weight and volume. You cannot, however, use negative values. This attribute is analogous to the DeliveryQuantities attribute.

In the case of an exchange visit, an order can have both delivery and pickup quantities.

  • Revenue: The income generated if the order is included in a solution. This attribute can contain a null value—a null value indicates zero revenue—but it can not have a negative value.

    Revenue is included by the service in optimizing the objective function value but is not part of the solution's operating cost. That is, the TotalCost attribute in the out_routes parameter never includes revenue; however, revenue weights the relative importance of servicing orders.

  • SpecialtyNames: A space-separated string containing the names of the specialties required by the order. A null value indicates that the order doesn't require specialties.

    The spelling of any specialties listed in the orders and the routes parameters must match exactly so that the service can link them together.

    To illustrate what specialties are and how they work, assume a lawn care and tree trimming company has a portion of its orders that requires a bucket truck to trim tall trees. The company would enter BucketTruck in the SpecialtyNames attribute for these orders to indicate their special need. SpecialtyNames would be left as null for the other orders. Similarly, the company would also enter BucketTruck in the SpecialtyNames attribute of routes that are driven by trucks with hydraulic booms. It would leave the field null for the other routes. When finding a solution, the service assigns orders without special needs to any route, but it only assigns orders that need bucket trucks to routes that have them.

  • AssignmentRule: Specifies the rule for assigning the order to a route. The attribute value is specified using integers. The text, in parenthesis, next to the integers is only meant to provide a quick summary for the numeric value. The attribute value must be specified using one of the following integers:
    • 0 (Exclude) - The order is to be excluded when finding the solution.
    • 1 (Preserve route and relative sequence) - The service must always assign the order to the preassigned route and at the preassigned relative sequence when finding the solution. If this assignment rule can't be followed, it results in an order violation.

      With this setting, only the relative sequence is maintained, not the absolute sequence. To illustrate what this means, imagine there are two orders: A and B. They have sequence values of 2 and 3, respectively. If you set their AssignmentRule attribute value to 1, A and B's actual sequence values may change in the solution because other orders, breaks, and depot visits could still be sequenced before, between, or after A and B. However, B cannot be sequenced before A.

    • 2 (Preserve route) - The service must always assign the order to the preassigned route when finding the solution. A valid sequence must also be set even though the sequence may or may not be preserved. If the order can't be assigned to the specified route, it results in an order violation.
    • 3 (Override) - The service tries to preserve the route and sequence preassignment for the order when finding the solution. However, a new route and/or sequence for the order may be assigned if it helps minimize the overall value of the objective function. This is the default value.
    • 4 (Anchor first) - The service ignores the route and sequence preassignment (if any) for the order when finding the solution. It assigns a route to the order, and makes it the first order on that route, so as to minimize the overall value of the objective function.
    • 5 (Anchor last) - The service ignores the route and sequence preassignment (if any) for the order when finding the solution. It assigns a route to the order, and makes it the last order on that route, so as to minimize the overall value of the objective function.
  • CurbApproach: Specifies the direction a vehicle may arrive at and depart from the order. One of the integers listed in Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you might have come across when using ArcGIS Network Analyst Extension software.

    Setting

    Coded value

    Description

    Either side of vehicle

    0

    The vehicle can approach and depart the order in either direction, so a U-turn is allowed at the order. This setting can be chosen if it is possible and desirable for your vehicle to turn around at the order. This decision may depend on the width of the road and the amount of traffic or whether the order has a parking lot where vehicles can pull in and turn around.

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    Right side of vehicle

    1

    When the vehicle approaches and departs the order, the order must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the right hand side.

    Right side of vehicle
    The allowed arrival and departure combination for the Right side of vehicle curb approach.

    Left side of vehicle

    2

    When the vehicle approaches and departs the order, the order must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the left hand side.

    Left side of vehicle
    The allowed arrival and departure combination for the Left side of vehicle curb approach.

    No U-Turn

    3

    When the vehicle approaches the order, the order can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived in. A U-turn is prohibited.

    No U-turns
    The allowed arrival and departure combinations for the No U-Turn curb approach.

    The CurbApproach property was designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an order on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach from the right or left side. For example, if you want to arrive at an order and not have a lane of traffic between the vehicle and the order, you would choose Right side of vehicle in the United States but Left side of vehicle in the United Kingdom.

    Right side of vehicle with right-hand traffic.
    With right-hand traffic, the curb approach that leaves the vehicle closest to the stop is Right side of vehicle.
    Left side of vehicle with left-hand traffic
    With left-hand traffic, the curb approach that leaves the vehicle closest to the stop is Left side of vehicle.

  • RouteName: The name of the route to which the order is assigned. This attribute can be used to preassign an order to a specific route. It can contain a null value, indicating that the order is not preassigned to any route, and the service determines the best possible route assignment for the order. If the attribute value is set to null, the Sequence attribute must also be set to null.

    In the service output, if the order is routed, the RouteName attribute of the out_stops parameter contains the name of the route that the order is assigned to. Otherwise, the order is included in the out_unassigned_stops parameter.

  • Sequence: Indicates the sequence of the order on its assigned route. This attribute can be used to specify the relative sequence for an order on the route. It can contain a null value specifying that the order can be placed anywhere along the route. A null value can only occur together with a null RouteName value.

    The input sequence values are positive and unique for each route (shared across renewal depot visits, orders, and breaks), but do not need to start from 1 or be contiguous.

    In the service output, the Sequence attribute of the out_stops parameter contains the sequence value of the order on its assigned route. Output sequence values for a route are shared across depot visits, orders, and breaks; start from 1 (at the starting depot); and are consecutive. So the smallest possible output sequence value for a routed order is 2, since a route always begins at a depot

Syntax for specifying orders using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>, 
    },
    "features": [
        {
            "geometry": {
                "x": <x1>,
                "y": <y1>,
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "x": <x2>,
                "y": <y2>,
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying orders using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying orders in the default spatial reference WGS84 using JSON structure.

The order geometries are in the default spatial reference WGS84. Hence, the spatialReference property is not specified. The example also shows how to specify some attributes for the orders.

{
    "features": [
        {
            "geometry": {
                "x": 51.5254,
                "y": -0.1891
            },
            "attributes": {
                "Name": "Order 1",
                "TimeWindowStart1": null,
                "TimeWindowEnd1": "11:00 AM",
                "MaxViolationTime1": 0,
                "DeliveryQuantities": "2000 100"
            }
        },
        {
            "geometry": {
                "x": 51.5353,
                "y": -0.1744
            },
            "attributes": {
                "Name": "Order 2",
                "TimeWindowStart1": "10:00 AM",
                "TimeWindowEnd1": "11:00 AM",
                "MaxViolationTime1": 30,
                "DeliveryQuantities": "1500 75"
            }
        }
    ]
}
Example 2: Specifying orders in the Web Mercator spatial reference using JSON structure.

The order geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence the spatialReference property is required.

{
    "spatialReference": {
        "wkid": 102100
    },
    "features": [
        {
            "geometry": {
                "x": 2698533.989,
                "y": 5192521.476
            },
            "attributes": {
                "Name": "200156",
                "SpecialtyNames": "Forklift",
                "PickupQuantities": 1,
                "ServiceTime": 60,
                "CurbApproach": 3
            }
        },
        {
            "geometry": {
                "x": 2697821.094,
                "y": 5191915.261
            },
            "attributes": {
                "Name": "300242",
                "DeliveryQuantities": 1,
                "ServiceTime": 30
            }
        }
    ]
}
Example 3: Specifying orders using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

depots

Use this parameter to specify a location that a vehicle departs from at the beginning of its workday and returns to at the end of the workday. Vehicles are loaded (for deliveries) or unloaded (for pickups) at depots at the start of the route. In some cases, a depot can also act as a renewal location whereby the vehicle can unload or reload and continue performing deliveries and pickups. A depot has open and close times, as specified by a hard time-window. Vehicles can't arrive at a depot outside of this time window.

The depots parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the depot geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a depot and contains the following properties:

  • geometry: Specifies the depot geometry as a point containing x and y properties.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for depots

When specifying the orders, you can specify additional properties for orders such as their names or service times using attributes. The orders parameter can be specified with the following attributes:

  • Name: The name of the depot. The StartDepotName and EndDepotName attributes of the routes parameter reference the names you specify here. It is also referenced by the route_renewals parameter, when used. Depot names are case insensitive and have to be nonempty and unique.
  • TimeWindowStart1: The beginning time of the first time window for the depot. A null value indicates no beginning time.
  • TimeWindowEnd1: The ending time of the first window for the depot. A null value indicates no ending time.
  • TimeWindowStart2: The beginning time of the second time window for the depot. A null value indicates that there is no second time window.

    If the first time window is null, as specified by the TimeWindowStart1 and TimeWindowEnd1 attributes, the second time window must also be null. If both time windows are nonnull, they can't overlap. Also, the second time window must occur after the first.

  • TimeWindowEnd2: The ending time of the second time window for the depot. This field can contain a null value. When TimeWindowStart2 and TimeWindowEnd2 are both null, there is no second time window. When TimeWindowStart2 is not null but TimeWindowEnd2 is null, there is a second time window that has a starting time but no ending time. This is valid input.

The value for the TimeWindowStart1, TimeWindowEnd1, TimeWindowStart2, or TimeWindowEnd2 attributes can contain a time-only value or a date and time value. If the attributes have a time-only value (for example, 8:00 AM), the date is assumed to be the date specified by the default_date parameter. Using date and time values (for example, 7/11/2010 8:00 AM) allows you to set time windows that span multiple days.

The time value is interpreted as local to the time zone in which the street closest to the depot is located. If your depots span multiple time zones, you should specify the time window values as local time for each depot.

  • CurbApproach: Specifies the direction a vehicle may arrive at and depart from the depot. One of the integers listed in Coded value column in the following table must be specified as a value of this attribute. The values in the Setting column are the descriptive names for CurbApproach attribute values that you might have come across when using ArcGIS Network Analyst Extension software.

    Setting

    Coded value

    Description

    Either side of vehicle

    0

    The vehicle can approach and depart the depot in either direction, so a U-turn is allowed at the depot. This setting can be chosen if it is possible and desirable for your vehicle to turn around at the depot. This decision may depend on the width of the road and the amount of traffic or whether the depot has a parking lot where vehicles can pull in and turn around.

    Either side of vehicle
    All arrival and departure combinations are allowed with the Either side of vehicle curb approach.

    Right side of vehicle

    1

    When the vehicle approaches and departs the depot, the depot must be on the right side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the right hand side.

    Right side of vehicle
    The allowed arrival and departure combination for the Right side of vehicle curb approach.

    Left side of vehicle

    2

    When the vehicle approaches and departs the depot, the depot must be on the left side of the vehicle. A U-turn is prohibited. This is typically used for vehicles like busses that must arrive with the bus stop on the left hand side.

    Left side of vehicle
    The allowed arrival and departure combination for the Left side of vehicle curb approach.

    No U-Turn

    3

    When the vehicle approaches the depot, the depot can be on either side of the vehicle; however, when it departs, the vehicle must continue in the same direction it arrived in. A U-turn is prohibited.

    No U-turns
    The allowed arrival and departure combinations for the No U-Turn curb approach.

    The CurbApproach property was designed to work with both kinds of national driving standards: right-hand traffic (United States) and left-hand traffic (United Kingdom). First, consider an depot on the left side of a vehicle. It is always on the left side regardless of whether the vehicle travels on the left or right half of the road. What may change with national driving standards is your decision to approach from the right or left side. For example, if you want to arrive at an depot and not have a lane of traffic between the vehicle and the depot, you would choose Right side of vehicle in the United States but Left side of vehicle in the United Kingdom.

    Right side of vehicle with right-hand traffic.
    With right-hand traffic, the curb approach that leaves the vehicle closest to the stop is Right side of vehicle.
    Left side of vehicle with left-hand traffic
    With left-hand traffic, the curb approach that leaves the vehicle closest to the stop is Left side of vehicle.

  • Bearing: The direction in which a point representing the depot location is moving. The units are degrees and are measured in a clockwise fashion from true north. This attribute is used in conjunction with the BearingTol attribute.

    Bearing data is usually sent automatically from a mobile device that is equipped with a GPS receiver. Try to include bearing data if you are loading a depot that is moving, such as a pedestrian or a vehicle.

    Using this attribute tends to prevent adding locations to the wrong edges, which can occur when a vehicle is near an intersection or an overpass, for example. Bearing also helps the service determine which side of the street the point is on.

    For more information, refer to Bearing and BearingTol page.

  • BearingTol: The bearing tolerance value creates a range of acceptable bearing values when locating moving points on a street using the Bearing attribute. If the value from the Bearing attribute is within the range of acceptable values that are generated from the bearing tolerance on a street, the point can be added as a depot there; otherwise, the closest point on the next-nearest street is evaluated.

    The units are in degrees, and the default value is 30. Values must be greater than zero and less than 180.

    A value of 30 means that when the service attempts to add a depot on a street, a range of acceptable bearing values is generated 15º to either side of the street (left and right) and in both digitized directions of the street.

    For more information, refer to Bearing and BearingTol page.

  • NavLatency: Indicates how much time is expected to elapse from the moment GPS information is sent from a moving vehicle to a server and the moment the processed route is received by the vehicle's navigation device. This attribute is only used when finding routes if Bearing and BearingTol attributes also have values; however, entering a NavLatency value is optional, even when values are present for Bearing and BearingTol. NavLatency values are specified in minutes.
Syntax for specifying depots using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>, 
    },
    "features": [
        {
            "geometry": {
                "x": <x1>,
                "y": <y1>,
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "x": <x2>,
                "y": <y2>,
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying depots using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying depots in the default spatial reference WGS84 using JSON structure.

The depot geometries are in the default spatial reference WGS84. Hence, the spatialReference property is not specified. The example also shows how to specify some attributes for the depots.

{
    "features": [
        {
            "geometry": {
                "x": 51.5254,
                "y": -0.1891
            },
            "attributes": {
                "Name": "Depot1",
                "TimeWindowStart1": null,
                "TimeWindowEnd1": "1358362800000"
            }
        },
        {
            "geometry": {
                "x": 51.5353,
                "y": -0.1744
            },
            "attributes": {
                "Name": "Depot2",
                "TimeWindowStart1": "1358359200000",
                "TimeWindowEnd1": "1358362800000",
            }
        }
    ]
}
Example 2: Specifying depots in the Web Mercator spatial reference using JSON structure.

The depot geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence the spatialReference property is required.

{
    "spatialReference": {
        "wkid": 102100
    },
    "features": [
        {
            "geometry": {
                "x": 2698533.989,
                "y": 5192521.476
            },
            "attributes": {
                "Name": "400181",
                "CurbApproach": 3
            }
        },
        {
            "geometry": {
                "x": 2697821.094,
                "y": 5191915.261
            },
            "attributes": {
                "Name": "400161",
                "CurbApproach": 1
            }
        }
    ]
}
Example 3: Specifying depots using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

routes

Use this parameter to specify the routes that are available for the given vehicle routing problem. A route specifies vehicle and driver characteristics; in service response, it also represents the path between depots and orders.

A maximum of 2 routes can be specified for synchronous execution and 100 for asynchronous execution.

A route can have start and end depot service times, a fixed or flexible starting time, time-based operating costs, distance-based operating costs, multiple capacities, various constraints on a driver's workday, and so on.

The routes parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a route and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
NoteNote:

Unlike the orders or depots parameter, the JSON structure for the routes parameter does not have a geometry property.

Attributes for routes

When specifying the routes, you can specify additional properties for routes such as their names or capacities using attributes. The routes parameter can be specified with the following attributes:

  • Name: The name of the route. The name must be unique.

    The service generates a unique name if the attribute value is null. Therefore, specifying a value is optional in most cases. However, you must specify a name if your analysis includes breaks, route renewals, route zones, or orders that are preassigned to a route because the route name is used as a foreign key in these cases. Note that route names are case insensitive.

  • StartDepotName: The name of the starting depot for the route. This attribute is a foreign key to the Name attribute in the depots parameter and so the values must match.

    If the StartDepotName value is null, the route will begin from the first order assigned. Omitting the start depot is useful when the vehicle's starting location is unknown or irrelevant to your problem. However, when StartDepotName is null, EndDepotName cannot also be null.

    Virtual start depots are not allowed if orders/depots are in multiple time zones.

    If the route is making deliveries and StartDepotName is null, it is assumed the cargo is loaded on the vehicle at a virtual depot before the route begins. For a route that has no renewal visits, its delivery orders (those with nonzero DeliveryQuantities values in the orders parameter) are loaded at the start depot or virtual depot. For a route that has renewal visits, only the delivery orders before the first renewal visit are loaded at the start depot or virtual depot.

  • EndDepotName: The name of the ending depot for the route. This attribute is a foreign key to the Name attribute in the depots parameter and so the values must match.
  • StartDepotServiceTime: The service time at the starting depot. This can be used to model the time spent for loading the vehicle. This attribute can contain a null value; a null value indicates zero service time. The unit for this attribute value is specified by the time_units parameter.
  • EndDepotServiceTime: The service time at the ending depot. This can be used to model the time spent for unloading the vehicle. This attribute can contain a null value; a null value indicates zero service time. The unit for this attribute value is specified by the time_units parameter.

The service times at the start and end depots are fixed values (given by the StartDepotServiceTime and EndDepotServiceTime attribute values) and do not take into account the actual load for a route. For example, the time taken to load a vehicle at the starting depot may depend on the size of the orders. As such, the depot service times could be given values corresponding to a full truckload or an average truckload, or you could make your own time estimate.

  • EarliestStartTime: The earliest allowable starting time for the route. This is used by the service in conjunction with the time window of the starting depot for determining feasible route start times.

    This attribute can't contain null values and has a default time-only value of 8:00 AM; the default value is interpreted as 8:00 a.m. on the date given by the default_date parameter.

    The time zone for EarliestStartTime is the same as the time zone of the street on which the starting depot is located.

  • LatestStartTime: The latest allowable starting time for the route. This attribute can't contain null values and has a default time-only value of 10:00 AM; the default value is interpreted as 10:00 a.m. on the date given by the default_date parameter.

    The time zone for EarliestStartTime is the same as the time zone of the street on which the starting depot is located.

  • ArriveDepartDelay: Stores the amount of travel time needed to accelerate the vehicle to normal travel speeds, decelerate it to a stop, and move it off and on the network (for example, in and out of parking). By including an ArriveDepartDelay value, the service is deterred from sending many routes to service physically coincident orders.

    The cost for this attribute is incurred between visits to noncoincident orders, depots, and route renewals. For example, when a route starts from a depot and visits the first order, the total arrive/depart delay is added to the travel time. The same is true when traveling from the first order to the second order. If the second and third orders are coincident, the ArriveDepartDelay value is not added between them since the vehicle doesn't need to move. If the route travels to a route renewal, the value is added to the travel time again.

    Although a vehicle needs to slow down and stop for a break and accelerate afterwards, the service cannot add the ArriveDepartDelay value for breaks. This means that if a route leaves an order, stops for a break, and continues to the next order, the arrive/depart delay is added only once, not twice.

    To illustrate, assume there are five coincident orders in a high-rise building, and they are serviced by three different routes. This means three arrive/depart delays would be incurred; that is, three drivers would need to separately find parking places and enter the same building. However, if the orders could be serviced by just one route instead, only one driver would need to park and enter the building—only one arrive/depart delay would be incurred. Since the service tries to minimize cost, it will try to limit the arrive/depart delays and thus choose the single-route option. (Note that multiple routes may need to be sent when other constraints—such as specialties, time windows, or capacities—require it.)

    The unit for this attribute value is specified by the time_units parameter.

  • Capacities: The maximum capacity of the vehicle. You can specify capacity in any dimension you want, such as weight, volume, or quantity. You can even specify multiple dimensions, for example, weight and volume.

    Specify capacities without indicating units. For example, assume your vehicle can carry a maximum of 40,000 pounds; you would specify 40000 as the value for the Capacities attribute. You need to remember for future reference that the value is in pounds.

    If you are tracking multiple dimensions, separate the numeric values with a space. For instance, if you are recording both weight and volume and your vehicle can carry a maximum weight of 40,000 pounds and a maximum volume of 2,000 cubic feet, Capacities should be specified as 40000 2000. Again, you need to remember the units. You also need to remember the sequence the values and their corresponding units are specified in (pounds followed by cubic feet in this case).

    Remembering the units and the unit sequence is important for a couple of reasons: one, so you can reinterpret the information later; two, so you can properly enter values for the DeliveryQuantities and PickupQuantities attributes in the orders parameter. To elaborate on the second point, note that the service simultaneously refers to Capacities, DeliveryQuantities, and PickupQuantities attributes to make sure that a route doesn't become overloaded. Since units can't be entered in the field, the service can't make unit conversions, so you need to specify the values for the three attributes using the same units and the same unit sequence to ensure the values are correctly interpreted. If you mix units or change the sequence in any of the three attributes, you will get unwanted results without receiving any warning messages. Thus, it is a good idea to set up a unit and unit-sequence standard beforehand and continually refer to it whenever specifying values for these three attributes.

    An empty string or null value is equivalent to all values being zero. Capacitiy values can't be negative.

    If the Capacities string has an insufficient number of values in relation to the DeliveryQuantities or PickupQuantities attributes in the orders parameter, the remaining values are treated as zero.

    CautionCaution:

    The service only performs a simple Boolean test to determine whether capacities are exceeded. If a route's capacity value is greater than or equal to the total quantity being carried, the service will assume the cargo fits in the vehicle. This could be incorrect, depending on the actual shape of the cargo and the vehicle. For example, the service allows you to fit a 1,000-cubic-foot sphere into a 1,000-cubic-foot truck that is 8 feet wide. In reality, however, since the sphere is 12.6 feet in diameter, it won't fit in the 8-foot wide truck.

  • FixedCost: A fixed monetary cost that is incurred only if the route is used in a solution (that is, it has orders assigned to it). This attribute can contain null values; a null value indicates zero fixed cost. This cost is part of the total route operating cost.
  • CostPerUnitTime: The monetary cost incurred—per unit of work time—for the total route duration, including travel times as well as service times and wait times at orders, depots, and breaks. This attribute can't contain a null value and has a default value of 1.0. The unit for this attribute value is specified by the time_units parameter.
  • CostPerUnitDistance: The monetary cost incurred—per unit of distance traveled—for the route length (total travel distance). This attribute can contain null values; a null value indicates zero cost. The unit for this attribute value is specified by the distance_units parameter
  • OverTimeStartTime: The duration of regular work time before overtime computation begins. This attribute can contain null values; a null value indicates that overtime does not apply. The unit for this attribute value is specified by the time_units parameter.

    For example, if the driver is to be paid overtime pay when the total route duration extends beyond eight hours, OvertimeStartTime is specified as 480 (8 hours * 60 minutes/hour), given the time_units parameter is set to Minutes.

  • CostPerUnitOvertime: The monetary cost incurred per time unit of overtime work. This attribute can contain null values; a null value indicates that the CostPerUnitOvertime value is the same as the CostPerUnitTime value. The unit for this attribute value is specified by the time_units parameter.
  • MaxOrderCount: The maximum allowable number of orders on the route. This attribute can't contain null values and has a default value of 30.
  • MaxTotalTime: The maximum allowable route duration. The route duration includes travel times as well as service and wait times at orders, depots, and breaks. This attribute can contain null values; a null value indicates that there is no constraint on the route duration. The unit for this attribute value is specified by the time_units parameter.
  • MaxTotalTravelTime: The maximum allowable travel time for the route. The travel time includes only the time spent driving on the streets and does not include service or wait times. This attribute can contain null values; a null value indicates there is no constraint on the maximum allowable travel time. This attribute value can't be larger than the MaxTotalTime attribute value. The unit for this attribute value is specified by the time_units parameter.
  • MaxTotalDistance: The maximum allowable travel distance for the route. This attribute can contain null values; a null value indicates that there is no constraint on the maximum allowable travel distance. The unit for this attribute value is specified by the distance_units parameter.
  • SpecialtyNames: A space-separated string containing the names of the specialties supported by the route. A null value indicates that the route does not support any specialties. This attribute is a foreign key to the SpecialtyNames attribute in the orders parmeter and so the values must match.

    To illustrate what specialties are and how they work, assume a lawn care and tree trimming company has a portion of its orders that requires a bucket truck to trim tall trees. The company would specify BucketTruck as the value for the SpecialtyNames attribute for these orders to indicate their special need. SpecialtyNames would be left as null for the other orders. Similarly, the company would also specify BucketTruck as the value for the SpecialtyNames attribute for the routes that are driven by trucks with hydraulic booms. It would leave the attribute value as null for the other routes. When finding the solution, the service assigns orders without special needs to any route, but it only assigns orders that need bucket trucks to routes that have them.

  • AssignmentRule: Specifies whether the route can be used or not when solving the problem. The attribute value should be specified as one of the following integer values:
    • 1: The route is included when finding the solution. This is the default value.
    • 2: The route is excluded from the solution.
Syntax for specifying routes using JSON structure for features
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying routes using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying routes using JSON structure.

Unlike the depots and orders parameter the spatialReference and geometry properties are not required when specifying the routes parameter. The example also shows how to specify some attributes for the depots.

{
    "features": [
	       {
            "attributes": {
                "Name": "Truck1",
                "Capacities": "40000 2000",
                "StartDepotName": "Depot1", 
                "EndDepotName": "Depot1",
                "SpecialtyNames": "BucketTruck"
            }
        },
        {
            "attributes": {
                "Name": "Truck2",
                "Capacities": "30000 2500",
                "StartDepotName": "Depot2",
                "EndDepotName": "Depot2",
                "SpecialtyNames": null
            }
        }
    ]
}

default_date

Use this parameter to specify the date on which all of your routes start.

The parameter value should be specified as a numeric value representing the milliseconds since midnight January 1, 1970.

You can use the same value that you have specified for the EarliestStartTime attribute for each route feature in the routes parameter. If your routes start on different dates, you can pick any date from one of them.

token

Use this parameter to specify a token that provides the identity of a user that has the permissions to access the service. The accessing services page provides more information on how such an access token can be obtained.

f

Use this parameter to specify the response format. The parameter can have json or pjson as arguments, for example, f=json. The pjson value is used for printing the JSON response in a pretty format.

Optional parameters

travel_mode

Choose the mode of transportation for the analysis.

Travel modes are managed in ArcGIS Online and can be configured by the administrator of your organization to better reflect your organization's workflows. You need to specify the JSON object containing the settings for a travel mode supported by your organization. To get a list of supported travel modes, execute the GetTravelModes tool from the Utilities service.

The value for the travel_mode parameter should be a JSON object representing travel mode settings. When you use the GetTravelModes tool from the Utlities service, You get a string representing the travel mode JSON. You need to convert this string to a valid JSON object using your API and then pass the JSON object as the value for the travel_mode parameter.

For example, below is a string representating the Walking Time travel mode as returned by the GetTravelModes tool.

"{\"attributeParameterValues\": [{\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Walking\", \"value\": \"PROHIBITED\"}, {\"parameterName\": \"Restriction Usage\", \"attributeName\": \"Preferred for Pedestrians\", \"value\": \"PREFER_LOW\"}, {\"parameterName\": \"Walking Speed (km/h)\", \"attributeName\": \"WalkTime\", \"value\": 5}], \"description\": \"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.\", \"impedanceAttributeName\": \"WalkTime\", \"simplificationToleranceUnits\": \"esriMeters\", \"uturnAtJunctions\": \"esriNFSBAllowBacktrack\", \"restrictionAttributeNames\": [\"Preferred for Pedestrians\", \"Walking\"], \"useHierarchy\": false, \"simplificationTolerance\": 2, \"timeAttributeName\": \"WalkTime\", \"distanceAttributeName\": \"Miles\", \"type\": \"WALK\", \"id\": \"caFAgoThrvUpkFBW\", \"name\": \"Walking Time\"}"

The above value should be converted to a valid JSON object and passed as the value for the travel_mode parameter

travel_mode={"attributeParameterValues":[{"parameterName":"Restriction Usage","attributeName":"Walking","value":"PROHIBITED"},{"parameterName":"Restriction Usage","attributeName":"Preferred for Pedestrians","value":"PREFER_LOW"},{"parameterName":"Walking Speed (km/h)","attributeName":"WalkTime","value":5}],"description":"Follows paths and roads that allow pedestrian traffic and finds solutions that optimize travel time. The walking speed is set to 5 kilometers per hour.","impedanceAttributeName":"WalkTime","simplificationToleranceUnits":"esriMeters","uturnAtJunctions":"esriNFSBAllowBacktrack","restrictionAttributeNames":["Preferred for Pedestrians","Walking"],"useHierarchy":false,"simplificationTolerance":2,"timeAttributeName":"WalkTime","distanceAttributeName":"Miles","type":"WALK","id":"caFAgoThrvUpkFBW","name":"Walking Time"}

The default value,Custom, allows you to configure your own travel mode. When you pass in Custom, you can set values for the following parameters impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values.

The default values of the custom travel mode parameters model travelling by car. You may want to choose Custom and set the custom travel mode parameters listed above to model a pedestrian with a fast walking speed or a truck with a given height, weight, and cargo of certain hazardous materials. You may choose to do this to try out different settings to get desired analysis results. Once you have identified the analysis settings, you should work with your organization's administrator and save these settings as part of new or existing travel mode so that everyone in your organization can rerun the analysis with the same settings.

CautionCaution:

When the travel_mode parameter is not set to Custom, this means you are choosing a travel mode configured by your organization, and the service automatically overrides the values of other parameters with values that model the chosen travel mode. The following parameters are overridden:impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values.

If you set travel_mode to Custom, the service honors the default or user-defined values for the related parameters (impedance, uturn_at_junctions, use_hierarchy, route_line_simplification_tolerance, restrictions, and attribute_parameter_values) so you can create your own travel mode.

time_zone_usage_for_time_fields

Use this parameter to specify the time zone for the input date-time fields. This parameter specifies the time zone for the following fields: TimeWindowStart1, TimeWindowEnd1, TimeWindowStart2, TimeWindowEnd2, InboundArriveTime, and OutboundDepartTime on orders. TimeWindowStart1, TimeWindowEnd1, TimeWindowStart2, and TimeWindowEnd2 on depots. EarliestStartTime, and LatestStartTime on routes. TimeWindowStart, and TimeWindowEnd on breaks.

  • GEO_LOCAL—The date-time values associated with the orders or depots are in the time zone in which the orders and depots are located. For routes, the date-time values are based on the time zone in which the starting depot for the route is located. If a route does not have a starting depot all orders and depots across all the routes must be in a single time zone. For breaks, the date-time values are based on the time zone of the routes. For example, if your depot is located in an area that follows Eastern Standard Time and has the first time window values (specified as TimeWindowStart1 and TimeWindowEnd1) of 8 AM and 5 PM, the time window values will be treated as 8 AM and 5 PM in Eastern Standard Time.
  • UTC—The date-time values associated with the orders or depots are in the in the Coordinated Universal Time (UTC) and are not based on the time zone in which the orders or depots are located. For example, if your depot is located in an area that follows Eastern Standard Time and has the first time window values (specified as TimeWindowStart1 and TimeWindowEnd1) of 8 AM and 5 PM, the time window values will be treated as 12 PM and 9 PM in Eastern Standard Time assuming the Eastern Standard Time is obeying the Daylight Saving Time.

impedance

Specify the impedance.

CautionCaution:

The value of this parameter, regardless of whether you rely on its default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Custom.

Impedance is a value that quantifies travel along the transportation network. Travel distance is an example of impedance; it quantifies the length of walkways and road segments. Similarly, drive time—the typical time it takes to drive a car along a road segment—is an example of impedance. Drive times may vary by type of vehicle—for instance, the time it takes for a truck to travel along a path tends to be longer than a car—so there can be many impedance values representing travel times for different vehicle types. Impedance values may also vary with time; live and historical traffic reference dynamic impedance values. Each walkway and road segment stores at least one impedance value. When performing a network analysis, the impedance values are used to calculate the best results, such as finding the shortest route—the route that minimizes impedance—between two points.

The impedance parameter can be specified using the following values:

  • Drive Time—Models travel times for a car. These travel times can be dynamic, fluctuating according to traffic flows, in areas where traffic data is available.
  • Truck Time (default)—Models travel times for a truck. These travel times are static for each road and don't fluctuate with traffic.
  • Walk Time—Models travel times for a pedestrian. The default walking speed is 5 kilometers per hour (3.1 miles per hour), but you can change that speed through the attribute_parameter_values parameter by setting Walking Speed (km/h) to a different value.

breaks

Use this parameter to specify the rest periods, or breaks, for the routes in a given vehicle routing problem. A break is associated with exactly one route, and it can be taken after completing an order, while en route to an order, or prior to servicing an order. It has a start time and a duration, for which the driver may or may not be paid. There are three options for establishing when a break begins: using a time window, a maximum travel time, or a maximum work time.

  • Time-window break: To set up a time-window break, you enter two time-of-day values to delimit a time range in which the break should begin. The TimeWindowStart and TimeWindowEnd attributes hold the bounding time-of-day values. The duration, or service time, of the break is independent of the time window and, therefore, can extend beyond the end of the time window. For instance, if the time window for an hour-long break spans from 10:00 a.m. to 10:15 a.m., the break should start after 10:00 a.m. but before 10:15 a.m. If it starts at 10:10 a.m., the break will end at 11:10 a.m.
  • Maximum-travel-time break: With this kind of break, you specify how long a person can drive before the break is required. (Note that only travel time is limited, not other times like wait and service times.) If you enter four hours into the first break's MaxTravelTimeBetweenBreaks property, for example, the driver will receive a break before the accumulated travel time from the start of the route exceeds four hours. For any subsequent breaks, the travel time is accumulated from the previous break. So if you have a second break with a MaxTravelTimeBetweenBreaks value of two hours, the second break will be taken before two hours of travel time have been accumulated from the previous break, not from the start depot. A route's final maximum-travel-time break not only limits the amount of accumulated travel time from the previous break or start of the route but also limits the travel time from the final break to the end depot. This is true even if there is only one break. The VRP service is designed this way to prevent a route from taking all its breaks, then traveling for an extended period without taking another break. In the last example, MaxTravelTimeBetweenBreaks was set to two hours. If this is the route's final break, the route must be able to reach the end depot within two hours of travel time from the final break; otherwise, the service will return an error.
  • Maximum-work-time break: This break specifies how long a person can work before a break is required. Unlike maximum-travel-time breaks, which can accumulate travel time from the end of the last break, maximum-work-time breaks always accumulate work time from the beginning of the route, including any service time at the start depot. Note that this break limits the accumulated work time, which includes travel time and all service times; it excludes wait time, however.

The breaks parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a break and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
NoteNote:

Unlike the orders or depots parameter, the JSON structure for the breaks parameter does not have a geometry property.

Attributes for breaks

When specifying the breaks, you can specify additional properties for breaks such as their time windows or duration using attributes. The breaks parameter can be specified with the following attributes:

  • RouteName: The name of the route that the break applies to. Although a break is assigned to exactly one route, many breaks can be assigned to the same route. This attribute is a foreign key to the Name attribute in the routes parameter and so the values must match. The attribute can not have a null value.
  • Precedence: Specify the values to sequence the breaks of a given route. Breaks with a precedence value of 1 occur before those with a value of 2, and so on. All breaks must have a precedence value, regardless of whether they are time-window, maximum-travel-time, or maximum-work-time breaks. The default value for this attribute is 1.
  • ServiceTime: The duration of the break. The units for this attribute value is specified by the time_units parameter. This attribute can contain null values; a null value indicates no service time. The default value for this attribute is 60.
  • TimeWindowStart: The starting time of the break's time window. Specifying this attribute indicates that the service should consider the breaks as time-window breaks. The attribute value is specified as a numeric value representing the milliseconds since midnight January 1, 1970. The time zone for the TimeWindowStart attribute is assumed to be the same as the time zone of the street on which the starting depot is located.

    If this attribute is null and TimeWindowEnd attribute has a valid time-of-day value, the break is allowed to start anytime before the TimeWindowEnd value.

    The default value for this attribute is null.

  • TimeWindowEnd: The ending time of the break's time window. Specifying this attribute indicates that the service should consider the breaks as time-window breaks. The attribute value is specified as a numeric value representing the milliseconds since midnight January 1, 1970. The time zone for the TimeWindowEnd attribute is assumed to be the same as the time zone of the street on which the starting depot is located.

    If this attribute is null and TimeWindowStart attribute has a valid time-of-day value, the break is allowed to start anytime after the TimeWindowStart value.

    The default value for this attribute is null.

CautionCaution:

If either the TimeWindowStart or the TimeWindowEnd attributes have values, the MaxTravelTimeBetweenBreaks and MaxCumulWorkTime attributes must be null; moreover, all other breaks must have null values for MaxTravelTimeBetweenBreaks and MaxCumulWorkTime attributes for the request to succeed. The service will also return an error if a route has multiple breaks with overlapping time windows.

  • MaxViolationTime: Specifies the maximum allowable violation time for a time-window break. A time window is considered violated if the arrival time falls outside the time range. The units for this attribute value is specified by the time_units parameter.

    A zero value indicates the time window cannot be violated; that is, the time window is hard. A nonzero value specifies the maximum amount of lateness; for example, the break can begin up to 30 minutes beyond the end of its time window, but the lateness is penalized as per the time_window_factor parameter. A null value indicates that there is no limit on the allowable violation time.

    CautionCaution:

    For the request to succeed, If MaxTravelTimeBetweenBreaks or MaxCumulWorkTime has a value, MaxViolationTime must be null.

    The default value for this attribute is null.

  • MaxTravelTimeBetweenBreaks: The maximum amount of travel time that can be accumulated before the break is taken. Specifying this attribute indicates that the service should consider the breaks as travel time breaks. The travel time is accumulated either from the end of the previous break or, if a break has not yet been taken, from the start of the route. If this is the route's final break, this attribute also indicates the maximum travel time that can be accumulated from the final break to the end depot.

    The MaxTravelTimeBetweenBreaks attribute is designed to limit how long a person can drive until a break is required. For instance, if the time_units parameter is set to Minutes, and MaxTravelTimeBetweenBreaks has a value of 120, the driver will get a break after two hours of driving. To assign a second break after two more hours of driving, the second break's MaxTravelTimeBetweenBreaks attribute value should be 120.

    The units for this attribute value is specified by the time_units parameter. The default value for this attribute is null.

    CautionCaution:

    For the request to succeed, If the MaxTravelTimeBetweenBreaks attribute has a value, TimeWindowStart, TimeWindowEnd, MaxViolationTime, and MaxCumulWorkTime attributes must be null.

  • MaxCumulWorkTime: The maximum amount of work time that can be accumulated before the break is taken. Specifying this attribute indicates that the service should consider the breaks as work time breaks. Work time is always accumulated from the beginning of the route. Work time is the sum of travel time and service times at orders, depots, and breaks. Note, however, that this excludes wait time, which is the time a route (or driver) spends waiting at an order or depot for a time window to begin.

    The MaxCumulWorkTime attribute is designed to limit how long a person can work until a break is required. For instance, if the time_units parameter is set to Minutes, MaxCumulWorkTime attribute has a value of 120, and the ServiceTime attribute has a value of 15, the driver will get a 15-minute break after two hours of work. If a second break is needed after three more hours of work, you would specify 315 (five hours and 15 minutes) as the second break's MaxCumulWorkTime value. This number includes the MaxCumulWorkTime and ServiceTime values of the preceding break, along with the three additional hours of work time before granting the second break. To avoid taking maximum-work-time breaks prematurely, remember that they accumulate work time from the beginning of the route and that work time includes the service time at previously visited depots, orders, and breaks.

    The units for this attribute value is specified by the time_units parameter. The default value for this attribute is null.

    CautionCaution:

    For the request to succeed, If the MaxCumulWorkTime attribute has a value, TimeWindowStart, TimeWindowEnd, MaxViolationTime, and MaxTravelTimeBetweenBreaks attributes must be null.

  • IsPaid: Specify whether the break is paid or unpaid. The attribute value is specified as an integer with possible values being 0 or 1. A value of 1 indicates that the time spent at the break is included in the route cost computation and overtime determination. A value of 0 indicates otherwise. The default value for this attribute is 1.
  • Sequence: Indicates the relative sequence of the break on its route. The attribute values must be positive and unique for each route but need not start from 1 or be contiguous. In the service output, the Sequence attribute of the out_stops parameter contains the sequence value of the break on its route This attribute can have null values specifying that the break can be placed anywhere along the route. The default value for this attribute is null.
  • ArriveTimeUTC:The date and time value indicating the arrival time in Coordinated Universal Time (UTC).
  • DepartTimeUTC:The date and time value indicating the departure time in Coordinated Universal Time (UTC).
Syntax for specifying breaks using JSON structure for features
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying breaks using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying time-window based breaks using JSON structure.

This example shows how to specify time-window based breaks by specifying the values for the TimeWindowStart and the TimeWindowEnd attributes. The input vehicle routing problem requires that each of three routes needs to have one 30 minute paid break between 12:30 PM and 1:30 PM. The break time window is rigid. So the break has to start between 12:30 PM and 1:30 PM and cannot start after 1:30 PM.

We need to specify one break for each route. So we have a total of three features. We specify the appropriate milliseconds since January 1, 1970 for 12:30 PM on April 23, 2013 Pacific Time as the value for the TimeWindowStart attribute and the appropriate milliseconds since January 1, 1970 for 1:30 PM on April 23, 2013 as the value for the TimeWindowEnd attribute. Since the break time window is rigid, we specify a value of 0 for the MaxViolationTime attribute. Since the break duration is 30 minutes, we specify a value of 30 for the ServiceTime attribute assuming the time_units parameter is set to Minutes. For each break we only specify the attribute values required to model the input scenario. The other attribute values are not specified as their default values are adequate in this scenario.

NoteNote:

Unlike the depots and orders parameter the spatialReference and geometry properties are not required when specifying the breaks parameter.

{
    "features": [
        {
            "attributes": {
                "RouteName": "Truck1",
                "TimeWindowStart": 1366745400000,
                "TimeWindowEnd": 1366749000000,
                "ServiceTime": 30,
                "MaxViolationTime": 0
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "TimeWindowStart": 1366745400000,
                "TimeWindowEnd": 1366749000000,
                "ServiceTime": 30,
                "MaxViolationTime": 0
            }
        },
        {
            "attributes": {
                "RouteName": "Truck3",
                "TimeWindowStart": 1366745400000,
                "TimeWindowEnd": 1366749000000,
                "ServiceTime": 30,
                "MaxViolationTime": 0
            }
        }
    ]
}
Example 2: Specifying travel time based breaks using JSON structure.

This example shows how to specify travel time based breaks by specifying the value for the MaxTravelTimeBetweenBreaks attribute. The input vehicle routing problem requires that the driver for each of the two routes needs to have one 15 minute unpaid break after two hours of driving and another unpaid break after an additional two hours of driving.

We need to specify two breaks for each route so we have a total of four features. The first break for each route has a precedence value of 1 and the second break has a precedence value of 2. As each break on the route needs to occur after two hours of travel time, we specify the MaxTravelTimeBetweenBreaks attribute value as 120 for both breaks on a route assuming that the time_units parameter is set to Minutes. Since the break duration is 15 minutes, we specify a value of 15 for the ServiceTime attribute. Since the break is unpaid we specify a value of 0 for IsPaid attribute. The other attribute values are not specified as their default values are adequate in this scenario.

{
    "features": [
        {
            "attributes": {
                "RouteName": "Truck1",
                "Precedence": 1,
                "ServiceTime": 15,
                "MaxTravelTimeBetweenBreaks": 120,
                "IsPaid": 0
            }
        },
        {
            "attributes": {
                "RouteName": "Truck1",
                "Precedence": 2,
                "ServiceTime": 15,
                "MaxTravelTimeBetweenBreaks": 120,
                "IsPaid": 0
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "Precedence": 1,
                "ServiceTime": 15,
                "MaxTravelTimeBetweenBreaks": 120,
                "IsPaid": 0
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "Precedence": 2,
                "ServiceTime": 15,
                "MaxTravelTimeBetweenBreaks": 120,
                "IsPaid": 0
            }
        }
    ]
}
Example 3: Specifying work time based breaks using JSON structure.

This example shows how to specify work time based breaks by specifying the value for the MaxCumulWorkTime attribute. The input vehicle routing problem requires that the driver for each of the two routes needs to have one 15 minute paid break after two hours of work time and a second 15 minute paid break after three hours of work time since the first break.

We need to specify two breaks for each route so we have a total of four features. The first break for each route has a precedence value of 1 and the second break has a precedence value of 2. As the first break on each route needs to occur after two hours of work, we specify the MaxCumulWorkTime attribute value as 120 for the first break on a route assuming that the time_units parameter is set to Minutes. As the second break is needed after three more hours of work, we specify 315 (five hours and 15 minutes) as the second break's MaxCumulWorkTime value. This number includes the MaxCumulWorkTime and ServiceTime values of the preceding break, along with the three additional hours of work time before granting the second break (120+15+180=315). Since the break duration is 15 minutes, we specify a value of 15 for the ServiceTime attribute. The other attribute values are not specified as their default values are adequate in this scenario.

{
    "features": [
        {
            "attributes": {
                "RouteName": "Truck1",
                "Precedence": 1,
                "ServiceTime": 15,
                "MaxCumulWorkTime": 120
            }
        },
        {
            "attributes": {
                "RouteName": "Truck1",
                "Precedence": 2,
                "ServiceTime": 15,
                "MaxCumulWorkTime": 315
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "Precedence": 1,
                "ServiceTime": 15,
                "MaxCumulWorkTime": 120
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "Precedence": 2,
                "ServiceTime": 15,
                "MaxCumulWorkTime": 315
            }
        }
    ]
}

time_units

Use this parameter to specify the time units for all time-based attribute values specified with different parameters. The parameter is specified using one of the following values: Seconds, Minutes, Hours, Days.

Many parameters in the vehicle routing problem request have attributes for storing time values, such as ServiceTime for the orders parameter and CostPerUnitTime for the routes parameter. To minimize data entry requirements, these attribute values don't include units. Instead, all time-based attribute values must be entered in the same units, and the time_units parameter is used to specify the units of those values.

NoteNote:

The time-based attributes in the output parameters also use the same units specified by this parameter.

The default value for this parameter is Minutes.

distance_units

Use this parameter to specify the distance units for all distance-based attribute values specified with different parameters. The parameter is specified using one of the following values: Miles, Kilometers, Feet, Yards, Meters, NauticalMiles.

Many parameters in the vehicle routing problem request have attributes for storing distance values, such as MaxTotalDistance and CostPerUnitDistance for the routes parameter. To minimize data entry requirements, these attribute values don't include units. Instead, all distance-based attribute values must be entered in the same units, and the distance_units parameter is used to specify the units of those values.

NoteNote:

The distance-based attributes in the output parameters also use the same units specified by this parameter.

The default value for this parameter is Miles.

uturn_policy

Use this parameter to restrict or permit the route from making U-turns at junctions.

CautionCaution:

The value of this parameter, regardless of whether you rely on its default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Custom.

In order to understand the parameter values, keep in mind that a junction is a point where only two streets intersect each other. If three or more streets intersect at a point, it is called as an intersection. The end of a culs-de-sac is called as the dead-end. The parameter can have the following values:

Parameter Value

Description

ALLOW_UTURNS

U-turns are permitted everywhere. Allowing U-turns implies that the vehicle can turn around at a junction and double back on the same street.

U-turns are allowed
U-turns are permitted at junctions with any number of adjacent streets.

ALLOW_DEAD_ENDS_AND_INTERSECTIONS_ONLY

U-turns are prohibited at junctions where exactly two adjacent streets meet.

U-turns allowed only at intersections and dead-ends
U-turns are permitted only at intersections or dead ends.

ALLOW_DEAD_ENDS_ONLY

U-turns are prohibited at all junctions and interesections and are permitted only at dead ends.

-turns allowed only at dead-ends
U-turns are permitted only at dead ends.

NO_UTURNS

U-turns are prohibited at all junctions, intersections and dead-ends. Note that even when this parameter value is chosen, the route can still make U-turns at stops. If you wish to prohibit U-turns even at the stops, you can set the appropriate value (3) for the CurbApproach attribute of the stops.

The default value for this parameter is ALLOW_UTURNS.

time_window_factor

Use this parameter to rate the importance of honoring time windows without causing violations. A time window violation occurs when a route arrives at an order, depot, or break after a time window has closed. The parameter is specified using one of the following values:

  • Low: Places more importance on minimizing drive times and less on arriving at stops on time. You may want to use this value if you have a growing backlog of service requests. For the purpose of servicing more orders in a day and reducing the backlog, you can choose Low even though customers might be inconvenienced with your late arrivals.
  • Medium: Balances the importance of minimizing drive times and arriving within time windows.
  • High: Places more importance on arriving at stops on time than on minimizing drive times. Organizations that make time-critical deliveries or that are very concerned with customer service would choose a value of High.

The vehicle routing problem solution can change according to the value you choose for the time_window_factor parameter. The next two graphics show the same set of orders and depots; however, the routes are not the same because different time_window_factor values were used. The graphic on the left shows the route that resulted from the time_window_factor parameter set to Low. The route is short, but it has a time window violation. If time_window_factor is set to High, the route meets all the time windows, but it is longer because it services the order with a time window first.

Low importance
Low importance
High importance
High importance

The default value for this parameter is Medium.

spatially_cluster_routes

Use this parameter to specify if orders assigned to an individual route are spatially clustered.

A parameter value of true indicates that the orders assigned to an individual route are spatially clustered by automatically creating dynamic seed points for all the routes. Clustering orders usually result in routes that cover a smaller area and don't intersect other routes as much, but the overall cost of the solution could be more. You might want to cluster orders to keep drivers in general neighborhoods or regions that they are familiar with, or you might want to have compartmentalized routes if they are easier for your organization to manage.

A parameter value of false indicates that the orders assigned to an individual route are not spatially clustered. Use this value if you have predefined work territories for the routes that are specified using the route_zones parameter.

The default value for this parameter is true.

route_zones

Use this parameter to specify areas that delineates work territories for given routes. A route zone is used to constrain routes to servicing only those orders that fall within or near the specified area. Here are some examples of when route zones may be useful:

  • Some of your employees don't have the required permits to perform work in certain states or communities. You can create a hard route zone so they only visit orders in areas where they meet the requirements.
  • One of your vehicles breaks down frequently so you want to minimize response time by having it only visit orders that are close to your maintenance garage. You can create a soft or hard route zone to keep the vehicle nearby.

The route_zones parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the route zone geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a route zone and contains the following properties:

  • geometry: Specifies the route zone geometry. The structure is based on ArcGIS REST polygon object. A polygon contains an array of rings. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers containing X and Y coordinate values at index 0 and 1 respectively.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for route_zones

When specifying the route_zones parameter, you can specify additional information about route zones, such as the name of the route to which the route zone applies, using attributes. The route_zones parameter can be specified with the following attributes:

  • RouteName: The name of the route to which this zone applies. A route zone can have a maximum of one associated route. This attribute is a foreign key to the Name attribute in the routes parameter and so the values must match. The attribute cannot have a null value.
  • IsHardZone: Specify if the route zone is hard or soft. The attribute value is specified as an integer with possible values being 0 or 1. A value of 1 indicates that the route zone is hard; that is, an order that falls outside the route zone area can't be assigned to the route. A value of 0 indicates that such orders can still be assigned, but the cost of servicing the order is weighted by a function that is based on the Euclidean distance from the route zone. Basically, this means that as the straight-line distance from the soft zone to the order increases, the likelihood of the order being assigned to the route decreases.
    NoteNote:

    Even though a route associated with a hard route zone can only service orders inside the route zone, other routes can still enter and service the orders inside the same zone. This is because route zones restrict the route, not the orders. If you want to assign all the orders in an area exclusively to one route, don't use route zones; instead, for all the orders in an area, change the RouteName attribute on the orders parameter to the proper route, and set the AssignmentRule attribute for the orders to 2.

Syntax for specifying route zones using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>    
    }
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ]
}
Syntax for specifying route zones using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying route zones using JSON structure.

The example shows how to add route zones associated with the routes in a vehicle routing problem. The two routes in the input vehicle routing problem are operated by vans that are only licensed to service orders in a predetermined area and so cannot service orders that are outside the route zone. Hence the IsHardZone attribute value is set to 1 to ensure that the vans are only assigned orders that are within the route zones.

The first zone is a single-part polygon feature made up of four points. The second zone is a two-part polygon feature in which both parts are made up of four points.The barrier geometries are in the default spatial reference, WGS84. Hence, the spatialReference property is not required.

{
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0634,
                            32.8442
                        ],
                        [
                            -97.0554,
                            32.84
                        ],
                        [
                            -97.0558,
                            32.8327
                        ],
                        [
                            -97.0638,
                            32.83
                        ],
                        [
                            -97.0634,
                            32.8442
                        ]
                    ]
                ]
            },
            "attributes": {
                "RouteName": "East Bay Route",
                "IsHardZone": 1
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0803,
                            32.8235
                        ],
                        [
                            -97.0776,
                            32.8277
                        ],
                        [
                            -97.074,
                            32.8254
                        ],
                        [
                            -97.0767,
                            32.8227
                        ],
                        [
                            -97.0803,
                            32.8235
                        ]
                    ],
                    [
                        [
                            -97.0871,
                            32.8311
                        ],
                        [
                            -97.0831,
                            32.8292
                        ],
                        [
                            -97.0853,
                            32.8259
                        ],
                        [
                            -97.0892,
                            32.8279
                        ],
                        [
                            -97.0871,
                            32.8311
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "North Bay Route",
                "IsHardZone": 1
            }
        }
    ]
}
Example 2: Specifying route zones using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

route_renewals

Use this parameter to specify the intermediate depots that routes can visit to reload or unload the cargo they are delivering or picking up. Specifically, a route renewal links a route to a depot. The relationship indicates the route can renew (reload or unload while en route) at the associated depot.

Route renewals can be used to model scenarios in which a vehicle picks up a full load of deliveries at the starting depot, services the orders, returns to the depot to renew its load of deliveries, and continues servicing more orders. For example, in propane gas delivery, the vehicle may make several deliveries until its tank is nearly or completely depleted, visit a refueling point, and make more deliveries.

Here are a few rules and options to consider when working with route renewals:

  • The reload/unload point, or renewal location, can be different from the start or end depot.
  • Each route can have one or many predetermined renewal locations.
  • A renewal location may be used more than once by a single route.
  • In some cases where there may be several potential renewal locations for a route, the closest available renewal location is chosen by the service.

The route_renewals parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a route renewal and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
NoteNote:

Unlike the orders or depots parameter, the JSON structure for the route_renewals parameter does not have a geometry property.

Attributes for route_renewals

When specifying the route renewals, you can specify additional properties for route renewals such as the route name or service time using attributes. The route_renewals parameter can be specified with the following attributes:

  • DepotName: The name of the depot where this renewal takes place. This attribute is a foreign key to the Name attribute in the depots parameter and so the values must match. The attribute can not have a null value.
  • RouteName: The name of the route that this renewal applies to. This attribute is a foreign key to the Name attribute in the routes parameter and so the values must match. The attribute can not have a null value.
  • ServiceTime: The service time for the renewal. This attribute can contain a null value; a null value indicates zero service time. The units for this attribute value is specified by the time_units parameter.
    NoteNote:

    The time taken to load a vehicle at a renewal depot may depend on the size of the vehicle and how full or empty the vehicle is. However, the service time for a route renewal is a fixed value and does not take into account the actual load. As such, the renewal service time should be given a value corresponding to a full truckload, an average truckload, or another time estimate of your choice.

  • Sequences: Specify the one or more sequence of visits to the renewal depot. This attribute can be used to preassign visits to the renewal depot. The attribute value is specified as a space seperated string of sequence values. The attribute can contain a null value; a null value indicates that the service will determine the best sequence to visit the renewal depot.
Syntax for specifying route renewals using JSON structure for features
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying route renewals using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying route renewals using JSON structure.

In this example, a distribution company makes deliveries from a central depot using two trucks. Overtime the distribution company also acquired two additional satellite distribution centers. These centers can be used by the trucks to renew their truckload while making their deliveries instead of returning to the main distribution center for renewal. So the new distribution centers are specified as route renewals when solving the vehicle routing problem and the service selects the best renewal locations that minimizes the total cost.

We need to specify two route renewal locations for each route. So we have a total of four route renewal features. We identify the depot location that can be used for renewal using theDepotName attribute. We specify the name of the route the renewal applies to using the RouteName attribute. As it takes 15 minutes to load the truck at the renewal location, we specify 15 as the value for the ServiceTime attribute assuming the time_units parameter is set to Minutes. The other attribute values are not specified as their default values are adequate in this scenario.

NoteNote:

Unlike the depots and orders parameter the spatialReference and geometry properties are not required when specifying the route_renewals parameter.

{
    "features": [
        {
            "attributes": {
                "RouteName": "Truck1",
                "DepotName": "800 Brush St",
                "ServiceTime": 15
            }
        },
        {
            "attributes": {
                "RouteName": "Truck1",
                "DepotName": "100 Old County Rd",
                "ServiceTime": 15
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "DepotName": "800 Brush St",
                "ServiceTime": 15
            }
        },
        {
            "attributes": {
                "RouteName": "Truck2",
                "DepotName": "100 Old County Rd",
                "ServiceTime": 15
            }
        }
    ]
}

order_pairs

Use this parameter to pair pickup and delivery orders so they are serviced by the same route.

Sometimes it is required that the pickup and delivery for orders be paired. For example, a courier company might need to have a route pick up a high-priority package from one order and deliver it to another without returning to a depot, or sorting station, to minimize delivery time. These related orders can be assigned to the same route with the appropriate sequence by using order pairs. Moreover, restrictions on how long the package can stay in the vehicle can also be assigned; for example, the package might be a blood sample that has to be transported from the doctor's office to the lab within two hours.

Some situations might require two pairs of orders. For example, suppose you want to transport a senior citizen from her home to the doctor and bring her back home. The ride from her home to the doctor is one pair of orders with a desired arrival time at the doctor, while the ride from the doctor back home is another pair with a desired pickup time.

The orders_pairs parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents an order pair and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
NoteNote:

Unlike the orders or depots parameter, the JSON structure for the order_pairs parameter does not have a geometry property.

Attributes for order_pairs

When specifying the order pairs, you can specify additional properties for order pairs such as the orders that should be paired together or the maximum transit time using attributes. The order_pairs parameter can be specified with the following attributes:

  • FirstOrderName: The name of the first order of the pair. This attribute is a foreign key to the Name attribute in the orders parameter and so the values must match. The attribute can not have a null value.
  • SecondOrderName: The name of the second order of the pair. This attribute is a foreign key to the Name attribute in the orders parameter and so the values must match. The attribute can not have a null value.
CautionCaution:

For the request to succeed, the first order in the pair must be a pickup order; that is, the value for its DeliveryQuantities attribute must be null. The second order in the pair must be a delivery order; that is, the value for its PickupQuantities attribute must be null. The quantity that is picked up at the first order must agree with the quantity that is delivered at the second order. As a special case, both orders may have zero quantities for scenarios where capacities are not used.

NoteNote:

The order quantities are not loaded or unloaded at depots.

  • MaxTransitTime: The maximum transit time for the pair. The transit time is the duration from the departure time of the first order to the arrival time at the second order. This constraint limits the time-on-vehicle, or ride time, between the two orders. When a vehicle is carrying people or perishable goods, the ride time is typically shorter than that of a vehicle carrying packages or nonperishable goods.

    Excess transit time (measured with respect to the direct travel time between order pairs) can be tracked and weighted by the service. Because of this, you can direct the service to take one of three approaches: (1) minimize the overall excess transit time, regardless of the increase in travel cost for the fleet; (2) find a solution that balances overall violation time and travel cost; and (3) ignore the overall excess transit time and, instead, minimize the travel cost for the fleet. By assigning an importance level for the excess_transit_factor parameter, you are in effect choosing one of these three approaches. Regardless of the importance level, the service will always return an error if the MaxTransitTime attribute value is surpassed.

    This attribute can contain null values; a null value indicates that there is no constraint on the ride time. The default value for this attribute is null.

Syntax for specifying order pairs using JSON structure for features
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying order pairs using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying order pairs using JSON structure.

In this example, a para transit company needs to find 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.

The hospital and patient locations are specifed as the orders parameter. The passengers have to be taken to a predetermined hospital. For each patient to hospital pair, we add a feature to the order_pairs parameter using patient name as the value for the FirstOrderName attribute and hospital name as the value for the SecondOrderName attribute. The maximum time in minutes the patients can sit in the van during a one-way trip is specified using the MaxTransitTime attribute.

NoteNote:

Unlike the depots and orders parameter the spatialReference and geometry properties are not required when specifying the order_pairs parameter.

{
    "features": [
        {
            "attributes": {
                "FirstOrderName": "Mark (Home)",
                "SecondOrderName": "Mark (Doctor)",
                "MaxTransitTime": 30
            }
        },
        {
            "attributes": {
                "FirstOrderName": "Tom (Home)",
                "SecondOrderName": "Tom (Doctor)",
                "MaxTransitTime": 20
            }
        },
        {
            "attributes": {
                "FirstOrderName": "Bob (Home)",
                "SecondOrderName": "Bob (Doctor)",
                "MaxTransitTime": 25
            }
        },
        {
            "attributes": {
                "FirstOrderName": "Tony (Home)",
                "SecondOrderName": "Tony (Doctor)",
                "MaxTransitTime": 15
            }
        }
    ]
}

excess_transit_factor

Use this parameter to rate the importance of reducing excess transit time of order pairs. Excess transit time is the amount of time exceeding the time required to travel directly between the paired orders. Excess time can be caused by driver breaks or travel to intermediate orders and depots.

Calculating excess transit time
Calculating excess transit time

The parameter is specified using one of the following values:

  • Low: The service tries to find a solution that minimizes overall solution cost, regardless of excess transit time. This value is commonly used with courier services. Since couriers transport packages as opposed to people, they don't need to worry about ride time. Using Low allows the couriers to service paired orders in the proper sequence and minimize the overall solution cost.
  • Medium: The service looks for a balance between reducing excess transit time and reducing the overall solution cost.
  • High: The service tries to find a solution with the least excess transit time between paired orders at the expense of increasing the overall travel costs. It makes sense to use this value if you are transporting people between paired orders and you want to shorten their ride time. This is characteristic of taxi services.

The vehicle routing problem solution can change according to the value you choose for the excess_transit_factor parameter. The next two graphics show the same set of orders and depots; however, the routes are not the same because different excess_transit_factor values were used. The graphic on the left shows the route that resulted when the excess_transit_factor parameter was set to Low. The overall route is short, but the travel time from the first order to its paired order, the airport, is long. If the excess_transit_factor is set to High, the route reduces the time between the first order and the airport while maintaining the same ride time to the airport for the order on the right; however, the overall cost of the route increases.

Low importance
Low importance (courier)
High importance (taxi)

The default value for this parameter is Medium.

point_barriers

Use this parameter to specify one or more points that act as temporary restrictions or represent additional time or distance that may be required to travel on the underlying streets. For example, a point barrier can be used to represent a fallen tree along a street or time delay spent at a railroad crossing.

CautionCaution:

The service imposes a limit of 250 points that can be passed as barriers. If the value is exceeded, the response returns an error message.

The point_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the barrier geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a point barrier and contains the following properties:

  • geometry: Specifies the barrier geometry as a point containing x and y properties.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for point_barriers

When specifying the point_barriers parameter you can specify additional information about barriers, such as the barrier type, using attributes. The point_barriers parameter can be specified with the following attributes:

  • Name: The name of the barrier.
  • BarrierType: Specifies whether the point barrier restricts travel completely or adds time or distance when it is crossed. The value for this attribute is specified as one of the following integers.
    • 0 - Prohibits traversing through the barrier. The barrier is referred to as restriction point barrier since it acts as a restriction. This is the default value.
      Two maps demonstrate how a restriction point barrier affects finding the best route.
      The map on the left shows the shortest path between two stops without any restriction point barriers. The map on the right has a road that is blocked by a fallen tree, so the shortest path between the same points is longer.
    • 2 - Traveling through the barrier increases the travel time or distance by the amount specified as the value for Additional_Time or Additional_Distance attributes. This barrier type is referred to as an added cost point barrier.
      Two maps demonstrate how added cost barriers affect finding the best route.
      The map on the left shows the shortest path between two stops without any added cost point barrier. For the map on the right, the travel time from stop one to stop two would be the same whether going around the north end of the block or the south end; however, since crossing railroad tracks incurs a time penalty (modeled with added cost point barriers), the route with only one railroad crossing is chosen. The cost of crossing the barrier is added to the accumulated travel time of the resulting route.
      NoteNote:

      There is no point barrier type with a value of 1 for the BarrierType attribute.

  • Additional_Time: Indicates how much travel time is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero and the units for the attribute value are specified by the time_units parameter.
  • Additional_Distance: Indicates how much distance is added when the barrier is traversed. This attribute is applicable only for added-cost barriers. The attribute value must be greater than or equal to zero and the units for the attribute value are specified by the distance_units parameter.

Syntax for specifying point_barriers using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>, 
    },
    "features": [
        {
            "geometry": {
                "x": <x1>,
                "y": <y1>,
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "x": <x2>,
                "y": <y2>,
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying point_barriers using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying added cost point barrier in the default spatial reference WGS84 using JSON structure.

This example shows how to use an added cost point barrier to model a 5-minute delay at a rail road crossing. The BarrierType attribute is used to specify that the point barrier is of type added cost and the Additional_Time attribute is used to specify the delay in minutes. The barrier geometries are in the default spatial reference WGS84. Hence, the spatialReference property is not specified.

{
    "features": [
        {
            "geometry": {
                "x": -122.053461,
                "y": 37.541479
            },
            "attributes": {
                "Name": "Haley St rail road crossing",
                "BarrrierType": 2,
                "Additional_Time": 5
            }
        }
    ]
}
Example 2: Specifying restriction point barriers in the Web Mercator spatial reference using JSON structure.

This example shows how to use a restriction point barrier to model a road that is blocked by a fallen tree.The barrier geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence the spatialReference property is required.

{
    "spatialReference": {
        "wkid": 102100
    },
    "features": [
        {
            "geometry": {
                "x": -13635398.9398,
                "y": 4544699.034400001
            },
            "attributes": {
                "Name": "Fallen tree at 123 Main St", 
                "BarrierType": 0
            }
        }
    ]
}
Example 3: Specifying point barriers using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver6.arcgisonline.com/arcgis/rest/services/NetworkAnalysis/SanDiego/MapServer/21/query?where=1%3D1&outFields=Name&f=json"
}

line_barriers

Use this parameter to specify one or more lines that prohibit travel anywhere the lines intersect the streets. For example, a parade or protest that blocks traffic across several street segments can be modeled with a line barrier. A line barrier can also quickly fence off several roads from being traversed, thereby channeling possible routes away from undesirable parts of the street network.

Two maps demonstrate how a line barrier affects finding a route between two stops.
The map on the left displays the shortest path between two stops. The map on the right shows the shortest path when several streets are blocked by a line barrier.

CautionCaution:

The service imposes a limit on the number of streets you can restrict using line_barriers parameter. While there is no limit on number of lines you can specify as line barriers, the combined number of streets intersected by all the lines should not exceed 500. If the value is exceeded, the response returns an error message.

The line_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the barrier geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a line barrier and contains the following properties:

  • geometry: Specifies the barrier geometry. The structure is based on ArcGIS REST polyline object. A polyline contains an array of paths. Each path is represented as an array of points, and each point in the path is represented as an array of numbers containing X and Y coordinate values at index 0 and 1 respectively.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for line_barriers

The line_barriers parameter can be specified with the following attributes:

  • Name: The name of the line barrier.

Syntax for specifying line barriers using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>, 
    },
    "features": [
        {
            "geometry": {
                "paths": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
		{
            "geometry": {
                "paths": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ], 
}
Syntax for specifying line barriers using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying line barriers using JSON structure in Web Mercator spatial reference.

The example shows how to add two lines as line barriers to restrict travel on the streets intersected by the lines. Barrier 1 is a single-part line feature made up of two points. Barrier 2 is a two-part line feature. The first part is made up of three points, and the second part is made up of two points. The barrier geometries are in the Web Mercator spatial reference and not in the default WGS84 spatial reference. Hence, the spatialReference property is required.

{
    "spatialReference": {
        "wkid": 102100
    },
    "features": [
        {
            "geometry": {
                "paths": [
                    [
                        [
                            -10804823.397,
                            3873688.372
                        ],
                        [
                            -10804811.152,
                            3873025.945
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Barrier 1"
            }
        },
        {
            "geometry": {
                "paths": [
                    [
                        [
                            -10804823.397,
                            3873688.372
                        ],
                        [
                            -10804807.813,
                            3873290.911
                        ],
                        [
                            -10804811.152,
                            3873025.945
                        ]
                    ],
                    [
                        [
                            -10805032.678,
                            3863358.76
                        ],
                        [
                            -10805001.508,
                            3862829.281
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Barrier 2"
            }
        }
    ]
}
Example 2: Specifying line barriers using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/6/query?where=1%3D1&returnGeometry=true&f=json"
}

polygon_barriers

Use this parameter to specify polygons that either completely restrict travel or proportionately scale the time or distance required to travel on the streets intersected by the polygons.

CautionCaution:

The service imposes a limit on the number of streets you can restrict using the polygon_barriers parameter. While there is no limit on number of polygons you can specify as the polygon barriers, the combined number of streets intersected by all the polygons should not exceed 2,000. If the value is exceeded, the response returns an error message.

The polygon_barriers parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • spatialReference: Specifies the spatial reference for the barrier geometries. This property is not required if the coordinate values are in the default spatial reference WGS84. If the coordinate values are in a different spatial reference, you need to specify the well-known ID (WKID) for the spatial reference. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents a polygon barrier and contains the following properties:

  • geometry: Specifies the barrier geometry. The structure is based on ArcGIS REST polygon object. A polygon contains an array of rings. The first point of each ring is always the same as the last point. Each point in the ring is represented as an array of numbers containing X and Y coordinate values at index 0 and 1 respectively.
  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.

Attributes for polygon_barriers

When specifying the polygon_barriers parameter, you can specify additional information about barriers, such as the barrier type, using attributes. The polygon_barriers parameter can be specified with the following attributes:

  • Name: The name of the barrier.
  • BarrierType: Specifies whether the barrier restricts travel completely or scales the time or distance for traveling through it. The value for this attribute is specified as one of the following integers:
    • 0 - Prohibits traveling through any part of the barrier. The barrier is referred to as restriction polygon barrier since it prohibits traveling on streets intersected by the barrier. One use of this type of barrier is to model floods covering areas of the street that make traveling on those streets impossible. This is the default value.
      Two maps demonstrate how a restriction polygon barrier affects finding a route between two stops.
      The left side depicts the shortest path between two stops. On the right, a polygon barrier blocks flooded streets, so the shortest path between the same two stops is different.
    • 1 - Scales the time or distance required to travel the underlying streets by a factor specified using the Scaled_Time or Scaled_Distance attributes. If the streets are partially covered by the barrier, the travel time or distance is apportioned and then scaled. For example, a factor 0.25 would mean that travel on underlying streets is expected to be four times faster than normal. A factor of 3.0 would mean it is expected to take three times longer than normal to travel on underlying streets. This barrier type is referred to as scaled cost polygon barrier. It might be used to model storms that reduce travel speeds in specific regions.
      Two maps demonstrate how a scaled cost polygon barrier affects finding a route between two stops.
      The map on the left shows a route that goes through inclement weather without regard for the effect poor road conditions have on travel time. On the right, a scaled polygon barrier doubles the travel time of the roads covered by the storm. Notice the route still passes through the southern tip of the storm since it is quicker to spend more time driving slowly through a small part of the storm rather than driving completely around it. The service uses the modified travel time in calculating the best route; furthermore, the modified travel time is reported as the total travel time in the response.
  • Scaled_Time: This is the factor by which the travel time of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. The attribute value must be greater than zero. The default value is 1.
  • Scaled_Distance: This is the factor by which the distance of the streets intersected by the barrier is multiplied. This attribute is applicable only for scaled-cost barriers. The attribute value must be greater than zero. The default value is 1.

Syntax for specifying polygon barriers using JSON structure for features
{
    "spatialReference": {
        "wkid": <wkid>,
        "latestWkid": <wkid>    
    }
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            <x11>,
                            <y11>
                        ],
                        [
                            <x12>,
                            <y12>
                        ],
                        ...,
                        [
                            <x11>,
                            <y11>
                        ]
                    ],
                    [
                        [
                            <x21>,
                            <y21>
                        ],
                        [
                            <x22>,
                            <y22>
                        ],
                        ...,
                        [
                            <x21>,
                            <y21>
                        ]
                    ]
                ]
            },
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>
            }
        }
    ]
}
Syntax for specifying polygon barriers using URL returning a JSON response
{
    "url": "<url>"
}
Example 1: Specifying polygon barriers using JSON structure.

The example shows how to add two polygons as barriers. The first polygon named Flood zone is a restriction polygon barrier that prohibits travel on the underlying streets. The polygon is a single-part polygon feature made up of four points. The second polygon named Severe weather zone is a scaled-cost polygon barrier that reduces the travel time on underlying streets to one third of the original value. The polygon is a two-part polygon feature. Both parts are made up of four points.

The barrier geometries are in the default spatial reference, WGS84. Hence, the spatialReference property is not required.

{
    "features": [
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0634,
                            32.8442
                        ],
                        [
                            -97.0554,
                            32.84
                        ],
                        [
                            -97.0558,
                            32.8327
                        ],
                        [
                            -97.0638,
                            32.83
                        ],
                        [
                            -97.0634,
                            32.8442
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Flood zone",
                "BarrierType": 0
            }
        },
        {
            "geometry": {
                "rings": [
                    [
                        [
                            -97.0803,
                            32.8235
                        ],
                        [
                            -97.0776,
                            32.8277
                        ],
                        [
                            -97.074,
                            32.8254
                        ],
                        [
                            -97.0767,
                            32.8227
                        ],
                        [
                            -97.0803,
                            32.8235
                        ]
                    ],
                    [
                        [
                            -97.0871,
                            32.8311
                        ],
                        [
                            -97.0831,
                            32.8292
                        ],
                        [
                            -97.0853,
                            32.8259
                        ],
                        [
                            -97.0892,
                            32.8279
                        ],
                        [
                            -97.0871,
                            32.8311
                        ]
                    ]
                ]
            },
            "attributes": {
                "Name": "Severe weather zone",
                "BarrierType": 1,
                "Scaled_Time": 3
            }
        }
    ]
}
Example 2: Specifying polygon barrier using URL.

The URL makes a query for a few features from a map service. A URL querying features from a feature service can also be specified.

{
    "url": "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/MapServer/7/query?where=1%3D1&returnGeometry=true&f=json"
}

use_hierarchy_in_analysis

Use this parameter to specify if hierarchy should be used when finding the best routes for the fleet of vehicles.

CautionCaution:

The value of this parameter, regardless of whether you rely on its default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Custom.

A parameter value of true indicates that the service should use hierarchy. Using a hierarchy results in the service preferring higher-order streets such as freeways to lower-order streets such as local roads and can be used to simulate the driver preference of traveling on freeways instead of local roads even if that means a longer trip. This is especially true when finding routes for long distance orders, as the driver will usually prefer to travel on freeways as much as possible and avoid the local roads. Using hierarchy is computationally faster, especially for long distance routes, as the service has to select the best route from a relatively smaller subset of streets.

A parameter value of false indicates that the service should consider all the streets and not prefer higher-order streets when finding the route. This is often used when finding short-distance routes like assigning orders within a city.

The default value for this parameter is true.

CautionCaution:

The service automatically reverts to using hierarchy if the straight-line distance between the first two orders is greater than 50 miles even if you have specified to find the routes without using hierarchy.

restrictions

Use this parameter to specify which restrictions should be honored by the service. A restriction represents a driving preference or requirement. In most cases, restrictions cause roads or pathways to be prohibited, but they can also cause them to be avoided or preferred. For instance, using an Avoid Toll Roads restriction will result in a route that will include toll roads only when it is absolutely required to travel on toll roads in order to visit a stop. Height Restriction makes it possible to route around any clearances that are lower than the height of your vehicle. If you are carrying corrosive materials on your vehicle, using the Any Hazmat Prohibited restriction prevents hauling the materials along roads where it is marked as illegal to do so.

CautionCaution:

The value of this parameter, regardless of whether you rely on the default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Driving, so unless you set travel_mode to a different value, this parameter value will be overridden.

The service supports the restriction names listed in the following table:

NoteNote:

Some restrictions are supported only in certain countries as indicated by the Availability column in the table. A restriction is supported in a country if the Logistics Attribute column has a value of Yes in the list of supported countries. If you specify restriction names that are not available in the country where your input points are located, the service ignores the invalid restrictions and returns warning messages indicating the names for the restrictions that were not considered when making measurements.

NoteNote:

Sometimes you need to specify an additional value, the restriction attribute parameter, on a restriction to get the intended results. This value needs to be associated with the restriction name and a restriction parameter using attribute_parameter_values.

Restriction Name

Description

Availability

Any Hazmat Prohibited

The route will exclude roads where transporting any kind of hazardous material is prohibited.

Select countries in North America and Europe

Avoid Carpool Roads

The route will avoid roads designated exclusively for carpool (high-occupancy) vehicles.

All countries

Avoid Express Lanes

The route will avoid roads designated as express lanes.

All countries

Avoid Ferries

The route will avoid ferries.

All countries

Avoid Gates

The route will avoid roads where there are gates, such as keyed-access or guard-controlled entryways.

All countries

Avoid Limited Access Roads

The route will avoid roads designated as limited-access highways.

All countries

Avoid Private Roads

The route will avoid roads that are not publicly owned and maintained.

All countries

Avoid Toll Roads

The route will avoid toll roads.

All countries

Avoid Unpaved Roads

The route will avoid roads that are not paved (for example, dirt, gravel, etc.).

All countries

Avoid Truck Restricted Roads

The route will avoid roads where trucks are not allowed except when making deliveries.

All countries

Axle Count Restriction

The route will not include roads where trucks with the specified number of axles are prohibited. The number of axles can be specified using the Number of Axles restriction parameter.

Select countries in North America and Europe

Driving a Bus

The route will exclude roads where buses are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Driving a Delivery Vehicle

The route will exclude roads where delivery vehicles are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Driving a Taxi

The route will exclude roads where taxis are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Driving a Truck

The route will exclude roads where trucks are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Driving an Automobile

The route will exclude roads where automobiles are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Driving an Emergency Vehicle

The route will exclude roads where emergency vehicles are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Height Restriction

The route will exclude roads where the vehicle height exceeds the maximum allowed height for the road. The vehicle height can be specified using the Vehicle Height (meters) restriction parameter.

Select countries in North America and Europe

Kingpin to Rear Axle Length Restriction

The route will exclude roads where the vehicle kingpin-to-rear-axle length exceeds the maximum allowed for the road. The vehicle's length between the vehicle kingpin and the rear axle can be specified using the Vehicle Kingpin to Rear Axle Length (meters) restriction parameter.

Select countries in North America and Europe

Length Restriction

The route will exclude roads where the vehicle length exceeds the maximum allowed length for the road. The vehicle length can be specified using the Vehicle Length (meters) restriction parameter.

Select countries in North America and Europe

Preferred for Pedestrians

The route prefers paths designated for pedestrians.

All countries

Riding a Motorcycle

The route will exclude roads where motorcycles are prohibited. Using this restriction also ensures the route will honor one-way streets.

All countries

Roads Under Construction Prohibited

The route will exclude roads that are under construction.

All countries

Semi or Tractor with One or More Trailers Prohibited

The route will exclude roads where semis or tractors with one or more trailers are prohibited.

Select countries in North America and Europe

Single Axle Vehicles Prohibited

The route will exclude roads where vehicles with single axles are prohibited.

Select countries in North America and Europe

Tandem Axle Vehicles Prohibited

The route will exclude roads where vehicles with tandem axles are prohibited.

Select countries in North America and Europe

Through Traffic Prohibited

The route will exclude roads where through traffic (non-local) is prohibited.

All countries

Truck with Trailers Restriction

The route will exclude roads where trucks with the specified number of trailers on the truck are prohibited. The number of trailers on the truck can be specified using the Number of Trailers on Truck restriction parameter.

Select countries in North America and Europe

Use Preferred Hazmat Routes

The route will prefer roads designated for transporting any kind of hazardous materials.

Select countries in North America and Europe

Use Preferred Truck Routes

The route will prefer roads designated as truck routes, such as the roads that are part of the national network as specified by the National Surface Transportation Assistance Act in the United States, or roads that are designated as truck routes by the state or province, or or roads in an area that are generally more suitable for trucks.

Select countries in North America and Europe

Walking

The route will exclude roads where pedestrians are prohibited.

All countries

Weight Restriction

The route will exclude roads where the vehicle weight exceeds the maximum allowed weight for the road. The vehicle weight can be specified using the Vehicle Weight (kilograms) restriction parameter.

Select countries in North America and Europe

Weight per Axle Restriction

The route will exclude roads where the vehicle's weight per axle exceeds the maximum allowed for the road. The vehicle's weight per axle can be specified using the Vehicle Weight per Axle (kilograms) restriction parameter.

Select countries in North America and Europe

Width Restriction

The route will roads where the vehicle width exceeds the maximum allowed for the road. The vehicle width can be specified using the Vehicle Width(meters) restriction parameter.

Select countries in North America and Europe

LegacyLegacy:

Driving a Delivery Vehicle restriction attribute is deprecated and will be unavailable in future releases. To achieve similar results, use Driving a Truck restriction attribute along with Avoid Truck Restricted Roads restriction attribute.

The restrictions parameter value is specified as an array of restriction names. The default value for this parameter is restrictions=[Avoid Carpool Roads, Avoid Express Lanes, Avoid Gates, Avoid Private Roads, Avoid Unpaved Roads, Driving an Truck, Use Preferred Truck Routes, Roads Under Construction Prohibited, Through Traffic Prohibited]. A value of null indicates that no restrictions should be used when finding the best route, but only when travel_mode is set to Custom.

Example: restrictions=[Driving an Emergency Vehicle,Height Restriction,Length Restriction]

attribute_parameter_values

Use this parameter to specify additional values required by an attribute or restriction, such as to specify whether the restriction prohibits, avoids, or prefers travel on restricted roads. If the restriction is meant to avoid or prefer roads, you can further specify the degree to which they are avoided or preferred using this parameter.

CautionCaution:

The value of this parameter, regardless of whether you rely on its default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Custom.

The attributes_parameter_values parameter can be specified using a JSON structure that represents a set of features. The JSON structure can include the following properties:

  • url: Specify a REST query request to any ArcGIS Server feature, map, or geoprocessing service that returns a JSON feature set. This property is optional. However, either features or url must be specified.
  • features: Specify an array of features. This property is optional. However, either the features or url property must be specified.

Each feature in the features array represents an attribute parameter and contains the following properties:

  • attributes: Specify each attribute as a key-value pair where the key is the name of a given field, and the value is the attribute value for the corresponding field.
NoteNote:

The JSON structure for the attribute_parameter_values parameter does not have a geometry property.

Attributes for attribute_parameter_values

The attribute_parameter_values parameter can be specified with the following attributes:

  • AttributeName: Lists the name of the restriction.
  • ParameterName: Lists the name of the parameter associated with the restriction. A restriction can have one or more ParameterName values based on its intended use, which implies you may need multiple attribute_parameter_values parameters for a single attribute name.
  • ParameterValue: The value for the ParameterName that is used by the service when evaluating the restriction.

NoteNote:

In most cases, the attribute_parameter_values parameter is dependent on the restrictions parameter. The ParameterValue specified as part of attribute_parameter_values is applicable only if the restriction name is specified as the value for the restrictions parameter.

When specifying the attribute_parameter_values parameter, each restriction (listed as AttributeName) has a ParameterName value, Restriction Usage, that specifies whether the restriction prohibits, avoids, or prefers travel on the roads associated with the restriction and the degree to which the roads are avoided or preferred.

The Restriction Usage ParameterName can be assigned any of the following string values or their equivalent numeric values listed within the parentheses:

  • PROHIBITED (-1)—Travel on the roads using the restriction is completely prohibited.
  • AVOID_HIGH (5)—It is very unlikely for the service to include, in the results, roads that are associated with the restriction.
  • AVOID_MEDIUM (2)—It is unlikely for the service to include, in the results, roads that are associated with the restriction.
  • AVOID_LOW (1.3)—It is somewhat unlikely for the service to include, in the results, roads that are associated with the restriction.
  • PREFER_LOW (0.8)—It is somewhat likely for the service to include, in the results, results roads that are associated with the restriction.
  • PREFER_MEDIUM(0.5)—It is likely for the service to include, in the results, roads that are associated with the restriction.
  • PREFER_HIGH (0.2)—It is very likely for the service to include, in the results, roads that are associated with the restriction.

In most cases, you can use the default value, PROHIBITED, for Restriction Usage if the restriction is dependent on a physical vehicle characteristic, such as vehicle height. However, in some cases, the value for Restriction Usage depends on your travel preferences. For example, the Avoid Toll Roads restriction has the default value of AVOID_MEDIUM for the Restriction Usage parameter. This means that when the restriction is used, the service will try to route around toll roads when it can. AVOID_MEDIUM also indicates how important it is to avoid toll roads when finding the best route; it has a medium priority. Choosing AVOID_LOW would put lower importance on avoiding tolls; choosing AVOID_HIGH instead would give it a higher importance and thus make it more acceptable for the service to generate longer routes to avoid tolls. Choosing PROHIBITED would entirely disallow travel on toll roads, making it impossible for a route to travel on any portion of a toll road. Keep in mind that avoiding or prohibiting toll roads, and thus avoiding toll payments, is the objective for some; in contrast, others prefer to drive on toll roads because avoiding traffic is more valuable to them than the money spent on tolls. In the latter case, you would choose PREFER_LOW, PREFER_MEDIUM, or PREFER_HIGH as the value for Restriction Usage. The higher the preference, the farther the service will go out of its way to travel on the roads associated with the restriction.

The following table lists the restriction names and the default restriction parameter values for all the restrictions. The default value for the attribute_parameter_values parameter is the JSON structure containing all the rows from the table.

TipTip:

If you want to use the default value for any restriction, AttributeName, ParameterName, and ParameterValue do not have to be specified as part of the attribute_parameter_values parameter.

AttributeName

ParameterName

ParameterValue

Any Hazmat Prohibited

Restriction Usage

PROHIBITED

Avoid Carpool Roads

Restriction Usage

AVOID_HIGH

Avoid Express Lanes

Restriction Usage

AVOID_HIGH

Avoid Ferries

Restriction Usage

AVOID_MEDIUM

Avoid Gates

Restriction Usage

AVOID_MEDIUM

Avoid Limited Access Roads

Restriction Usage

AVOID_MEDIUM

Avoid Private Roads

Restriction Usage

AVOID_MEDIUM

Avoid Toll Roads

Restriction Usage

AVOID_MEDIUM

Avoid Truck Restricted Roads

Restriction Usage

AVOID_HIGH

Axle Count Restriction

Number of Axles

0

Restriction Usage

PROHIBITED

Driving a Bus

Restriction Usage

PROHIBITED

Driving a Delivery Vehicle

Restriction Usage

PROHIBITED

Driving a Taxi

Restriction Usage

PROHIBITED

Driving a Truck

Restriction Usage

PROHIBITED

Driving an Automobile

Restriction Usage

PROHIBITED

Driving an Emergency Vehicle

Restriction Usage

PROHIBITED

Height Restriction

Restriction Usage

PROHIBITED

Vehicle Height (meters)

0

Kingpin to Rear Axle Length Restriction

Restriction Usage

PROHIBITED

Vehicle Kingpin to Rear Axle Length (meters)

0

Length Restriction

Restriction Usage

PROHIBITED

Vehicle Length (meters)

0

Riding a Motorcycle

Restriction Usage

PROHIBITED

Roads Under Construction Prohibited

Restriction Usage

PROHIBITED

Semi or Tractor with One or More Trailers Prohibited

Restriction Usage

PROHIBITED

Single Axle Vehicles Prohibited

Restriction Usage

PROHIBITED

Tandem Axle Vehicles Prohibited

Restriction Usage

PROHIBITED

Through Traffic Prohibited

Restriction Usage

AVOID_HIGH

Truck with Trailers Restriction

Restriction Usage

PROHIBITED

Number of Trailers on Truck

0

Use Preferred Hazmat Routes

Restriction Usage

PREFER_MEDIUM

Use Preferred Truck Routes

Restriction Usage

PREFER_HIGH

Walking

Restriction Usage

PROHIBITED

WalkTime

Walking Speed (km/h)

5

Weight Restriction

Restriction Usage

PROHIBITED

Vehicle Weight (kilograms)

0

Weight per Axle Restriction

Restriction Usage

PROHIBITED

Vehicle Weight per Axle (kilograms)

0

Width Restriction

Restriction Usage

PROHIBITED

Vehicle Width (meters)

0

Syntax for specifying attribute_parameter_values
{
    "features": [
        {
            "attributes": {
                "<field1>": <value11>,
                "<field2>": <value12>,
                "<field3>": <value13>

            }
        },
        {
            "attributes": {
                "<field1>": <value21>,
                "<field2>": <value22>,
                "<field3>": <value13>
            }
        }
    ] 
}
Example: Specifying the vehicle height and weight and a high preference to use designated truck routes

This example shows how to specify the height and weight of the vehicle for use with the height and weight restrictions respectively along with a high preference to include designated truck routes. This results in a route that does not include any roads where the clearance under overpasses or through tunnels is less than the vehicle height. The results will also not include any roads with load limited bridges or local roads that prohibit heavy vehicles if the vehicle weight exceeds the maximum permissible weight. However, the route will include as many roads as possible that are designated as preferred truck routes.

Note that the Restriction Usage ParameterName for the Height Restriction and the Weight Restriction restrictions are not specified since we want to use the default value of PROHIBITED for these restriction parameters.

attribute_parameter_values=
{
    "features": [
        {
            "attributes": {
                "AttributeName": "Height Restriction",
                "ParameterName": "Vehicle Height (meters)",
                "ParameterValue": 4.12
            }
        },
        {
            "attributes": {
                "AttributeName": "Weight Restriction",
                "ParameterName": "Vehicle Weight (kilograms)",
                "ParameterValue": 36287
            }
        },
        {
            "attributes": {
                "AttributeName": "Use Preferred Truck Routes",
                "ParameterName": "Restriction Usage",
                "ParameterValue": "PREFER_HIGH"
            }
        }
    ]
}

populate_route_lines

Use this parameter to specify the shape of the output routes.

A parameter value of true specifies that the output routes will have the exact shape of the underlying streets that are included in the routes.

A parameter value of false specifies that no shape is generated for the output routes. You won't be able to generate driving directions if populate_route_lines parameter is set to false. Use this option if you are only interested in determining the assignment and sequence of orders to the routes and do not want route shapes that follow streets or generate driving directions. Use this option reduces the time taken by the service to solve the vehicle routing problem as the service has to perform relatively less computations.

The default value for this parameter is true.

route_line_simplification_tolerance

Use this parameter to specify by how much you want to simplify the route geometry returned by the service.

CautionCaution:

The value of this parameter, regardless of whether you rely on its default or explicitly set a value, is overridden when travel_mode is set to any other value than Custom. The default value for travel_mode is Custom.

Simplification maintains critical points on a route, such as turns at intersections, to define the essential shape of the route and removes other points. The simplification distance you specify is the maximum allowable offset that the simplified line can deviate from the original line. Simplifying a line reduces the number of vertices that are part of the route geometry. This reduces the overall response size and also improves the performance for drawing the route shapes in the applications.

The parameter is specified as a JSON structure that includes the following properties:

  • distance: The simplification distance value.
  • units: The units for the simplification distance value. The property value should be specified as one of the following values: esriCentimeters, esriDecimalDegrees, esriDecimeters, esriFeet, esriInches, esriKilometers, esriMeters, esriMiles, esriMillimeters, esriNauticalMiles, esriPoints, and esriYards.

The default value for the route_line_simplification_tolerance parameter is 10 meters.

Syntax for specifying route_line_simplification_tolerance
{
    "distance": <value>,
    "units": "<unit>"
}
Example: Specifying route_line_simplification_tolerance of 10 meters
{
    "distance": 10,
    "units": "esriMeters"
}

populate_directions

Use this parameter to specify if the service should generate driving directions for the routes that are included as part of the vehicle routing problem solution.

A parameter value of true indicates that the directions will be generated and configured based on the values for the directions_language, and the directions_style_name parameters.

A parameter value of false indicates that the directions are not generated and the service returns an empty value for the features property within the out_directions output parameter.

The default value for the parameter is false.

directions_language

Use this parameter to specify the language that should be used when generating driving directions. This parameter is used only when the populate_directions parameter is set to true. The parameter value can be specified using one of the following values:

  • ar - Generate directions in Arabic
  • cs - Generate directions in Czech
  • de - Generate directions in German
  • el - Generate directions in Greek
  • en (default) - Generate directions in English
  • es - Generate directions in Spanish
  • et - Generate directions in Estonian
  • fr - Generate directions in French
  • he - Generate directions in Hebrew
  • it - Generate directions in Italian
  • ja - Generate directions in Japanese
  • ko - Generate directions in Korean
  • lt - Generate directions in Lithuanian
  • lv - Generate directions in Latvian
  • nl - Generate directions in Dutch
  • pl - Generate directions in Polish
  • pt-BR - Generate directions in Brazilian Portuguese
  • pt-PT - Generate directions in Portuguese (Portugal)
  • ru - Generate directions in Russian
  • sv - Generate directions in Swedish
  • tr - Generate directions in Turkish
  • zh-CN - Simplified Chinese

NoteNote:

If an unsupported language code is specified, the service returns the directions using the default language, English.

directions_style_name

Use this parameter to specify the name of the formatting style for the directions. This parameter is used only when the populate_directions parameter is set to true. The parameter can be specified using the following values:

  • NA Desktop - Generates turn-by-turn directions suitable for printing.
  • NA Navigation - Generates turn-by-turn directions designed for an in-vehicle navigation device.

The default value for the parameter is NA Desktop.

env:outSR

Use this parameter to specify the spatial reference of the geometries such as the routes or the directions returned by the service. The parameter value can be specified as a well-known ID (WKID) for the spatial reference. If env:outSR is not specified, the geometries are returned in the default spatial reference WGS84. See Geographic coordinate systems and Projected coordinate systems to look up WKID values.

Many of the basemaps provided by ArcGIS Online are in the Web Mercator spatial reference (WKID 102100). Specifying env:outSR=102100 will return the geometries for the routes in the Web Mercator spatial reference and can be used to draw the routes on top of the basemaps.

save_route_data

Use this parameter to specify whether the service should create a zip file that contains a file geodatabase holding the inputs and outputs of the analysis in a format that can be used to share route layers with your portal.

  • true—Saves route data. The route data zip file can be downloaded from the URL provided as part of the output_route_data parameter.

  • false—Don't save route data. This is the default value.

save_output_network_analysis_layer

Use this parameter to specify if the service should save the analysis settings as a network analysis layer file. You cannot directly work with this file even when you open the file in an ArcGIS Desktop application like ArcMap. It is meant to be sent to Esri Technical Support in order to diagnose the quality of results returned from the service.

  • true—Saves network analysis layer file. The file can be downloaded from the URL provided as part of the output_network_analysis_layer parameter.

  • false—Don't save network analysis layer file. This is the default value.

overrides

Specify additional settings that can influence the behavior of the solver when finding solutions for the network analysis problems.

The value for this parameter needs to be specified in JavaScript Object Notation (JSON). The values can be either a number, Boolean, or a string.

{
"overrideSetting1" : "value1", 
"overrideSetting2" : "value2"
}

The default value for this parameter is no value, which indicates not to override any solver settings.

Overrides are advanced settings that should be used only after careful analysis of the results obtained before and after applying the settings. A list of supported override settings for each solver and their acceptable values can be obtained by contacting Esri Technical Support.

JSON response

The execution mode chosen for the service determines the way in which you can retrive the results from the service.

Outputs from synchronous execution

With the synchronous execution mode, the service returns a JSON response that contains any warning messages from the service execution as well as an array of results. Each result in this array contains the value for the output parameters returned by the service. If the request fails to execute, the response only contains the error property that contains the error messages. The examples in the subsequent section illustrate the response returned with specific request parameters.

JSON Response Syntax for successful request
{
    "results": [
        {
            "paramName": "<paramName1>",
            "dataType": "<dataType1>",
            "value": <valueLiteralOrObject1>
        },
        {
            "paramName": "<paramName2>",
            "dataType": "<dataType2>",
            "value": <valueLiteralOrObject2>
        }
    ],
    "messages": [
        {
            "type": "<type1>",
            "description": "<description1>"
        },
        {
            "type": "<type2>",
            "description": "<description2>"
        }
    ]
}
JSON response syntax for failed request.
{
    "error": {
        "code": <code>,
        "message": "<message>",
        "details": [
            "<details>"
        ]
    }
}

Outputs from asynchronous execution

With the asynchronous execution mode, the service assigns a unique job ID for the transaction. The job ID and the status of the job are returned in the response.

JSON response syntax from a request using asynchronous execution mode
{
    "jobId": <jobID>,
    "jobStatus": <jobStatus>
}

The jobStatus property can have the following values:

  • esriJobSubmitted
  • esriJobWaiting
  • esriJobExecuting
  • esriJobSucceeded
  • esriJobFailed
  • esriJobTimedOut
  • esriJobCancelling
  • esriJobCancelled

You can use the job ID to periodically check the status of the job and messages. Additionally if the job has successfully completed, you can use the job ID to retrive the results or even the inputs. The job information and results remain available for 24 hours after the job is done.

After the initial request is submitted you can make a request of the following form to get the status of the job

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/<yourJobID>?token=<yourToken>&returnMessages=true&f=json

JSON response syntax during job execution
{
    "jobId": "<jobId>",
    "jobStatus": "<jobStatus>",
    "messages": [
        {
            "type": "<type1>",
            "description": "<description1>"
        },
        {
            "type": "<type2>",
            "description": "<description2>"
        }
    ]
}

While a job is executing, you can cancel it by making a request of the form

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/<yourJobID>/cancel?token=<yourToken>&f=json

After the successful completion of the job, you can make a request of the following form to retrieve the outputs. Refer to the Output Parameters section for more information on how to interpret the solution provided by the service.

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/<yourJobID>/results/<output_parameter_name>?token=<yourToken>&f=json

You can also retrieve the value for any input parameter by making the requests of the the following form

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/<yourJobID>/inputs/<inputParameterName>?token=<yourToken>&f=json

Output parameters

Upon successful execution, the service returns the solution to the specified vehicle routing problem. The solution is made up of the following output parameters:

out_stops

Use this parameter to access information about stops made at depots, orders, and breaks. The information includes which routes make the stops, the arrival and departure times, and the stop sequence.

The following provides a description of attributes that are returned for each stop:

  • ObjectID: A unique identifier for the stop. This identifier is auto generated by the service.
  • Name: The name of the stop. The value of this attribute is same as the Name attribute of the depots, orders, or the breaks parameters from the request. You can use the StopType attribute to determine if the Name attribute value refers to a depot, order or a break.
  • PickupQuantities: The amount of cargo or number of people to be picked up from a stop. If multiple dimensions are delivered to a stop, each quantity is separated by a space.

    The units for the value of this attribute aren't stored. You should interpret the units according to the way in which you specified the Quantities attribute of the routes parameter in the request and the PickupQuantities and DeliveryQuantities attributes of the orders parameters in the request.

  • DeliveryQuantities: The amount of cargo or number of people to be delivered to a stop. If multiple dimensions are delivered to a stop, each quantity is separated by a space.

    The units for the value of this attribute aren't stored. You should interpret the units according to the way in which you specified the Quantities attribute of the routes parameter in the request and the PickupQuantities and DeliveryQuantities attributes of the orders parameters in the request.

  • StopType: Indicates whether the stop represents a depot, order, or break. The attribute value is an integer which can be interpreted in the following way:
    • 0: The stop is an order.
    • 1: The stop is depot.
    • 2: The stop is a break.
  • RouteName: The name of the route that makes the stop.
  • Sequence: The relative sequence in which the assigned route visits the stop.
TipTip:

The RouteName and Sequence attributes can be used to create an ordered lists of stops for each route.

  • FromPreviousTravelTime: The elapsed travel time from the route's previous stop to the current stop. The value is in the units specified by the time_units parameter.
  • FromPreviousDistance: The distance along the route from the previous stop to the current stop. The value is in the units specified by the distance_units parameter.
  • ArriveCurbApproach: Indicates which side of the vehicle the curb is on when arriving at the stop. A value of 1 means the right side of vehicle; 2 indicates the left side.
  • DepartCurbApproach: Indicates which side of the vehicle the curb is on when departing from the stop. A value of 1 means the right side of vehicle; 2 indicates the left side.
  • ArriveTime: The time of day when the route arrives at the stop. The time-of-day value for this attribute is in the time zone in which the stop is located.
  • DepartTime: The time of day when the route departs from the stop. The time-of-day value for this attribute is in the time zone in which the stop is located.
  • ArriveTimeUTC: The time of day when the route arrives at the stop. This value is given in Coordinated Universal Time (UTC).
  • DepartTimeUTC: The time of day when the route departs from the stop. This value is given in Coordinated Universal Time (UTC).
  • WaitTime: The wait time or layover at the stop. For example, a wait time is incurred when a route must wait at an order for a time window to open. The value is in the units specified by the time_units parameter.
  • ViolationTime: The amount of time elapsed from the end of the stop's time window to the arrival of the route vehicle. The value is in the units specified by the time_units parameter.
TipTip:

The out_stops parameter does not contain the geometry of the stops. In order to visualize the stops on a map, you can do the following

  • Use the StopType attribute to determine if the stop feature corresponds to a feature in the orders or depots parameters .
  • Use the Name attribute to find the feature with the same name in the orders or depots parameters.

The out_stops parameter is returned as a JSON feature set with following syntax:

Unlike the out_routes parameter, the out_stops parameter does not contain spatialReference or geometryType properties as this parameter does not return any geometry information about the stops.

{
    "paramName": "out_stops",
    "dataType": "GPRecordSet",
    "value": {
        "displayFieldName": "",
        "fields": [
            {
                "name": "<field1Name>",
                "type": "<field1Type>",
                "alias": "<field1Alias>",
                "length": "<field1Length>" //length is included only for esriFieldTypeString
            },
            {
                "name": "<field2Name>",
                "type": "<field2Type>",
                "alias": "<field2Alias>",
                "length": "<field2Length>"
            }
        ],
        "features": [
            {
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                }
            },
            {
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                }
            }
        ],
        "exceededTransferLimit": <true|false>
    }
}

The following shows an example of the out_stops parameter.

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "paramName": "out_stops",
    "dataType": "GPRecordSet",
    "value": {
        "displayFieldName": "",
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "Name",
                "type": "esriFieldTypeString",
                "alias": "Name",
                "length": 128
            },
            {
                "name": "PickupQuantities",
                "type": "esriFieldTypeString",
                "alias": "PickupQuantities",
                "length": 128
            },
            {
                "name": "DeliveryQuantities",
                "type": "esriFieldTypeString",
                "alias": "DeliveryQuantities",
                "length": 128
            },
            {
                "name": "StopType",
                "type": "esriFieldTypeSmallInteger",
                "alias": "StopType"
            },
            {
                "name": "RouteName",
                "type": "esriFieldTypeString",
                "alias": "RouteName",
                "length": 128
            },
            {
                "name": "Sequence",
                "type": "esriFieldTypeInteger",
                "alias": "Sequence"
            },
            {
                "name": "FromPrevTravelTime",
                "type": "esriFieldTypeDouble",
                "alias": "FromPrevTravelTime"
            },
            {
                "name": "FromPrevDistance",
                "type": "esriFieldTypeDouble",
                "alias": "FromPrevDistance"
            },
            {
                "name": "ArriveCurbApproach",
                "type": "esriFieldTypeInteger",
                "alias": "ArriveCurbApproach"
            },
            {
                "name": "DepartCurbApproach",
                "type": "esriFieldTypeInteger",
                "alias": "DepartCurbApproach"
            },
            {
                "name": "ArriveTime",
                "type": "esriFieldTypeDate",
                "alias": "ArriveTime",
                "length": 16
            },
            {
                "name": "DepartTime",
                "type": "esriFieldTypeDate",
                "alias": "DepartTime",
                "length": 16
            },
            {
                "name": "WaitTime",
                "type": "esriFieldTypeDouble",
                "alias": "WaitTime"
            },
            {
                "name": "ViolationTime",
                "type": "esriFieldTypeDouble",
                "alias": "ViolationTime"
            },
            {
                "name": "ArriveTimeUTC",
                "type": "esriFieldTypeDate",
                "alias": "ArriveTimeUTC",
                "length": 16
            },
            {
                "name": "DepartTimeUTC",
                "type": "esriFieldTypeDate",
                "alias": "DepartTimeUTC",
                "length": 16
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Store_1",
                    "PickupQuantities": "",
                    "DeliveryQuantities": "1706",
                    "StopType": 0,
                    "RouteName": "Truck_1",
                    "Sequence": 3,
                    "FromPrevTravelTime": 7.952569246292114,
                    "FromPrevDistance": 2.6272945531949463,
                    "ArriveCurbApproach": 0,
                    "DepartCurbApproach": 0,
                    "ArriveTime": 1355248198164,
                    "DepartTime": 1355249698164,
                    "WaitTime": 0,
                    "ViolationTime": 0,
                    "ArriveTimeUTC": 1355276998164,
                    "DepartTimeUTC": 1355278498164
                }
            },
            {
                "attributes": {
                    "ObjectID": 2,
                    "Name": "Store_2",
                    "PickupQuantities": "",
                    "DeliveryQuantities": "1533",
                    "StopType": 0,
                    "RouteName": "Truck_2",
                    "Sequence": 3,
                    "FromPrevTravelTime": 5.654368394985795,
                    "FromPrevDistance": 1.5515339440650768,
                    "ArriveCurbApproach": 0,
                    "DepartCurbApproach": 0,
                    "ArriveTime": 1355248059340,
                    "DepartTime": 1355249439341,
                    "WaitTime": 0,
                    "ViolationTime": 0,
                    "ArriveTimeUTC": 1355276859340,
                    "DepartTimeUTC": 1355278239341
                }
            },
            //.... additional stops
        ],
        "exceededTransferLimit": false
    }
}

out_routes

Use this parameter to access the drivers, vehicles, and vehicle route paths of a vehicle routing problem. The populate_route_lines and route_line_simplification_tolerance parameters highly influence the shape of the output routes. The route geometries are returned in the spatial reference specified as the env:outSR parameter.

The following provides a description of fields that are returned for each route:

  • ObjectID: A unique identifier for the route. This identifier is auto generated by the service.
  • Name: The name of the route.
  • ViolatedConstraints: Contains a summary of constraints that are violated when assigning the order to any of the routes. The service assigns a unique integer for each violated constraint. The ViolatedConstraints attribute value is an integer representing the sum of all the constraints that are violated by the route. In order to determine the individual constraints that are violated, you can treat the attribute value as a bit mask and derive the values for the individual bits. For instance, the combination of Capacities exceeded (2) and Hard route zone (128) is coded as 130 (2 +128).

    If a route causes a constraint to be violated, a combination of one or more of the violations listed below could be assigned to the ViolatedConstraints attribute.

    • MaxOrderCount exceeded (1): The preassigned orders can't be assigned to the route since assigning the orders would exceed the maximum number of orders that can be assigned to the route as specified by the MaxOrderCount attribute for the routes parameter.
    • Capacities exceeded (2): The preassigned orders can't be assigned to the route since assigning the orders would exceed the total route capacity as specified by the Capacities attribute for the routes parameter.
    • MaxTotalTime exceeded (4): The travel time from the start depot to the end depot plus the service and wait times at both depots and any break exceeds the total time for the route as specified by the MaxTotalTime attribute for the routes parameter.
    • MaxTotalTravelTime exceeded (8): The travel time from the start depot to the end depot exceeds the total travel time for the route as specified by the MaxTotalTravelTime attribute for the routes parameter.
    • MaxTotalDistance exceeded (16): The travel distance from the start depot to the end depot exceeds the total travel distance for the route as specified by the MaxTotalDistance attribute for the routes parameter.
    • Hard time window (32): There is a hard time window violation on the start depot, end depot, or break associated with the route.
    • Unmatched specialty (64): The specialties required by an order are not found on the target route.
    • Hard route zone (128): An order that was preassigned to the route does not fall within a hard route zone.
    • Order pair MaxTransitTime exceeded (256): There is an order pair preassigned to the route, and assigning the orders in the order pair would exceed the maximum transit time for the order pair as specified by the MaxTransitTime attribute for the order_pairs parameter.
    • Order pair violation (512): An order belongs to an order pair and can't be assigned to the preassigned route.
    • Unreachable (1024): A preassigned order is located on a street that cannot be reached by the route.
    • Cannot insert required break (2048): A break for the route has a null sequence value in the presence of preassigned orders, and the break can't be inserted anywhere without introducing other violations.
    • Cannot insert required renewal (4096): A route exceeds its capacity and needs to visit a route renewal; however, the associated route renewal has a null sequence value in the presence of preassigned orders and can't be inserted anywhere without introducing other violations.
    • MaxTravelTimeBetweenBreaks exceeded (8192): The solver was unable to insert a break within the time specified by the MaxTravelTimeBetweenBreaks attribute for the breaks parameter. This is often caused by preassigning a sequence to a break such that it can't be reached within the maximum travel time.

    • Break MaxCumulWorkTime exceeded (16384): The service was unable to insert a break within the time specified by the MaxCumulWorkTime attribute for the breaks parameter. This is often caused by preassigning a sequence to a break such that it can't be reached within the maximum work time.
  • OrderCount: The number of orders assigned to the route.
  • TotalCost: The total operating cost of the route, which is the sum of the following attribute values: FixedCost, RegularTimeCost, OvertimeCost, DistanceCost.
  • RegularTimeCost: The cost of regular work time, excluding any unpaid breaks.
  • OvertimeCost: The cost of overtime work, excluding any unpaid breaks.
  • DistanceCost: The distance cost component obtained by multiplying the TotalDistance and CostPerUnitDistance attribute values.
  • TotalTime: The total route duration. This includes travel times as well as service and wait times at orders, depots, and breaks. The value is in the units specified by the time_units parameter. The TotalTime value is the sum of the following attribute values:
    • StartDepotServiceTime
    • EndDepotServiceTime
    • TotalOrderServiceTime
    • TotalBreakServiceTime
    • TotalRenewalServiceTime
    • TotalWaitTime
    • TotalTravelTime
  • TotalOrderServiceTime: The total service time spent at all orders on the route. The value is in the units specified by the time_units parameter.
  • TotalBreakServiceTime: The total service time spent at all breaks on the route. The value is in the units specified by the time_units parameter.
  • TotalTravelTime: The total travel time for the route. The value is in the units specified by the time_units parameter.
  • TotalDistance: The total travel distance for the route. The value is in the units specified by the distance_units parameter.
  • StartTime: The starting time of the route. The route may start before the beginning of its start depot's time window, in which case there is a wait time at the starting depot. The time-of-day value for this attribute is in the time zone on which the starting depot is located.
  • EndTime: The ending time of the route. The route ends upon completion of service at the ending depot. The time-of-day value for this attribute is in the time zone on which the ending depot is located.
  • TotalWaitTime: The total wait time at all orders, depots, and breaks on the route. The value is in the units specified by the time_units parameter.
  • TotalViolationTime: The total violation time at all orders and breaks on the route. The value is in the units specified by the time_units parameter.
  • RenewalCount: For a route with renewals, this is equal to the number of visits to depots for the purpose of renewing a vehicle, that is, loading or unloading a vehicle.
  • TotalRenewalServiceTime: For a route with renewals, the total service time spent at all renewal visits on the route. The value is in the units specified by the time_units parameter.
  • Shape_Length: The length of the route in the units of the spatial reference specified for the routes. By default the length is reported in decimal degrees if the env:outSR parameter is not specified.
  • StartTimeUTC:The start time of the route in Coordinated Universal Time (UTC).
  • EndTimeUTC:The end time of the route in Coordinated Universal Time (UTC).

The out_routes parameter is returned as a JSON feature set with following syntax:

{
    "paramName": "out_Routes",
    "dataType": "GPFeatureRecordSetLayer",
    "value": {
        "displayFieldName": "",
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": <wkid>,
            "latestWkid": <wkid>,
            
        },
        "fields": [
            {
                "name": "<field1Name>",
                "type": "<field1Type>",
                "alias": "<field1Alias>",
                "length": "<field1Length>" //length is included only for esriFieldTypeString
            },
            {
                "name": "<field2Name>",
                "type": "<field2Type>",
                "alias": "<field2Alias>",
                "length": "<field2Length>"
            }
        ],
        "features": [
            {
                "geometry": {
                    "paths": [
                        [
                            [
                                <x11>,
                                <y11>
                            ],
                            [
                                <x12>,
                                <y12>
                            ]
                        ],
                        [
                            [
                                <x21>,
                                <y21>
                            ],
                            [
                                <x22>,
                                <y22>
                            ]
                        ]
                    ]
                },
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                }
            },
            {
                "geometry": {
                    "paths": [
                        [
                            [
                                <x11>,
                                <y11>
                            ],
                            [
                                <x12>,
                                <y12>
                            ]
                        ],
                        [
                            [
                                <x21>,
                                <y21>
                            ],
                            [
                                <x22>,
                                <y22>
                            ]
                        ]
                    ]
                },
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                }
            }
        ],
        "exceededTransferLimit": <true|false>
    }
}

The following shows an example of the out_routes parameter.

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "paramName": "out_routes",
    "dataType": "GPFeatureRecordSetLayer",
    "value": {
        "displayFieldName": "",
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
        },
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "Name",
                "type": "esriFieldTypeString",
                "alias": "Name",
                "length": 128
            },
            {
                "name": "ViolatedConstraints",
                "type": "esriFieldTypeInteger",
                "alias": "ViolatedConstraints"
            },
            {
                "name": "OrderCount",
                "type": "esriFieldTypeInteger",
                "alias": "OrderCount"
            },
            {
                "name": "TotalCost",
                "type": "esriFieldTypeDouble",
                "alias": "TotalCost"
            },
            {
                "name": "RegularTimeCost",
                "type": "esriFieldTypeDouble",
                "alias": "RegularTimeCost"
            },
            {
                "name": "OvertimeCost",
                "type": "esriFieldTypeDouble",
                "alias": "OvertimeCost"
            },
            {
                "name": "DistanceCost",
                "type": "esriFieldTypeDouble",
                "alias": "DistanceCost"
            },
            {
                "name": "TotalTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalTime"
            },
            {
                "name": "TotalOrderServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalOrderServiceTime"
            },
            {
                "name": "TotalBreakServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalBreakServiceTime"
            },
            {
                "name": "TotalTravelTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalTravelTime"
            },
            {
                "name": "TotalDistance",
                "type": "esriFieldTypeDouble",
                "alias": "TotalDistance"
            },
            {
                "name": "StartTime",
                "type": "esriFieldTypeDate",
                "alias": "StartTime",
                "length": 16
            },
            {
                "name": "EndTime",
                "type": "esriFieldTypeDate",
                "alias": "EndTime",
                "length": 16
            },
            {
                "name": "TotalWaitTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalWaitTime"
            },
            {
                "name": "TotalViolationTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalViolationTime"
            },
            {
                "name": "RenewalCount",
                "type": "esriFieldTypeInteger",
                "alias": "RenewalCount"
            },
            {
                "name": "TotalRenewalServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalRenewalServiceTime"
            },
            {
                "name": "Shape_Length",
                "type": "esriFieldTypeDouble",
                "alias": "Shape_Length"
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Truck_1",
                    "ViolatedConstraints": null,
                    "OrderCount": 2,
                    "TotalCost": 55.12577115597857,
                    "RegularTimeCost": 32.368821966275576,
                    "OvertimeCost": 0,
                    "DistanceCost": 22.756949189702993,
                    "TotalTime": 161.84410983137786,
                    "TotalOrderServiceTime": 49,
                    "TotalBreakServiceTime": 0,
                    "TotalTravelTime": 52.844109831377864,
                    "TotalDistance": 15.171299459801997,
                    "StartTime": 1355241600000,
                    "EndTime": 1355251310647,
                    "TotalWaitTime": 0,
                    "TotalViolationTime": 0,
                    "RenewalCount": 0,
                    "TotalRenewalServiceTime": 0,
                    "Shape_Length": 0.27770417275136994
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39476499860575,
                                37.79623499914595
                            ],
                            [
                                -122.39486000028876,
                                37.79632999992958
                            ],
							                     //.... additional points in the route part
                        ],
                        [
                            [
                                -122.46491587646648,
                                37.77469887205535
                            ],
                            [
                                -122.4648300002043,
                                37.77348999976374
                            ],
							                     //.... additional points in the route path
                        ],
						                  //.... additional paths in the route
                    ]
                }
            },
            {
                "attributes": {
                    "ObjectID": 2,
                    "Name": "Truck_2",
                    "ViolatedConstraints": null,
                    "OrderCount": 2,
                    "TotalCost": 58.98111973045911,
                    "RegularTimeCost": 31.262990736961367,
                    "OvertimeCost": 0,
                    "DistanceCost": 27.71812899349775,
                    "TotalTime": 156.31495368480682,
                    "TotalOrderServiceTime": 43,
                    "TotalBreakServiceTime": 0,
                    "TotalTravelTime": 53.314953684806824,
                    "TotalDistance": 18.478752662331832,
                    "StartTime": 1355241600000,
                    "EndTime": 1355250978897,
                    "TotalWaitTime": 0,
                    "TotalViolationTime": 0,
                    "RenewalCount": 0,
                    "TotalRenewalServiceTime": 0,
                    "Shape_Length": 0.30798071724323045
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39476499860575,
                                37.79623499914595
                            ],
                            [
                                -122.39486000028876,
                                37.79632999992958
                            ],
                            //.... additional points in the route path
                        ],
                        [
                            [
                                -122.47389692820065,
                                37.74313425554152
                            ],
                            [
                                -122.47462999977466,
                                37.74310000036479
                            ],
                            //.... additional points in the route path
                        ],
						                  //.... additional paths in the route
                    ]
                }
            },
            {
                "attributes": {
                    "ObjectID": 3,
                    "Name": "Truck_3",
                    "ViolatedConstraints": null,
                    "OrderCount": 2,
                    "TotalCost": 59.96986647554318,
                    "RegularTimeCost": 28.12653774395585,
                    "OvertimeCost": 0,
                    "DistanceCost": 31.843328731587327,
                    "TotalTime": 140.63268871977925,
                    "TotalOrderServiceTime": 38,
                    "TotalBreakServiceTime": 0,
                    "TotalTravelTime": 42.63268871977925,
                    "TotalDistance": 21.228885821058217,
                    "StartTime": 1355241600000,
                    "EndTime": 1355250037961,
                    "TotalWaitTime": 0,
                    "TotalViolationTime": 0,
                    "RenewalCount": 0,
                    "TotalRenewalServiceTime": 0,
                    "Shape_Length": 0.3486039472893737
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39476499860575,
                                37.79623499914595
                            ],
                            [
                                -122.39486000028876,
                                37.79632999992958
                            ],
							                     //.... additional points in the route path
                        ],
                        [
                            [
                                -122.44930025350385,
                                37.731549383197546
                            ],
                            [
                                -122.45112999974964,
                                37.73153999967133
                            ],
                            //.... additional points in the route path
                        ],
						                  //.... additional paths in the route
                    ]
                }
            }
        ],
        "exceededTransferLimit": false
    }
}

out_directions

Use this parameter to access the turn-by-turn instructions to help drivers follow their assigned routes. The parameter includes the driving directions as well as the geometry for the directions feature corresponding to the text. The shape for the directions feature is determined from the underlying streets included in the route. The feature geometries are returned in the spatial reference specified as the env:outSR parameter. The features are empty if thepopulate_directions parameter is false. The directions_language, and the directions_style_name parameters highly influence the driving directions.

The following provides a description of fields that are returned for directions features:

  • ObjectID: A unique identifier for the directions feature. This identifier is auto generated by the service.
  • RouteName: The name of the route that the driving action applies to. This value is same as the Name attribute from out_routes parameter.
  • ArriveTime: The time of day to initiate the given driving action. The value is reported as milliseconds since midnight January 1, 1970.
  • Type: Indicates the type of maneuver that the direction feature represents or the type of the directions text. In order to determine if Type refers to a maneuver type or a directions string type, you need to check the value of SubItemType field.

    Type can be used, for example, to assign a different icon for a direction text based on the maneuver type or use a special formatting style based on the directions string type when displaying the driving directions in your applications

    The Type value is an integer from the Maneuver Types or the Directions String Types tables.

    Maneuver types

    Value

    Description

    0

    Unknown

    1

    Arrive at Stop

    2

    Go straight

    3

    Bear left

    4

    Bear right

    5

    Turn left

    6

    Turn right

    7

    Make sharp left

    8

    Make sharp right

    9

    Make U-turn

    10

    Take ferry

    11

    Take roundabout

    12

    Merge to highway

    13

    Exit highway

    14

    Go on another highway

    15

    At fork keep center

    16

    At fork keep left

    17

    At fork keep right

    18

    Depart stop

    19

    Trip planning item

    20

    End of ferry

    21

    Ramp right

    22

    Ramp left

    23

    Turn left and immediately turn right

    24

    Turn right and immediately turn left

    25

    Turn right and immediately turn right

    26

    Turn left and immediately turn left

    Directions string types

    Value

    Description

    0

    General directions string type

    1

    Depart directions string type

    2

    Arrive directions string type

    3

    Length directions string type

    4

    Time directions string type

    5

    Time summary directions string type

    6

    Time Window directions string type

    7

    Violation Time directions string type

    8

    Wait Time directions string type

    9

    Service Time directions string type

    10

    Estimated Arrival Time directions string type

    11

    Cumulative Length directions string type

    12

    Street name directions string type

    13

    Alternate street name directions string type

    14

    Sign branch information directions string type

    15

    Sign toward information directions string type

    16

    Cross street name directions string type

    17

    Sign exit number directions string type

  • SubItemType: Specifies whether the Type field refers to an integer from the Directions String Types table or the Maneuver Types table.
    • If the SubItemType value is 1, the Type refers to the values from the Maneuver Types table.
    • If the SubItemType value is 2, the Type refers to the values from the Directions String Types table.
  • Text: A text description of the driving direction.
  • ElapsedTime: The time elapsed from when the current driving direction starts until the next one starts, or until the route ends for the last driving direction. The value is in the units specified by the time_units parameter.
  • DriveDistance: The distance from where the current driving direction occurs to where the next one occurs, or to where the route ends for the last driving direction. The value is in the units specified by the distance_units parameter.

    This value is zero for driving directions that occur at the same location where the next one begins. For example, the DriveDistance is 0 for the directions text at the start of the route.

  • Shape_Length: The length of the directions feature in the units of the spatial reference specified for the routes. By default the length is reported in decimal degrees if the env:outSR parameter is not specified.

The out_directions parameter is returned as a JSON feature set with following syntax:

CautionCaution:

When using the asynchronous execution mode, the service can only return a maximum of 200,000 features with the out_directions parameter. The limit is 10,000 features when using the synchronous execution mode. If this limit is exceeded, the exceededTransferLimit property is set to true.

{
    "paramName": "out_directions",
    "dataType": "GPFeatureRecordSetLayer",
    "value": {
        "displayFieldName": "",
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": <wkid>,
            "latestWkid": <wkid>,
            
        },
        "fields": [
            {
                "name": "<field1Name>",
                "type": "<field1Type>",
                "alias": "<field1Alias>",
                "length": "<field1Length>" //length is included only for esriFieldTypeString
            },
            {
                "name": "<field2Name>",
                "type": "<field2Type>",
                "alias": "<field2Alias>",
                "length": "<field2Length>"
            }
        ],
        "features": [
            {
                "geometry": {
                    "paths": [
                        [
                            [
                                <x11>,
                                <y11>
                            ],
                            [
                                <x12>,
                                <y12>
                            ]
                        ],
                        [
                            [
                                <x21>,
                                <y21>
                            ],
                            [
                                <x22>,
                                <y22>
                            ]
                        ]
                    ]
                },
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                }
            },
            {
                "geometry": {
                    "paths": [
                        [
                            [
                                <x11>,
                                <y11>
                            ],
                            [
                                <x12>,
                                <y12>
                            ]
                        ],
                        [
                            [
                                <x21>,
                                <y21>
                            ],
                            [
                                <x22>,
                                <y22>
                            ]
                        ]
                    ]
                },
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                }
            }
        ],
        "exceededTransferLimit": <true|false>
    }
}

The following shows an example of the out_directions parameter:

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "paramName": "out_directions",
    "dataType": "GPFeatureRecordSetLayer",
    "value": {
        "displayFieldName": "",
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
        },
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "RouteName",
                "type": "esriFieldTypeString",
                "alias": "RouteName",
                "length": 128
            },
            {
                "name": "ArriveTime",
                "type": "esriFieldTypeDate",
                "alias": "ArriveTime",
                "length": 16
            },
            {
                "name": "Type",
                "type": "esriFieldTypeSmallInteger",
                "alias": "Type"
            },
            {
                "name": "SubItemType",
                "type": "esriFieldTypeSmallInteger",
                "alias": "SubItemType"
            },
            {
                "name": "Text",
                "type": "esriFieldTypeString",
                "alias": "Text",
                "length": 255
            },
            {
                "name": "ElapsedTime",
                "type": "esriFieldTypeSingle",
                "alias": "ElapsedTime"
            },
            {
                "name": "DriveDistance",
                "type": "esriFieldTypeSingle",
                "alias": "DriveDistance"
            },
            {
                "name": "Shape_Length",
                "type": "esriFieldTypeDouble",
                "alias": "Shape_Length"
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355241600000,
                    "Type": 18,
                    "SubItemType": 1,
                    "Text": "Start at San Francisco",
                    "ElapsedTime": 60,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 2,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355241600000,
                    "Type": 6,
                    "SubItemType": 2,
                    "Text": "Time Window: 12/11/2012 4:00 PM - 12/12/2012 1:00 AM",
                    "ElapsedTime": 60,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 3,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355241600000,
                    "Type": 9,
                    "SubItemType": 2,
                    "Text": "Service Time: 1 hr ",
                    "ElapsedTime": 60,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 4,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355245200000,
                    "Type": 2,
                    "SubItemType": 1,
                    "Text": "Go northwest on THE EMBARCADERO (HERB CAEN WAY)",
                    "ElapsedTime": 1.015078,
                    "DriveDistance": 0.2596097,
                    "Shape_Length": 0.004134325550916659
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39476499860575,
                                37.79623499914595
                            ],
                            [
                                -122.3955800002168,
                                37.79708999990362
                            ],
                            //... additional points in the path
                        ]
                    ]
                }
            },
            {
                "attributes": {
                    "ObjectID": 5,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355245260905,
                    "Type": 5,
                    "SubItemType": 1,
                    "Text": "Turn left on BROADWAY",
                    "ElapsedTime": 3.704131,
                    "DriveDistance": 0.7392571,
                    "Shape_Length": 0.013397827315874893
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39755000023229,
                                37.79928999973373
                            ],
                            [
                                -122.39792999976964,
                                37.799070000380254
                            ],
                            //.... additional points in the path
                        ]
                    ]
                }
            },
            //.... additional directions features
            {
                "attributes": {
                    "ObjectID": 14,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355246407621,
                    "Type": 1,
                    "SubItemType": 1,
                    "Text": "Arrive at Store_3, on the left",
                    "ElapsedTime": 24,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 15,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355246407621,
                    "Type": 6,
                    "SubItemType": 2,
                    "Text": "Time Window: 12/11/2012 5:00 PM - 12/12/2012 1:00 AM",
                    "ElapsedTime": 24,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 16,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355246407621,
                    "Type": 9,
                    "SubItemType": 2,
                    "Text": "Service Time: 24 min",
                    "ElapsedTime": 24,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 17,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355247847621,
                    "Type": 18,
                    "SubItemType": 1,
                    "Text": "Depart Store_3",
                    "ElapsedTime": 0,
                    "DriveDistance": 0,
                    "Shape_Length": 0
                }
            },
            {
                "attributes": {
                    "ObjectID": 18,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355247847621,
                    "Type": 2,
                    "SubItemType": 1,
                    "Text": "Continue south on 7TH AVE",
                    "ElapsedTime": 0.5039461,
                    "DriveDistance": 0.08350408,
                    "Shape_Length": 0.001211918705951693
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.46491587646648,
                                37.77469887205535
                            ],
                            [
                                -122.4648300002043,
                                37.77348999976374
                            ]
                        ]
                    ]
                }
            },
            {
                "attributes": {
                    "ObjectID": 19,
                    "RouteName": "Truck_1",
                    "ArriveTime": 1355247877858,
                    "Type": 6,
                    "SubItemType": 1,
                    "Text": "Turn right on FULTON ST",
                    "ElapsedTime": 7.81348,
                    "DriveDistance": 2.474024,
                    "Shape_Length": 0.04514114889321549
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.4648300002043,
                                37.77348999976374
                            ],
                            [
                                -122.46588000006193,
                                37.773380000087
                            ],
                            //.... additional points in the path
                        ]
                    ]
                }
            },
            //.... additional directions features
        ],
        "exceededTransferLimit": false
    }
}

out_unassigned_stops

Use this parameter to access the orders that couldn't be visited by any routes. You can also determine why the stop couldn't be visited and can make the necessary changes to fix the problem.

The following provides a description of attributes that are returned for each unassigned stop:

  • ObjectID: A unique identifier for the stop. This identifier is auto generated by the service.
  • StopType: Indicates whether the stop represents a depot, order, or break. The attribute value is an integer which can be interpreted in the following way:
    • 0: The stop is an order.
    • 1: The stop is depot.
    • 2: The stop is a break.
  • Name: The name of the stop. The value of this attribute is same as the Name attribute of the depots, orders, or the breaks parameters from the request. You can use the StopType attribute to determine if the Name attribute value refers to a depot, order or a break.
  • ViolatedConstraints: Contains a summary of constraints that are violated when assigning the order to any of the routes. The service assigns a unique integer for each violated constraint. The ViolatedConstraints attribute value is an integer representing the sum of all the constraints that are violated by the order. In order to determine the individual constraints that are violated, you can treat the attribute value as a bit mask and derive the values for the individual bits. For instance, the combination of Capacities exceeded (2) and Hard route zone (128) is coded as 130 (2 +128).

    If an order causes a constraint to be violated, a combination of one or more of the violations listed below could be assigned to the ViolatedConstraints attribute.

    • MaxOrderCount exceeded (1): The preassigned orders can't be assigned to the route since assigning the orders would exceed the maximum number of orders that can be assigned to the route as specified by the MaxOrderCount attribute for the routes parameter.
    • Capacities exceeded (2): The preassigned orders can't be assigned to the route since assigning the orders would exceed the total route capacity as specified by the Capacities attribute for the routes parameter.
    • MaxTotalTime exceeded (4): The travel time from the start depot to the end depot plus the service and wait times at both depots and any break exceeds the total time for the route as specified by the MaxTotalTime attribute for the routes parameter.
    • MaxTotalTravelTime exceeded (8): The travel time from the start depot to the end depot exceeds the total travel time for the route as specified by the MaxTotalTravelTime attribute for the routes parameter.
    • MaxTotalDistance exceeded (16): The travel distance from the start depot to the end depot exceeds the total travel distance for the route as specified by the MaxTotalDistance attribute for the routes parameter.
    • Hard time window (32): There is a hard time window violation on the start depot, end depot, or break associated with the route.
    • Unmatched specialty (64): The specialties required by an order are not found on the target route.
    • Hard route zone (128): An order that was preassigned to the route does not fall within a hard route zone.
    • Order pair MaxTransitTime exceeded (256): There is an order pair preassigned to the route, and assigning the orders in the order pair would exceed the maximum transit time for the order pair as specified by the MaxTransitTime attribute for the order_pairs parameter.
    • Order pair violation (512): An order belongs to an order pair and can't be assigned to the preassigned route.
    • Unreachable (1024): A preassigned order is located on a street that cannot be reached by the route.
    • Cannot insert required break (2048): A break for the route has a null sequence value in the presence of preassigned orders, and the break can't be inserted anywhere without introducing other violations.
    • Cannot insert required renewal (4096): A route exceeds its capacity and needs to visit a route renewal; however, the associated route renewal has a null sequence value in the presence of preassigned orders and can't be inserted anywhere without introducing other violations.
    • MaxTravelTimeBetweenBreaks exceeded (8192): The solver was unable to insert a break within the time specified by the MaxTravelTimeBetweenBreaks attribute for the breaks parameter. This is often caused by preassigning a sequence to a break such that it can't be reached within the maximum travel time.

    • Break MaxCumulWorkTime exceeded (16384): The service was unable to insert a break within the time specified by the MaxCumulWorkTime attribute for the breaks parameter. This is often caused by preassigning a sequence to a break such that it can't be reached within the maximum work time.
      Dive-inDive-in:

      The ViolatedConstraints value of an unrouted order may or may not describe all its violations. If the violation is severe enough to immediately exclude the order from further consideration, the service does so, which prevents any other violations from being discovered for that order. If a violation is encountered that doesn't automatically stop a solution from being generated, the violation is noted in ViolatedConstraints, and the solver continues to consider the order. Any further violations like these are added to the ViolatedConstraints field until either (a) the service finds a violation that prematurely stops the solve process for that particular order or (b) the service finds an overall solution to the problem.

  • Status: Indicates the status of the stop in the solution returned by the service. The attribute value is an integer which can be interpreted in the following way.
    • 0: The stop was successfully evaluated.
    • 3: The street on which the stop is located not traversable. This can occur is the street is restricted by a restriction specifed by the restrictions parameter.
    • 4: The attribute values of the stop fall outside the coded value or range domains expected by the service. For example, a negative number may exist where positive numbers are required
    • 5: The stop can't be arrived at by the service.
TipTip:

The out_unassigned_stops parameter does not contain the geometry of the stops. In order to visualize the unaasigned stops on a map, you can do the following

  • Use the StopType attribute to determine if the stop feature corresponds to a feature in the orders or depots parameters .
  • Use the Name attribute to find the feature with the same name in the orders or depots parameters.

The out_unassigned_stops parameter is returned as a JSON feature set with following syntax:

Unlike the out_routes parameter, the out_unassigned_stops parameter does not contain spatialReference or geometryType properties as this parameter does not return any geometry information about the stops.

{
    "paramName": "out_unassigned_stops",
    "dataType": "GPRecordSet",
    "value": {
        "displayFieldName": "",
        "fields": [
            {
                "name": "<field1Name>",
                "type": "<field1Type>",
                "alias": "<field1Alias>",
                "length": "<field1Length>" //length is included only for esriFieldTypeString
            },
            {
                "name": "<field2Name>",
                "type": "<field2Type>",
                "alias": "<field2Alias>",
                "length": "<field2Length>"
            }
        ],
        "features": [
            {
                "attributes": {
                    "<field1>": <value11>,
                    "<field2>": <value12>
                }
            },
            {
                "attributes": {
                    "<field1>": <value21>,
                    "<field2>": <value22>
                }
            }
        ],
        "exceededTransferLimit": <true|false>
    }
}

The following shows an example of the out_unassigned_stops parameter.

{
    "paramName": "out_unassigned_stops",
    "dataType": "GPRecordSet",
    "value": {
        "displayFieldName": "",
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "StopType",
                "type": "esriFieldTypeSmallInteger",
                "alias": "StopType"
            },
            {
                "name": "Name",
                "type": "esriFieldTypeString",
                "alias": "Name",
                "length": 128
            },
            {
                "name": "ViolatedConstraints",
                "type": "esriFieldTypeInteger",
                "alias": "ViolatedConstraints"
            },
            {
                "name": "Status",
                "type": "esriFieldTypeInteger",
                "alias": "Status"
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "StopType": 0,
                    "Name": "Store_6",
                    "ViolatedConstraints": 1,
                    "Status": 5
                }
            },
            {
                "attributes": {
                    "ObjectID": 2,
                    "StopType": 0,
                    "Name": "Store_8",
                    "ViolatedConstraints": 1,
                    "Status": 5
                }
            },
            {
                "attributes": {
                    "ObjectID": 3,
                    "StopType": 0,
                    "Name": "Store_9",
                    "ViolatedConstraints": 1,
                    "Status": 5
                }
            }
        ],
        "exceededTransferLimit": false
    }
}

solve_succeeded

Use this parameter to determine if the service was able to successfully find the solution for the input vehicle routing problem. The error messages for the failure can be obtained by making a request to get the status of the job.

The solve_succeeded parameter is returned as a JSON feature set with following syntax:

{
    "paramName": "solve_succeeded",
    "dataType": "GPBoolean",
    "value": <true | false>
}

The following shows an example of the solve_succeeded parameter:

{
    "paramName": "solve_succeeded",
    "dataType": "GPBoolean",
    "value": true
}

Usage limits

The table below lists the limits that apply to this service. Some limits vary by execution mode, and they are noted accordingly.

Limit Description

Limit Value

Maximum number of orders:

100 for synchronous execution

2,000 for asynchronous execution

Maximum number of routes:

2 for synchronous execution

100 for asynchronous execution

Maximum number of orders per route:

100 for synchronous execution

200 for asynchronous execution

Maximum number of (point) barriers:

250

Maximum number of street features intersected by polyline barriers:

500

Maximum number of street features intersected by polygon barriers:

2,000

Maximum straight-line distance for the walking travel mode:

(If the straight-line distance between any orders or depots is greater than this limit, the analysis will fail when the waking restriction is used.)

50 miles (80.46 kilometers)

Force hierarchy beyond a straight-line distance of:

(If the straight-line distance between any orders or depots is greater than the limit shown here, the analysis uses hierarchy, even if useHierarchy_in_analysis is set to false.)

50 miles (80.46 kilometers)

Maximum snap tolerance:

(If the distance between an input point and its nearest traversable street is greater than the distance specified here, the point is excluded from the analysis.)

12.42 miles (20 kilometers)

Maximum number of directions features that can be returned:

10,000 for synchronous execution

200,000 for asynchronous execution

Maximum time a client can use the VRP services:

60 seconds for synchronous execution

4 hours (14,400 seconds) for asynchronous execution

Examples

NoteNote:

If you copy and paste the request URL from the examples into a web browser, you will get an invalid token error message. You need to replace <yourToken> with a valid token. See Accessing services provided by Esri to see how to generate one.

Servicing a set of orders with a fleet of vehicles

In this example, you will find the best routes for a fleet of three vehicles, operated by a distribution company, to deliver goods from a distribution center to a set of nine grocery stores. Each store has a specific quantity of demand for the goods, and each truck has a limited capacity for carrying the goods. The main objective is to assign trucks in the fleet a subset of the stores to service and to sequence the deliveries in a way that minimizes the overall transportation costs.

To solve this vehicle routing problem, we specify the stores as orders, the distibution center as depot and the three trucks as routes. For orders and depots, the geometries are in the default spatial reference, WGS84. So the spatialReference property is not required.

For the orders parameter, we specify the following attributes:

  • The store name as the Name attribute.
  • The service time as the ServiceTime attribute.
  • The total weight of goods to be delivered as the DeliveryQuantities attribute.
  • The time range in which the store accepts deliveries as the TimeWindowStart1 and TimeWindowEnd1 attributes.
  • Since the time windows should not be violated we specify 0 as the value for the MaxViolationTime1 attribute.

For the depots parameter, we specify the depot name as the Name attribute and the depot operating time as the TimeWindowStart1 and TimeWindowEnd1 attributes.

For the routes parameter, we specify the following attributes:

  • The name for each truck as the Name attribute.
  • The depot name from where the trucks operates as the StartDepotName and EndDepotName attributes.
    CautionCaution:

    The values for the StartDepotName and EndDepotName attributes need to match with the Name attribute specified for the depots parameter.

  • The time required to full load the truck with goods as StartDepotServiceTime attribute.
  • The trucks can start operating as soon as the depot opens. So we specify the EarliestStartTime and LatestStartTime attributes to have same value as the TimeWindowStart1 attribute for the depots parameter.
  • The maximum carrying capacity of each truck as the Capacities attribute.
  • The wage of the truck driver as the CostPerUnitTime attribute.
  • The average dollar amount spent per mile on fuel consumption, truck depreciation, and maintenance as the CostPerUnitDistance parameter.
  • The maximum number of stores that can be serviced by a truck as the MaxOrderCount attribute.
  • The maximum duration of the work shift for the drivers according to the workday constraints as the MaxTotalTime attribute.
  • The maximum time a truck can spend driving on the streets as the MaxTravelTime attribute. This considers the need to satisfy the workday constraints and still be able to serve a reasonable number of stores while taking into account the service time needed at a store.
  • The maximum distance a truck can travel that balances the daily fuel and maintenance costs among the fleet as the MaxTotalDistance attribute.

Since our time based attribute values such as ServiceTime, CostPerUnitDistance, and MaxTotalTime are in minutes, we can use the default value (which is minutes) for the time_units parameter. Similarly, our distance based attributes values such as CostPerUnitDistance and MaxTotalDistance are in miles, we can use the default value (which is miles) for the distance_units parameter. It is difficult for these delivery trucks to make U-turns. Hence we set the uturn_policy parameter as NO_UTURNS. We need to generate driving directions in English for each route. So we set the populate_directions parameter to true and the directions_language parameter to en. Since we have time windows on orders and depots, we need to specify the default_date parameter. The default values for all the remaining parameters is valid for this problem and hence we will not pass those parameters in our request.

As we have three routes, we need to select the asynchronous execution mode. The first request is to submit a job which returns the job id.

Request URL to submit the job

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob?token=<yourToken>&orders={"features":[{"geometry":{"x":-122.51,"y":37.7724},"attributes":{"DeliveryQuantities":1706,"Name":"Store_1","ServiceTime":25,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4889,"y":37.7538},"attributes":{"DeliveryQuantities":1533,"Name":"Store_2","ServiceTime":23,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4649,"y":37.7747},"attributes":{"DeliveryQuantities":1580,"Name":"Store_3","ServiceTime":24,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4739,"y":37.7432},"attributes":{"DeliveryQuantities":1289,"Name":"Store_4","ServiceTime":20,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4493,"y":37.7315},"attributes":{"DeliveryQuantities":1302,"Name":"Store_5","ServiceTime":21,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4917,"y":37.6493},"attributes":{"DeliveryQuantities":1775,"Name":"Store_6","ServiceTime":26,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.4832,"y":37.7012},"attributes":{"DeliveryQuantities":1014,"Name":"Store_7","ServiceTime":17,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.5301,"y":37.8935},"attributes":{"DeliveryQuantities":1761,"Name":"Store_8","ServiceTime":26,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}},{"geometry":{"x":-122.2875,"y":37.8909},"attributes":{"DeliveryQuantities":1815,"Name":"Store_9","ServiceTime":27,"TimeWindowStart1":1355245200000,"TimeWindowEnd1":1355274000000,"MaxViolationTime1":0}}]}&depots={"features":[{"geometry":{"x":-122.3943,"y":37.7967},"attributes":{"Name":"San Francisco","TimeWindowStart1":1355241600000,"TimeWindowEnd1":1355274000000}}]}&routes={"features":[{"attributes":{"Name":"Truck_1","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}},{"attributes":{"Name":"Truck_2","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}},{"attributes":{"Name":"Truck_3","StartDepotName":"San Francisco","EndDepotName":"San Francisco","StartDepotServiceTime":60,"EarliestStartTime":1355241600000,"LatestStartTime":1355241600000,"Capacities":"15000","CostPerUnitTime":0.2,"CostPerUnitDistance":1.5,"MaxOrderCount":2,"MaxTotalTime":360,"MaxTotalTravelTime":120,"MaxTotalDistance":80}}]}&time_units=Minutes&distance_units=Miles&uturn_policy=NO_UTURNS&populate_directions=true&directions_language=en&default_date=1355212800000&f=json

JSON response

{
    "jobId": "jb1e9c0999ec047f4ac99750055041719",
    "jobStatus": "esriJobSubmitted"
}

Request URL to query job status

The job id obtained from the response of the first request can be queried periodically to determine the status of the job.

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jb1e9c0999ec047f4ac99750055041719?token=<yourToken>&returnMessages=true&f=json

JSON response

{
    "jobId": "jb1e9c0999ec047f4ac99750055041719",
    "jobStatus": "esriJobSucceeded",
    "results": {
        "out_unassigned_stops": {
            "paramUrl": "results/out_unassigned_stops"
        },
        "out_stops": {
            "paramUrl": "results/out_stops"
        },
        "out_routes": {
            "paramUrl": "results/out_routes"
        },
        "out_directions": {
            "paramUrl": "results/out_directions"
        },
        "solve_succeeded": {
            "paramUrl": "results/solve_succeeded"
        }
    },
    "inputs": {
        "orders": {
            "paramUrl": "inputs/orders"
        },
        "depots": {
            "paramUrl": "inputs/depots"
        },
        "routes": {
            "paramUrl": "inputs/routes"
        },
        "breaks": {
            "paramUrl": "inputs/breaks"
        },
        "time_units": {
            "paramUrl": "inputs/time_units"
        },
        "distance_units": {
            "paramUrl": "inputs/distance_units"
        },
        "analysis_region": {
            "paramUrl": "inputs/analysis_region"
        },
        "default_date": {
            "paramUrl": "inputs/default_date"
        },
        "uturn_policy": {
            "paramUrl": "inputs/uturn_policy"
        },
        "time_window_factor": {
            "paramUrl": "inputs/time_window_factor"
        },
        "spatially_cluster_routes": {
            "paramUrl": "inputs/spatially_cluster_routes"
        },
        "route_zones": {
            "paramUrl": "inputs/route_zones"
        },
        "route_renewals": {
            "paramUrl": "inputs/route_renewals"
        },
        "order_pairs": {
            "paramUrl": "inputs/order_pairs"
        },
        "excess_transit_factor": {
            "paramUrl": "inputs/excess_transit_factor"
        },
        "point_barriers": {
            "paramUrl": "inputs/point_barriers"
        },
        "line_barriers": {
            "paramUrl": "inputs/line_barriers"
        },
        "polygon_barriers": {
            "paramUrl": "inputs/polygon_barriers"
        },
        "use_hierarchy_in_analysis": {
            "paramUrl": "inputs/use_hierarchy_in_analysis"
        },
        "restrictions": {
            "paramUrl": "inputs/restrictions"
        },
        "attribute_parameter_values": {
            "paramUrl": "inputs/attribute_parameter_values"
        },
        "populate_route_lines": {
            "paramUrl": "inputs/populate_route_lines"
        },
        "route_line_simplification_tolerance": {
            "paramUrl": "inputs/route_line_simplification_tolerance"
        },
        "populate_directions": {
            "paramUrl": "inputs/populate_directions"
        },
        "directions_language": {
            "paramUrl": "inputs/directions_language"
        },
        "directions_style_name": {
            "paramUrl": "inputs/directions_style_name"
        }
    },
    "messages": []
}

Request URL to return the output routes

As the job succeeded, we can make a request to return the routes from the out_routes output parameter.

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jb1e9c0999ec047f4ac99750055041719/results/out_routes?token=<yourToken>&f=json

JSON response

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "paramName": "out_routes",
    "dataType": "GPFeatureRecordSetLayer",
    "value": {
        "displayFieldName": "",
        "geometryType": "esriGeometryPolyline",
        "spatialReference": {
            "wkid": 4326,
            "latestWkid": 4326
        },
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "Name",
                "type": "esriFieldTypeString",
                "alias": "Name",
                "length": 128
            },
            {
                "name": "ViolatedConstraints",
                "type": "esriFieldTypeInteger",
                "alias": "ViolatedConstraints"
            },
            {
                "name": "OrderCount",
                "type": "esriFieldTypeInteger",
                "alias": "OrderCount"
            },
            {
                "name": "TotalCost",
                "type": "esriFieldTypeDouble",
                "alias": "TotalCost"
            },
            {
                "name": "RegularTimeCost",
                "type": "esriFieldTypeDouble",
                "alias": "RegularTimeCost"
            },
            {
                "name": "OvertimeCost",
                "type": "esriFieldTypeDouble",
                "alias": "OvertimeCost"
            },
            {
                "name": "DistanceCost",
                "type": "esriFieldTypeDouble",
                "alias": "DistanceCost"
            },
            {
                "name": "TotalTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalTime"
            },
            {
                "name": "TotalOrderServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalOrderServiceTime"
            },
            {
                "name": "TotalBreakServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalBreakServiceTime"
            },
            {
                "name": "TotalTravelTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalTravelTime"
            },
            {
                "name": "TotalDistance",
                "type": "esriFieldTypeDouble",
                "alias": "TotalDistance"
            },
            {
                "name": "StartTime",
                "type": "esriFieldTypeDate",
                "alias": "StartTime",
                "length": 16
            },
            {
                "name": "EndTime",
                "type": "esriFieldTypeDate",
                "alias": "EndTime",
                "length": 16
            },
            {
                "name": "TotalWaitTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalWaitTime"
            },
            {
                "name": "TotalViolationTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalViolationTime"
            },
            {
                "name": "RenewalCount",
                "type": "esriFieldTypeInteger",
                "alias": "RenewalCount"
            },
            {
                "name": "TotalRenewalServiceTime",
                "type": "esriFieldTypeDouble",
                "alias": "TotalRenewalServiceTime"
            },
            {
                "name": "Shape_Length",
                "type": "esriFieldTypeDouble",
                "alias": "Shape_Length"
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Truck_1",
                    "ViolatedConstraints": null,
                    "OrderCount": 1,
                    "TotalCost": 39.22232551889244,
                    "RegularTimeCost": 24.312590403482318,
                    "OvertimeCost": 0,
                    "DistanceCost": 14.90973511541012,
                    "TotalTime": 121.56295201741159,
                    "TotalOrderServiceTime": 24,
                    "TotalBreakServiceTime": 0,
                    "TotalTravelTime": 37.56295201741159,
                    "TotalDistance": 9.939823410273414,
                    "StartTime": 1355241600000,
                    "EndTime": 1355248893777,
                    "TotalWaitTime": 0,
                    "TotalViolationTime": 0,
                    "RenewalCount": 0,
                    "TotalRenewalServiceTime": 0,
                    "Shape_Length": 0.18586232678817152
                },
                "geometry": {
                    "paths": [
                        [
                            [
                                -122.39476499860575,
                                37.79623499914595
                            ],
                            [
                                -122.39486000028876,
                                37.79632999992958
                            ],
....
.... additional points in the route part
.... 
                        ]  
                        [
                            [
                                -122.46491587646648,
                                37.77469887205535
                            ],
                            [
                                -122.46495999990407,
                                37.77531999961832
                            ],
....
.... additional points in the route part
....     
                        ]
                    ]
                }
            },
....
.... additional routes in the solution
....
        ],
        "exceededTransferLimit": false
    }
}

Request URL to return output orders

As the job succeeded, we can make a request to return the orders assigned to routes from the out_stops output parameter.

https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/jb1e9c0999ec047f4ac99750055041719/results/out_stops?token=<yourToken>&f=json

JSON response

NoteNote:

Because the response is quite verbose, the repeated elements within the response are abbreviated for clarity.

{
    "paramName": "out_stops",
    "dataType": "GPRecordSet",
    "value": {
        "displayFieldName": "",
        "fields": [
            {
                "name": "ObjectID",
                "type": "esriFieldTypeOID",
                "alias": "ObjectID"
            },
            {
                "name": "Name",
                "type": "esriFieldTypeString",
                "alias": "Name",
                "length": 128
            },
            {
                "name": "PickupQuantities",
                "type": "esriFieldTypeString",
                "alias": "PickupQuantities",
                "length": 128
            },
            {
                "name": "DeliveryQuantities",
                "type": "esriFieldTypeString",
                "alias": "DeliveryQuantities",
                "length": 128
            },
            {
                "name": "StopType",
                "type": "esriFieldTypeSmallInteger",
                "alias": "StopType"
            },
            {
                "name": "RouteName",
                "type": "esriFieldTypeString",
                "alias": "RouteName",
                "length": 128
            },
            {
                "name": "Sequence",
                "type": "esriFieldTypeInteger",
                "alias": "Sequence"
            },
            {
                "name": "FromPrevTravelTime",
                "type": "esriFieldTypeDouble",
                "alias": "FromPrevTravelTime"
            },
            {
                "name": "FromPrevDistance",
                "type": "esriFieldTypeDouble",
                "alias": "FromPrevDistance"
            },
            {
                "name": "ArriveCurbApproach",
                "type": "esriFieldTypeInteger",
                "alias": "ArriveCurbApproach"
            },
            {
                "name": "DepartCurbApproach",
                "type": "esriFieldTypeInteger",
                "alias": "DepartCurbApproach"
            },
            {
                "name": "ArriveTime",
                "type": "esriFieldTypeDate",
                "alias": "ArriveTime",
                "length": 16
            },
            {
                "name": "DepartTime",
                "type": "esriFieldTypeDate",
                "alias": "DepartTime",
                "length": 16
            },
            {
                "name": "WaitTime",
                "type": "esriFieldTypeDouble",
                "alias": "WaitTime"
            },
            {
                "name": "ViolationTime",
                "type": "esriFieldTypeDouble",
                "alias": "ViolationTime"
            },
            {
                "name": "ArriveTimeUTC",
                "type": "esriFieldTypeDate",
                "alias": "ArriveTimeUTC",
                "length": 16
            },
            {
                "name": "DepartTimeUTC",
                "type": "esriFieldTypeDate",
                "alias": "DepartTimeUTC",
                "length": 16
            }
        ],
        "features": [
            {
                "attributes": {
                    "ObjectID": 1,
                    "Name": "Store_1",
                    "PickupQuantities": "",
                    "DeliveryQuantities": "1706",
                    "StopType": 0,
                    "RouteName": "Truck_2",
                    "Sequence": 2,
                    "FromPrevTravelTime": 25.57343202829361,
                    "FromPrevDistance": 7.5915227103313985,
                    "ArriveCurbApproach": 0,
                    "DepartCurbApproach": 0,
                    "ArriveTime": 1355246734406,
                    "DepartTime": 1355248234406,
                    "WaitTime": 0,
                    "ViolationTime": 0,
                    "ArriveTimeUTC": 1355275534406,
                    "DepartTimeUTC": 1355277034406
                }
            },
 ....
 .... additional orders in the solution
 ....
        ],
        "exceededTransferLimit": false
    }
}
7/5/2017