In vehicle routing problems (VRPs) it is often necessary to not only know the best route but also the estimated time of arrival (ETA) per stop on the route to inform customers. By default the router engine provides the route duration but not the ETA because the time reference for the start of the route is missing. To add this information the router engine
provides the Shifts
option. If the given shifts not only specify the start times but also a shift's end time, the router engine
will make sure that the routes are completed within the given shift's start and end.
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 shifts for both vehicles, but only one vehicle has a start and end time defined.
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 output now includes estimated time of arrival and departure (note, these times are equal for each stop in this example) in addition to route duration. To take into account service times at a stop, please use the Services option. Because of the short time window that the shift offers for v1
, most stops are assigned to v2
.