Create Routes to Visit VIP Customers

See files for this Use Case on GitHub here

You can set special conditions for VIP customers.

Note
A VIP address is an address that has a higher priority than other addresses.

Description

Some customers generate an exceptional amount of revenue for a business, or they're important in some other way. For such customers, Route4Me has introduced the parameter of "priority" in the object "Address". If priority = 0, the customer has highest priority. 1 means less priority that 0, 2 means less than 1, etc.

So, let's say you have a case with multiple depots and multiple drivers with time windows (TW) and two customers/addresses have priority 1, another one has priority 2, and the rest of the addresses have priority 5. The optimization will first try to preserve the time windows of the two priority 1 customers, and after that the time window of the customer with priority 2 will be considered.

Solution

Review addresses for an optimization

The addresses for the optimization are stored in the file multiple_depot_with_time_window_data.json. Most of the addresses in this file have priority 5. Three addresses have different priorities.

You can see these addresses on the map as:

Addresses with high priority (priority < 5) are labeled for better presentation.

Create an optimization

Now you can run an optimization script for getting optimized routes.

Note
The parameter route_path_output enables you to get route points for drawing a route generated by the Route4Me API engine. Of course, you can draw routes using other means, too (by using an OSM provider, for example).

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

HTTP Parameters

AttributeTypeDescriptionHTTP
method
api_keystringAPI KEY of the userGET
route_path_outputstringIf equal to 'Poitns', you'll get an array of path points to next addressGET
parametersRoute ParametersValid JSON object string. Click here to see the JSON SchemaPOST
addressesarrayValid JSON string of Address object array. lick here to see the JSON SchemaPOST


Create a new Optimization Problem with multiple depots, drivers and VIP customers.
1 @ECHO OFF
2 :: Multiple Depot, Multiple Driver, Time Window
3 :: Put real value in route_date
4 
5 ::See video tutorial here: http://support.route4me.com/route-planning-help.php?id=manual0:tutorial2:chapter3:subchapter2
6 
7 SET URL=https://www.route4me.com/api.v4/optimization_problem.php
8 SET apikey=11111111111111111111111111111111
9 SET route_path_output=Points
10 
11 ECHO ON
12 
13 curl -o file1.txt -g -X POST -k -d "@multiple_depot_with_time_window_data.json" "%URL%?api_key=%apikey%&route_path_output=%route_path_output%"
14 
15 timeout /t 30

The Route4Me API created Optimization Problem with optimization_problem_id = "07A150F52EEB318B28000F79FF7282BA".

See sample RESPONSE JSON data here

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


Get details of the generated Optimization Problem.
1 @ECHO OFF
2 
3 SET url=https://www.route4me.com
4 SET apikey=11111111111111111111111111111111
5 SET optprobid=07A150F52EEB318B28000F79FF7282BA
6 
7 ECHO ON
8 curl -o file1.txt -g -X GET -k "%url%/api.v4/optimization_problem.php?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 addresses, which belong to four 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=http://www.route4me.com
4 SET apikey=11111111111111111111111111111111
5 SET routeid=8242F8854C00C65586C1BFE9F6F5A157
6 SET rpo=Points
7 
8 ECHO ON
9 
10 curl -o file1.txt -g -X GET "%url%?route_id=%routeid%&api_key=%apikey%&route_path_output=%rpo%"
11 
12 timeout /t 30

See sample RESPONSE JSON data here

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 routes on the map drawn by the Route4Me API as:

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

You can draw all of the generated routes as:

Compare to non-Vip case

If you run the above listed steps again, but with equal priority for all addresses, you'll get this result:

Same case on the Route4Me official website

You can try this Optimization Problem on Route4Me's official website and with appropriate parameters generate optimal routes. You'll get this result:

The result is a little different, because the official map is for users and the parameters are chosen for users. You, as a programmer, have more options to influence the result. And the drawing tools of the official Route4Me website are far more advanced than most open source tools (GMap.Net in this case).