In vehicle routing problems (VRPs) you may want your drivers to have a break at specific locations that are especially suitable for this. The router engine provides the Alternates
option to configure such stops for each vehicle. The router will then add exactly one of those stops optimally to the vehicle's route.
The Alternates
option is often combined with the Windows and the Services option to enforce a driver's break during the given time window for the specified "service time".
Example
The aim of this example is to define alternate stops (or breaks) for a vehicle. The introductory router example is used as a base, where routes are created to visit seven landmarks in Kyoto using two vehicles. Note, this example also uses the Capacity option for illustrative purposes.
Save the following information in an input.json
file (see input and output for more information on working with input files).
Code
The following program uses the CLI Runner to obtain a solution and requires access to the Nextmv code repository on GitHub. To request access, please contact support@nextmv.io.
To proceed with running the example, create a main.go
file and use the code snippet below.
To execute the example, specify the path to the input.json
file using command-line flags and use jq to extract the solution state (see runners for more information on building and running programs).
Solution
The solution should look similar to this one:
You can see that only one alternate stop was assigned to each vehicle. In this example, Nijō Castle
was assigned to v1
and Kiyomizu-dera
was assigned to v2
.