1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! Path-dependent heuristics: estimates that also depend on how the search reached a state.
use crateHeuristic;
/// A heuristic whose estimate depends on the path to a state, through per-node information
/// the search carries along (Karpas & Domshlak 2009; LAMA's accepted landmarks).
///
/// The search calls [`PathHeuristic::root`] for the start state, [`PathHeuristic::on_expand`]
/// for every generated child, and [`PathHeuristic::merge`] when a second path reaches a state
/// it already holds information for; it stores the returned [`PathHeuristic::Info`] with the
/// node and passes it to [`PathHeuristic::estimate`].
///
/// An admissible path heuristic must give an estimate no higher than the state's true cost to
/// the goal for the information of *any* path to it, and for any merge of such information.
///
/// ```mermaid
/// graph LR
/// root["root(start)"] --> info["Info per node"]
/// info -->|"on_expand(parent, op, child)"| info
/// info -->|"merge (second path)"| info
/// info -->|"estimate(state, info)"| h["Option<C>"]
/// ```
///
/// Not part of `search_core` yet (see `docs/design.md`); a stateless [`Heuristic`] becomes a
/// path heuristic through [`Stateless`].
/// A stateless [`Heuristic`] as a [`PathHeuristic`] with no per-node information.
///
/// # Examples
///
/// ```
/// use planning_heuristics::{PathHeuristic, Stateless, heuristic_fn};
///
/// let mut h = Stateless(heuristic_fn(|n: &u32| 10_u32.checked_sub(*n)));
/// let info = PathHeuristic::<u32, ()>::root(&mut h, &3);
/// assert_eq!(PathHeuristic::<u32, ()>::estimate(&mut h, &3, &info), Some(7));
/// ```
;