pub struct ProvidedMatrix { /* private fields */ }Expand description
Caller-supplied cost matrix: explicit distance and time between every pair
of locations, addressed by LocationId (0 = depot, 1..=n = stops).
This is the matrix used when the caller brings their own routing numbers
(e.g. from a maps engine) instead of relying on the straight-line
HaversineMatrix. Both inner matrices are square and share the same n.
Implementations§
Source§impl ProvidedMatrix
impl ProvidedMatrix
Sourcepub fn new(
distances: Vec<Vec<f64>>,
times: Vec<Vec<f64>>,
) -> Result<Self, MatrixError>
pub fn new( distances: Vec<Vec<f64>>, times: Vec<Vec<f64>>, ) -> Result<Self, MatrixError>
Build from row-major distances and times, each an n×n matrix whose
rows and columns are indexed by LocationId (depot first, then stops).
§Errors
MatrixError::NotSquare if either matrix is empty or any row’s length
differs from the row count; MatrixError::SizeMismatch if the two
matrices disagree on n.
Sourcepub fn densify<M: CostMatrix>(source: &M, n: usize) -> Self
pub fn densify<M: CostMatrix>(source: &M, n: usize) -> Self
Materialise any CostMatrix into a dense n×n store, indexed by
LocationId 0..n.
The local search queries distance/time for the same pairs millions of
times; precomputing turns each query into an array read instead of (for
HaversineMatrix) recomputing great-circle trigonometry. The n²
upfront cost and the dense storage only pay off below a size bound, so the
caller decides when to densify.
Trait Implementations§
Source§impl Clone for ProvidedMatrix
impl Clone for ProvidedMatrix
Source§fn clone(&self) -> ProvidedMatrix
fn clone(&self) -> ProvidedMatrix
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl CostMatrix for ProvidedMatrix
impl CostMatrix for ProvidedMatrix
Source§fn distance(&self, a: LocationId, b: LocationId) -> f64
fn distance(&self, a: LocationId, b: LocationId) -> f64
a and b, in kilometres.Source§fn time(&self, a: LocationId, b: LocationId) -> f64
fn time(&self, a: LocationId, b: LocationId) -> f64
a and b, in hours.