An optimized route that reorders stops to minimize the distance and time required to visit all locations.
What is optimized routing?
Optimized routing, also known as the traveling salesperson problem (TRP), is the process of finding the best route to travel for a single vehicle when you need to stop at multiple destinations. Optimized routing differs from simple routing because it can reorder the sequence of stops to create the most efficient route possible, while minimizing the travel distance or travel time. Simple routing does not change the order of the stops you provide. Both simple and optimized routing take into consideration different restrictions such as speed limit, number of lanes, road conditions, and other barriers.
You can use optimized routing to:
Find the most efficient sequence of stops to multiple destinations.
Find the quickest and most effective path from an origin to multiple locations.
Generate driving directions in multiple languages.
How optimized routing works
The typical workflow for creating an optimized route is to:
Define the origin, stops, and destination.
Define the type of travel for the route.
Set the findBestSequence parameter to true. Unless specified, the first and last stops you provide will be kept.
Access the routing service to find the route features and directions.
How to navigate a route
Once you have a route, if you want to use your current device's location to track progress and provide navigation instructions (voice guidance) as you traverse the route, the best way to accomplish this is with the ArcGIS Maps SDKs for Native Apps.
URL requests
You can find a route and directions by making an HTTPS request to the routing service solve operation or by using client APIs. Specify the origin, destination, and optionally, additional parameters to refine the results with directions. Some of the most common parameters are described provided below.
Request limits
Limit
Direct
Job
Maximum number of stops
150
10,000
Maximum transaction time:
5 minutes
60 minutes
Maximum number of point barriers:
250
250
Maximum number of street features intersected by polyline barriers:
500
500
Maximum number of street features intersected by polygon barriers:
2,000
2,000
Maximum straight-line distance for the walking travel mode: (If the straight-line distance between any stops is greater than this limit, the analysis will fail when the walking restriction is used.)
27 miles (43.45 kilometers)
27 miles (43.45 kilometers)
Force hierarchy beyond a straight-line distance of: (If the straight-line distance between any stops is greater than the limit shown here, the analysis uses hierarchy, even if the travel_mode defines not to use hierarchy.)
50 miles (80.46 kilometers)
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)
12.42 miles (20 kilometers)
Maximum number of directions features that can be returned:
No limit
1,000,000
Maximum number of route edges that can be returned:
The two or more locations that need to be visited in the route.
stops=-117,34; -117.5,34.5
findBestSequence
Specify whether the service should find the best sequence when visiting multiple destinations. Note: Set this parameter to true to generate an optimized route.
findBestSequence=true
Direct
Use for shorter transactions with less than 150 stops that will complete in less than 5 minutes.
The time at which travel begins from the input stops. You can also specify a value of now, to set the depart time to the current time.
startTime=now
returnDirections
Generate driving directions for each route.
returnDirections=true
directionsLanguage
The language to be used when generating driving directions.
directionsLanguage=es
Additional parameters: Set additional constraints for a route such as temporary slowdowns, using polygonBarriers, or set outputLines to specify the type of route feature created by the service.
Job
Use for longer transactions with up to 10,000 stops that will complete in less than 60 minutes.
The two or more locations that need to be visited in the route.
stops=-117,34; -117.5,34.5
reorder_stops_to_find_optimal_routes
Specify whether the service should find the best sequence when visiting multiple destinations. Note:Set this parameter to true to return an optimized route.
reorder_stops_to_find_optimal_routes=true
Key parameters
Name (Job)
Description
Examples
travel_mode
The mode of transportation such as driving a car or a truck or walking.
The time at which travel begins from the input stops.
time_of_day=1608022800000
populate_directions
Generate driving directions for each route.
populate_directions=true
directions_language
The language to be used when generating driving directions.
directions_language=es
Additional parameters: Set additional constraints such as temporary slowdowns, using polygon_barriers, route_shape to specify the type of route feature created by the service, or set return_to_start if the start and end location for your route is same.
Code examples
Direct: Find an optimized route to restaurants
In this example, you find the best delivery route for ten restaurants in downtown San Diego. The default travelMode is driving time by vehicle, but you can use walk or trucking travel modes as well. The startTime is set as now, which sets the route departure time as the current time and the service will use the current traffic conditions. The findBestSequence parameter is set to true so that the service reorders the stops to generate the best route sequence.
Find an optimized route for ten stops.
APIs
ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for .NETArcGIS Maps SDK for JavaArcGIS Maps SDK for Qt (C++)ArcGIS Maps SDK for Qt (QML)ArcGIS API for PythonArcGIS REST JSEsri LeafletMapLibre GL JSOpenLayersCesiumJS
In this example, you use a job request to find the best route sequence for 36 stops for a delivery truck for an area around San Diego. The travel_mode is set to find the trucking time and the reorder_stops_to_find_optimal_routes parameter is set to true so that the service reorders the stops and creates the best sequence for the delivery route.
Find an optimized route for a truck delivery with 36 stops.
APIs
ArcGIS Maps SDK for JavaScriptArcGIS Maps SDK for JavaScriptArcGIS API for PythonArcGIS REST JS
Unlike Direct request type which allows you to make a request and get back all the results in the response, when working with a Job request type, you need to follow a three step workflow:
Make the submitJob request with the appropriate request parameters to get a job id.
Using the job id, check the job status to see if the job completed successfully.