In vehicle routing problems (VRPs) it is sometimes needed to assign stops directly to vehicles. This can be the case if only some vehicles do have a specific configuration, such as a cooling system. Another common use is that sometimes routes from previous decisions exist that cannot be changed.
The router engine provides the Backlogs
option to configure backlogs for vehicles. This is done by setting a list of stops for a vehicle.
Example
The aim of this example is to define a backlog 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.
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 both stops, Arashiyama Bamboo Forest
and Kinkaku-ji
, which have been defined in a backlog for vehicle v1
, are assigned to that vehicle.