Skip to main content

MvhTable

Struct MvhTable 

Source
pub struct MvhTable<S, C, const N: usize> { /* private fields */ }
Expand description

A multi-valued heuristic stored as a table: per state, a set of mutually non-dominated estimates. A state without an entry is a dead end.

Build one with apex_mvh, and make it consistent with MvhTable::make_consistent for namoa_star_dr_mvh.

§Examples

use multiobjective_search::{Epsilon, Graph, MvHeuristic, ReverseGraph, apex_mvh};

/// Two routes from 0 to the goal 1.
struct Routes;

impl Graph for Routes {
    type State = u8;
    type Weight = [u32; 2];

    fn successors(&self, state: &u8, out: &mut Vec<(u8, [u32; 2])>) {
        if *state == 0 {
            out.extend([(1, [1, 5]), (1, [4, 2])]);
        }
    }
}

impl ReverseGraph for Routes {
    fn predecessors(&self, state: &u8, out: &mut Vec<(u8, [u32; 2])>) {
        if *state == 1 {
            out.extend([(0, [1, 5]), (0, [4, 2])]);
        }
    }
}

let mut h = apex_mvh(&Routes, [1], [Epsilon::ZERO; 2]);
let mut out = Vec::new();
h.estimates(&0, &mut out);
assert_eq!(out, [[1, 5], [4, 2]]); // exact with zero tolerance

Implementations§

Source§

impl<S: Ord, C: Cost, const N: usize> MvhTable<S, C, N>

Source

pub fn get(&self, state: &S) -> &[[C; N]]

The estimates of state, sorted lexicographically; empty for a dead end.

Source

pub fn size(&self) -> usize

The total number of estimates over all states.

Source

pub fn make_consistent<G>(&mut self, graph: &G)
where S: Clone, G: ReverseGraph<State = S, Weight = [C; N]>,

Makes the table consistent in the monotone sense (see MvHeuristic) by Bellman-Ford label updates: while some edge (s, t) with cost c has an estimate h' of t such that no estimate of s weakly dominates c + h', add c + h' to s and drop the estimates it dominates.

Only lower bounds are added, so an admissible table stays admissible. Wolff et al. add c + h' when it strictly dominates an estimate of s; adding it whenever it is not covered is what guarantees the monotone form. The fix-point exists on finite graphs: every added vector is an original estimate plus a path cost, and one that runs around a cycle is weakly dominated by the vector without the cycle. States whose estimates change are revisited through their predecessors.

Trait Implementations§

Source§

impl<S: Clone, C: Clone, const N: usize> Clone for MvhTable<S, C, N>

Source§

fn clone(&self) -> Self

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<S: Debug, C: Debug, const N: usize> Debug for MvhTable<S, C, N>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: Ord, C: Cost, const N: usize> MvHeuristic<S, [C; N]> for MvhTable<S, C, N>

Source§

fn estimates(&mut self, state: &S, out: &mut Vec<[C; N]>)

Appends the estimates of state to out. Read more
Source§

impl<S: Ord, C: Cost, const N: usize> MvHeuristic<S, [C; N]> for &MvhTable<S, C, N>

Source§

fn estimates(&mut self, state: &S, out: &mut Vec<[C; N]>)

Appends the estimates of state to out. Read more

Auto Trait Implementations§

§

impl<S, C, const N: usize> Forget for MvhTable<S, C, N>

§

impl<S, C, const N: usize> Freeze for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: Freeze,

§

impl<S, C, const N: usize> Move for MvhTable<S, C, N>

§

impl<S, C, const N: usize> RefUnwindSafe for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: RefUnwindSafe,

§

impl<S, C, const N: usize> Send for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: Send,

§

impl<S, C, const N: usize> Sync for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: Sync,

§

impl<S, C, const N: usize> Unpin for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: Unpin,

§

impl<S, C, const N: usize> UnsafeUnpin for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: UnsafeUnpin,

§

impl<S, C, const N: usize> UnwindSafe for MvhTable<S, C, N>
where BTreeMap<S, Front<C, N>>: UnwindSafe,

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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.