pub struct DifferentialHeuristic<S, C, const N: usize> { /* private fields */ }Expand description
Differential heuristics (Goldberg and Harrelson 2005) per objective:
exact distances from and to a few landmark states, giving for any goal
g the consistent lower bound
h_i(v) = max_L max(d_i(L, g) - d_i(L, v), d_i(v, L) - d_i(g, L), 0)
by the triangle inequality. It is consistent along every edge whose
head can reach the goal (a term undefined for lack of a path is left
out).
The memory-based heuristics the survey discusses for multi-objective
search; Zhang et al. 2023 extend them to multi-valued bi-objective
forms. Build once per graph with DifferentialHeuristic::new, then
aim at a goal with DifferentialHeuristic::towards.
§Examples
use multiobjective_search::{DifferentialHeuristic, Graph, Heuristic, ReverseGraph};
/// A path 0 - 1 - 2 - 3 in both directions, unit costs.
struct Path;
impl Graph for Path {
type State = u8;
type Weight = [u32; 1];
fn successors(&self, s: &u8, out: &mut Vec<(u8, [u32; 1])>) {
if *s > 0 { out.push((s - 1, [1])); }
if *s < 3 { out.push((s + 1, [1])); }
}
}
impl ReverseGraph for Path {
fn predecessors(&self, s: &u8, out: &mut Vec<(u8, [u32; 1])>) {
self.successors(s, out);
}
}
let dh = DifferentialHeuristic::new(&Path, [0]);
let mut h = dh.towards(&3);
assert_eq!(h.estimate(&1), Some([2])); // exact here: the landmark is an endImplementations§
Source§impl<S: Clone + Ord, C: Cost + WideMul, const N: usize> DifferentialHeuristic<S, C, N>
impl<S: Clone + Ord, C: Cost + WideMul, const N: usize> DifferentialHeuristic<S, C, N>
Sourcepub fn new<G>(graph: &G, landmarks: impl IntoIterator<Item = S>) -> Selfwhere
G: ReverseGraph<State = S, Weight = [C; N]>,
pub fn new<G>(graph: &G, landmarks: impl IntoIterator<Item = S>) -> Selfwhere
G: ReverseGraph<State = S, Weight = [C; N]>,
Computes the landmark distances: two Dijkstras per landmark and objective, over the finite reachable graph.
Trait Implementations§
Auto Trait Implementations§
impl<S, C, const N: usize> Forget for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> Freeze for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> Move for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> RefUnwindSafe for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> Send for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> Sync for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> Unpin for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> UnsafeUnpin for DifferentialHeuristic<S, C, N>
impl<S, C, const N: usize> UnwindSafe for DifferentialHeuristic<S, C, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more