Nextmv provides a hosted map data service based on OSRM if you wish to use a pre-calculated distance matrix. The service is available as a paid add on to any paid plan. The service can be configured via the input file and can be used with either the Nextmv Routing marketplace app or custom apps.
This feature is configurable via .json
input, without the need for code customization, and is available for both the Marketplace app and Platform. You can find a list of all available features here.
This how-to guide assumes you already completed the get started with vehicle routing tutorial.
When duration_matrix
and distance_matrix
(with speed
) are both specified, the duration_matrix
takes precedence.
Field name | Required | Data type | SI Unit | Defined on | Example | Configurable via defaults |
---|---|---|---|---|---|---|
duration_matrix | No | array of array of float | seconds | input | {"duration_matrix": [[1.23, 4.56], [7.89, 0.12]]} | ➖ |
By default, the duration of traveling between two locations is calculated using the Haversine formula and factoring the speed
of each vehicle. To override this behavior, you can specify a duration matrix in the input that provides the duration of going from location A to B, using the duration_matrix
feature.
The duration_matrix
is useful when you want to use a different travel duration function, or when you want to use a pre-calculated duration matrix. For example, you may have your own mapping service that provides the travel duration between locations.
The duration_matrix
is an array
of array
s of float
. The units for the values are seconds
. The matrix must be square, and its size is:
Where:
n
: the number of stops.m
: the number of vehicles.
If you’re using Nextmv Maps, the max size for the duration matrix is 2,000 x 2,000. If you’re using your own matrix there is no size limit other than the 100 MB file size limit for the input file. The size follows that each float
value is the duration in seconds of traveling from location at index i
to location at index j
. Indices must be given in the following order:
The matrix may be asymmetric, meaning that the duration of going from location A to B may be different than the duration of going from location B to A.
Here is an example input defining a complete duration matrix. In this example, the duration to travel from "Fushimi Inari Taisha"
to "Kiyomizu-dera"
and viceversa is 720
seconds. Vehicle locations are omitted, given that the duration of going to/from them is zero.
A sample output obtained after solving the problem is also shown.