Traditional vehicle routing problems (VRP) require a depot where a route starts and ends. On the other hand, open vehicle routing problems (OVRP) do not specify an ending location for a vehicle. The router engine provides the Starts
and Ends
options to configure starting and ending locations for the vehicles, respectively. These options are independent of each other, so you could solve VRPs by configuring the same starts and ends or OVRPs by configuring either of those.
Example
The router example is used as a base, where routes are created to visit seven landmarks in Kyoto using two vehicles. This time, vehicle v1
has a starting location (but no end) and vehicle v2
has the same starting and ending locations.
Save the following information in an input.json
file (see input and output for more information on working with input files).
Note that the starts
and ends
indices map to the indices of the vehicles. This means that the starting location of vehicle v1
is {"lon": 135.73723, "lat": 35.04381}
and it has an empty ending location.
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 v1
has two stops assigned and is an open route, whereas v2
has five stops assigned in a closed route.