Visit Many of Addresses in as Few Routes as Possible

See files for this Use Case on GitHub here

Description

If a company has a small number of vehicles but a large number of orders, it can be difficult for management to find a way to cram all of the necessary addresses into each route.

The Route4Me API offers a solution to this problem - all you have to do is set the appropriate parameters.

Solution

Optimization Parameters and Addresses

To provide correct information for this use case, you need to pay attention to the following parameters:

ParameterDescription
vehicle_max_distance_miMaximum distance for a single vehicle in a route (always in miles)
route_max_durationMaximum amount of time it takes to complete a route (in seconds)
partsNumber of vehicles
parts_minMinimum number of vehicles
min_tour_sizeMinimum number of stops per route
max_tour_sizeMaximum number of stops per route

Addresses are without time windows and you can see them on the map as:

Create an Optimization

The cURL example below shows you how to create new optimized routes for this Use Case:

ParameterTypeDescription
api_keystringAPI KEY of the user
input dataPOST dataValid JSON object string. Click here to see the JSON Schema
1 @ECHO OFF
2 :: Single Depot, Multiple Driver, No Time Window
3 
4 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter1
5 
6 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
7 SET apikey=11111111111111111111111111111111
8 SET route_path_output=Points
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -X POST -k -d "@single_depot_multiple_driver_notime_window_data.json" "%url%?api_key=%apikey%&route_path_output=%route_path_output%"
13 
14 timeout /t 30

You can expect an Optimization Problem (see link), which generated some routes already.

View the Optimization details

You can get more details from the newly created Optimization Problem.

The endpoint: https://www.route4me.com/api.v4/optimization_problem.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
optimization_problem_idstringOptimization problem IDGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/optimization_problem.php
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=CE44FE1C4F46FACA59BE052489BE8642
6 
7 ECHO ON
8 curl -o file1.txt -g -X GET -k "%url%?api_key=%apikey%&optimization_problem_id=%optprobid%"
9 
10 timeout /t 30

See sample RESPONSE JSON data here

In the RESPONSE you can see an array of the addresses, which belong to 3 generated routes.

Attention
The first route with route-id=11A0D38B94DEF5607A29A5188B48D7CD is without the path_to_next object (array of geographic points), so it's not a real route.

Details of the Optimized Routes

Below is an example for one route; you can get the details of the remaining routes by using the same method and changing the parameter route_id.

The endpoint: https://www.route4me.com/api.v4/route.php

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_idstringRoute IDGET
route_path_outputstringIf equal to 'Points', you'll get an array of the path points to the next addressGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=11A0D38B94DEF5607A29A5188B48D7CD
6 SET rpo=Points
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -k -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

Note
In the RESPONSE you can see the array of the fields path_to_next and use them to draw routes on a map, exactly as they are generated by the Route4Me API.

You can see a route on the map drawn by the Route4Me API as:

You can draw the other 2 generated routes (as mentioned above, the first route is not real) as:

Same case on the Route4Me official website

You can try this Optimization Problem on Route4Me's official website.

You'll get this result on the map:

The official website generated 2 routes, as it did in our example, too.