Search…
Measures
Overview of measures for your custom app.

Overview

Measures determine the cost of connecting two things together. This may mean assigning one item to another, clustering two points together, or routing a vehicle from one location to another. These cost computations are generically referred to as "measures". Nextmv provides several prebuilt measures and functionality for composing and augmenting measures.
Costs determined by measures (e.g., distance or time traveled) are used in Nextmv engines as part of the value function to make decisions. The measure interface is standardized, enabling measures to be used interchangably within an engine.
Most measures are defined in the package github.com/nextmv-io/code/engines/measure. Measures that rely on external dependencies, are found in the package github.com/nextmv-io/code/extend/measure.

Types of measures

There are two types of measures: point-to-point measures (measure.ByPoint) and indexed measures (measure.ByIndex). Each type is represented by a Go interface. All measure.ByPoint measures implement the method Cost(from, to Point) float64, which returns the cost to travel from one point to another. All measure.ByIndex measures refer to an underlying list of points and implement Cost(from, to int) float64, returning the cost to travel from one point at a particular index in the list to another.
Some engines may require a measure.ByPoint while others use a measure.ByIndex. It is simple to convert a measure.ByPoint to a measure.ByIndex using the Indexed method. For example:
Go
1
points := []measure.Point{...}
2
byPointMeasure := measure.EuclideanByPoint()
3
byIndexMeasure := measure.Indexed(byPointMeasure, points)
Copied!
See the pages linked below for information on the point-to-point and indexed measures available for use with Nextmv.

Point-to-point measures

Indexed measures

  • measure.Matrix: Matrix measure to look up the cost from a row to a column index
  • measure.Sparse: Sparse matrix measure to look up the cost from a row to a column index without requiring a full dataset.
  • osrm.DistanceMatrix(client, points): OSRM measure to determine the shortest path between two points on road networks; requires an OSRM client
  • osrm.DurationMatrix(client, points): OSRM measure to determine the shortest path between two points on road networks; requires an OSRM client
  • osrm.DistanceDurationMatrices(client, points): OSRM measure to determine the shortest path between two points on road networks in terms of distance and travel time; requires an OSRM client
  • routingkit.ByPoint: Routingkit measure to determine the shortest path between two points on road networks
  • routingkit.DurationByPoint: Routingkit measure to determine the shortest path in terms of travel time between two points on road networks
Last modified 20d ago