Skip to main content

ProvidedMatrix

Struct ProvidedMatrix 

Source
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

Source

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.

Source

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 upfront cost and the dense storage only pay off below a size bound, so the caller decides when to densify.

Source

pub fn len(&self) -> usize

Number of locations the matrix covers (stops + 1).

Source

pub fn is_empty(&self) -> bool

Whether the matrix is empty (never true for a value built by Self::new).

Trait Implementations§

Source§

impl Clone for ProvidedMatrix

Source§

fn clone(&self) -> ProvidedMatrix

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CostMatrix for ProvidedMatrix

Source§

fn distance(&self, a: LocationId, b: LocationId) -> f64

Great-circle / road distance between a and b, in kilometres.
Source§

fn time(&self, a: LocationId, b: LocationId) -> f64

Travel time between a and b, in hours.
Source§

impl Debug for ProvidedMatrix

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V