pub struct DynamicSearch<C, P, const N: usize> { /* private fields */ }Expand description
An incremental multi-objective search on a DynamicGraph: every
state keeps the Pareto set of path costs from the start (label
correcting), and edge changes repair only what they touch.
After DynamicSearch::set_cost, DynamicSearch::remove_edge or
DynamicSearch::add_edge, the labels whose paths use the changed
edge, and everything built on them, are dropped; every state that lost a
label is re-seeded from the live labels of its predecessors, and label
correcting runs from there, as LPA* re-expands only the inconsistent
part of its search tree. Labels elsewhere stay. DynamicSearch::front
then equals a fresh search’s front.
Goal states end paths. Edge costs must be non-negative.
§Examples
use multiobjective_search::{DynamicGraph, DynamicSearch};
let mut graph = DynamicGraph::new(3);
let direct = graph.add_edge(0, 2, [10_u32, 1]);
graph.add_edge(0, 1, [1, 5]);
graph.add_edge(1, 2, [1, 5]);
let mut search = DynamicSearch::new(graph, 0, |s: &u32| *s == 2);
let costs = |s: &DynamicSearch<_, _, 2>| s.front().solutions.iter().map(|x| x.cost).collect::<Vec<_>>();
assert_eq!(costs(&search), [[2, 10], [10, 1]]);
search.set_cost(direct, [1, 1]); // the direct road got better
assert_eq!(costs(&search), [[1, 1]]);Implementations§
Source§impl<C: Cost, P: Fn(&u32) -> bool, const N: usize> DynamicSearch<C, P, N>
impl<C: Cost, P: Fn(&u32) -> bool, const N: usize> DynamicSearch<C, P, N>
Sourcepub fn new(graph: DynamicGraph<C, N>, start: u32, is_goal: P) -> Self
pub fn new(graph: DynamicGraph<C, N>, start: u32, is_goal: P) -> Self
Sourcepub const fn graph(&self) -> &DynamicGraph<C, N>
pub const fn graph(&self) -> &DynamicGraph<C, N>
The current graph.
Sourcepub fn remove_edge(&mut self, id: usize)
pub fn remove_edge(&mut self, id: usize)
Auto Trait Implementations§
impl<C, P, const N: usize> Forget for DynamicSearch<C, P, N>
impl<C, P, const N: usize> Freeze for DynamicSearch<C, P, N>
impl<C, P, const N: usize> Move for DynamicSearch<C, P, N>
impl<C, P, const N: usize> RefUnwindSafe for DynamicSearch<C, P, N>
impl<C, P, const N: usize> Send for DynamicSearch<C, P, N>
impl<C, P, const N: usize> Sync for DynamicSearch<C, P, N>
impl<C, P, const N: usize> Unpin for DynamicSearch<C, P, N>
impl<C, P, const N: usize> UnsafeUnpin for DynamicSearch<C, P, N>
impl<C, P, const N: usize> UnwindSafe for DynamicSearch<C, P, 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