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.
There are different ways to specify the duration matrix. Depending on your use case, you can choose between the following options:
- The
duration_matrix
is anarray
ofarray
s offloat
. - The
duration_matrix
can handle time dependent travel times, to model e.g. traffic conditions by providing a matrix or by scaling a default matrix for each time period. - The
duration_matrix
can be provided as in the case before but specified for different vehicles. This is useful when you want to model e.g. different vehicles with different speeds (cars and bikes, for example).
Whenever you specify a duration_matrix
, you need to make sure that 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 are the examples for the different ways to specify the 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.