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 toleranceImplementations§
Source§impl<S: Ord, C: Cost, const N: usize> MvhTable<S, C, N>
impl<S: Ord, C: Cost, const N: usize> MvhTable<S, C, N>
Sourcepub fn get(&self, state: &S) -> &[[C; N]]
pub fn get(&self, state: &S) -> &[[C; N]]
The estimates of state, sorted lexicographically; empty for a
dead end.
Sourcepub fn make_consistent<G>(&mut self, graph: &G)
pub fn make_consistent<G>(&mut self, graph: &G)
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.