Split Addresses

See files for this Use Case on GitHub here

Split addresses among several routes.

Description

Route4Me supports three different optimization types: Single Driver Route, Multiple Drivers Route, and Balanced Team Route.

The “Multiple Drivers” optimization type uses a powerful algorithm that allows you to split your addresses into several routes, based on specific constraints such as duration, number of vehicles, time window constraints, etc.

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 with 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 :: Multiple Depot, Multiple Driver with 24 Stops, Time Window
3 :: Please put real value in route_date
4 
5 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter2:subchapter2
6 
7 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
8 SET apikey=11111111111111111111111111111111
9 
10 ECHO ON
11 
12 curl -o file1.txt -g -X POST -k -d "@multiple_depot_multiple_driver_with24stops_time_window_data.json" "%URL%?api_key=%apikey%"
13 
14 timeout /t 30

You can expect an Optimization Problem (see link), which has 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=0502D86404C439681E9499D80A2F180F
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 5 generated routes.

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 'Poitns', you'll get an array of the path points to next addressGET


1 @ECHO OFF
2 
3 SET url=https://www.route4me.com/api.v4/route.php
4 SET apikey=11111111111111111111111111111111
5 SET routeid=0A1C7BD129C70CDA271B957BF3E83A76
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 see all 5 routes drawn by the Route4Me API as:

Compare this to the route drawn by an OSM provider. Note: the sequence of the addresses is generated by the Route4Me API, but lines between them are drawn by an OSM provider.

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 results are different, because the online application refused to accept these parameters in the "Multiple Drivers Route" option. This solution was processed by the "Balanced Team Route" option.