In vehicle routing problems (VRPs), you sometimes need to account for the amount of extra time required to enter a building or a fenced area. This allows for a more realistic VRP model that includes more than just loading and unloading times. This information can be added to the model using the ServiceGroups
option.
Example
The router example is used as a base, where routes are created to visit seven landmarks in Kyoto using two vehicles. This time, we define a service group of a few stops. In addition, we also use the Shifts
option to have ETA and ETD in the output.
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:
The estimated arrival and departure of the stops show that for the stops Fushimi Inari Taisha
and Kiyomizu-dera
the service time has been applied only once for both stops, because they were approached as one group. Also, the service time was applied to Nijō Castle
again, since it was approached as an isolated stop.