Expand description
§Stochastic search
Planning under probabilistic outcomes: value iteration, RTDP, labeled RTDP, BRTDP, FRTDP, VPI-RTDP, LAO*, iLAO* and CG-iLAO* for fully observable problems, MOLAO*, iMOLAO* and MOLRTDP for multi-objective ones; POMCP and DESPOT for partially observable ones.
A problem is a stochastic shortest path (SSP) problem: reach a goal state with minimal
expected total cost, where every action has a cost and a probability distribution over
successor states. It is described by small capability traits instead of one universal
problem trait: the MDP implements Mdp, the goal test is a Goal and the initial
value estimate a Heuristic. Closures work for both (wrap heuristic closures in
heuristic_fn). Every algorithm takes
a Config and returns a Solution: a value function and a greedy policy, plus a
Status and Stats.
Partially observable problems are generative models (Pomdp): a step samples successor,
observation and reward from a rand_core generator. The online planners pomcp() and
despot() take a particle belief and return a Plan for one decision.
The crate is no_std and needs only alloc.
§Algorithms
lrtdp(): labeled real-time dynamic programming (Bonet and Geffner 2003). Explores only the states a good policy visits; epsilon-consistent on them when it converges.rtdp(): plain RTDP (Barto, Bradtke and Singh 1995), with LRTDP’s solved check as its stopping rule. The classic baseline.brtdp(): bounded RTDP (McMahan, Likhachev and Gordon 2005). Keeps a lower and an upper bound and samples where they are far apart; anytime, with a known gap.frtdp(): focused RTDP (Smith and Simmons 2006). The same bounds; trials follow the successor of highest priority with an adaptive depth limit.vpi_rtdp(): VPI-RTDP (Sanner et al. 2009). The same bounds; trials follow the value of perfect information about successors where the bounds are informative.lao_star(): classic LAO* (Hansen and Zilberstein 2001), one tip per expansion step with value iteration on its ancestors. The paper’s original; slower than iLAO*.cg_ilao_star(): CG-iLAO* (Schmalz and Trevizan 2024). iLAO* over a partial SSP that adds an action only when constraint generation finds it necessary.ilao_star(): improved LAO* (Hansen and Zilberstein 2001). Grows the best partial solution graph in depth-first passes; no sampling.value_iteration(): value iteration over every reachable state. The exact reference.pomcp(): partially observable Monte-Carlo planning (Silver and Veness 2010). UCT over action-observation histories with rollouts.despot(): anytime regularized DESPOT (Somani et al. 2013, Ye et al. 2017). Bound guided search over a tree ofKdeterminized scenarios.molrtdp(),molao_star(),imolao_star()andmo_value_iteration(): multi-objective SSPs (Chen, Trevizan and Thiébaux 2023) over anMoMdpwith cost vectors. They return anMoSolution, a convex coverage set of deterministic policies; heuristics areZeroVector,IdealPointandAbstraction(also overDeterminized).PomcpandDespot: the same planners kept between decisions, reusing the subtree after the action taken and the observation received;update_beliefis POMCP’s particle filter with reinvigoration.
§The heuristic contract
Goal, Heuristic, heuristic_fn and Budget are re-exported from
search-core, shared with the other planning crates. The algorithms here use
Heuristic<S, f64> (closures infer f64) under this contract:
estimateis called once per state, when the state is first stored; never for goals. It takes&mut self, so a heuristic can keep a workspace; algorithms take it by value, pass&mut hto keeph.None(or an infinite estimate) means no proper policy exists from the state, a proven dead end that is never expanded. Return it only when that is certain.- NaN and negative infinity are rejected with
Error::InvalidHeuristic. - The optimality guarantees need an admissible heuristic (never above the optimal expected cost). Inadmissible ones never panic; they only void the guarantee.
Zero, the blind heuristic, is search-core’s too; it estimates 0.0 for f64.
The multi-objective algorithms take cost-vector sets and use ZeroVector instead.
§Dead ends
States from which no policy reaches a goal with probability 1 are valued per
DeadEnds: at infinity (the default, exact SSP semantics), or at a finite give-up
penalty that makes every input solvable. The bounded algorithms (brtdp(), frtdp(),
vpi_rtdp()) need finite upper bounds, so under infinite dead ends their lower bound
must prove the dead ends they meet.
§Events
An Observer set with Config::with_observer receives Events while a run
progresses: progress, proven dead ends, and suspected divergence (a heuristic signal,
never a verdict). The default observer () costs nothing.
§Example
use stochastic_search::{Config, Mdp, heuristic_fn, lrtdp};
/// A die roll: action `roll` (cost 1) ends on a six; action `pay` (cost 4) ends always.
struct Dice;
impl Mdp for Dice {
type State = bool;
type Action = &'static str;
fn actions(&self, _done: &bool, mut emit: impl FnMut(&'static str, f64)) {
emit("roll", 1.0);
emit("pay", 4.0);
}
fn outcomes(&self, _done: &bool, action: &&'static str, mut emit: impl FnMut(bool, f64)) {
match *action {
"roll" => {
emit(true, 1.0 / 6.0);
emit(false, 5.0 / 6.0);
}
_ => emit(true, 1.0),
}
}
}
let heuristic = heuristic_fn(|_: &bool| Some(1.0));
let solution = lrtdp(&Dice, false, &|done: &bool| *done, heuristic, Config::default())?;
// Rolling takes 6 attempts in expectation, so paying 4 is cheaper.
assert_eq!(solution.initial_action(), Some(&"pay"));
assert!((solution.initial_value() - 4.0).abs() < 1e-5);See docs/design.md in the repository for the design.
Repository: https://github.com/sunsided/stochastic-search
Re-exports§
pub use mo::Abstraction;pub use mo::Determinized;pub use mo::IdealPoint;pub use mo::MoMdp;pub use mo::MoPolicy;pub use mo::MoSolution;pub use mo::MoSolveResult;pub use mo::Objectives;pub use mo::ZeroVector;pub use mo::imolao_star;pub use mo::mo_value_iteration;pub use mo::molao_star;pub use mo::molrtdp;
Modules§
- mo
- Multi-objective stochastic shortest path problems (MOSSPs) and the heuristic search algorithms of Chen, Trevizan and Thiébaux (2023): MOLAO*, iMOLAO* and MOLRTDP, with multi-objective value iteration (MOVI) as the exact reference.
Structs§
- Belief
Filter - Settings of
update_belief. - Belief
Update - The posterior particles of
update_beliefand how they came about. - Brtdp
Config - Settings of
brtdp: the sharedConfigand BRTDP’s trial-end ratio. - Config
- Settings shared by all algorithms.
- Despot
- A DESPOT planner that keeps its tree between decisions.
- Despot
Config - Settings of
despot. - Frtdp
Config - Settings of
frtdp: the sharedConfigand FRTDP’s adaptive maximum depth. - Heuristic
Fn - A closure used as a
Heuristic; created byheuristic_fn. - Limits
- Simple counter limits.
- Observer
Fn - A closure used as an
Observer; created byobserver_fn. - Plan
- The answer of an online POMDP planner for one decision.
- Pomcp
- A POMCP planner that keeps its search tree between decisions.
- Pomcp
Config - Settings of
pomcp. - Solution
- A value function and a greedy policy over the states a run touched.
- Split
Mix64 - The
SplitMix64generator (Steele, Lea and Flood 2014). - Stats
- Counters collected during one run of an algorithm.
- Step
- One sampled transition of a
Pomdp. - Tree
Stats - Counters collected during one call of a tree planner (
pomcp,despot), returned inPlan::statsand given to the budget. - Uniform
Random - The rollout policy that picks every action with equal probability.
- VpiRtdp
Config - Settings of
vpi_rtdp: the sharedConfigand VPI-RTDP’s two thresholds. - Zero
- The blind heuristic: estimates
Cost::ZEROeverywhere. Turns A* into Dijkstra’s algorithm and is admissible and consistent for every non-negative cost.
Enums§
- Dead
Ends - How states without a proper policy are valued.
- Error
- Invalid input found while solving. Each variant names the state where it was found.
- Event
- Something worth reporting while an algorithm runs.
- Status
- How a run ended.
Constants§
- PROBABILITY_
TOLERANCE - The tolerance on the sum of an action’s outcome probabilities.
Traits§
- Budget
- Decides when a search must stop before it finishes, given its counters so far.
- Goal
- A goal test over states of type
S. - Heuristic
- An estimate of the cost from a state of type
Sto the nearest goal, in cost typeC. - Mdp
- A finite Markov decision process with action costs.
- Observer
- Receives
Events while an algorithm runs. - Pomdp
- A partially observable Markov decision process, given as a generative model.
- Rollout
Policy - Picks actions for simulations below the search tree: POMCP’s rollout policy and DESPOT’s default policy (whose simulated value is DESPOT’s lower bound).
Functions§
- brtdp
- Solves an SSP from
initialwith bounded RTDP, keeping a lower and an upper bound on every stored state’s optimal value. - cg_
ilao_ star - Solves an SSP from
initialwith CG-iLAO*. - despot
- Plans one action from the particle belief
beliefwith anytime regularized DESPOT. - frtdp
- Solves an SSP from
initialwith focused RTDP, keeping a lower and an upper bound on every stored state’s optimal value. - heuristic_
fn - Turns a closure
FnMut(&S) -> Option<C>into aHeuristic. - ilao_
star - Solves an SSP from
initialwith iLAO*. - lao_
star - Solves an SSP from
initialwith classic LAO*, one tip at a time. - lrtdp
- Solves an SSP from
initialwith labeled RTDP. - observer_
fn - Turns a closure
FnMut(Event)into anObserver. - pomcp
- Plans one action from the particle belief
beliefwith POMCP. - pomcp_
exploration - The paper’s exploration constant
c = R_hi - R_loforPomcpConfig::exploration: runssimulationssimulations of POMCP frombeliefwithc = 0and returns the highest discounted return of a simulation minus the lowest discounted return of a rollout (Silver and Veness 2010, Section 6: “R_hiwas the highest return achieved during sample runs of POMCP withc = 0, andR_lowas the lowest return achieved during sample rollouts”). - rtdp
- Solves an SSP from
initialwith plain RTDP: greedy trials without solved labels. - unit_
interval - Returns a uniform sample from
[0, 1)with 53 random bits drawn fromrng. - update_
belief - Updates the particle belief
beliefafter takingactionand receivingobservation, with the Monte-Carlo particle filter of POMCP (Silver and Veness 2010, Section 3.2). - value_
iteration - Solves an SSP from
initialwith Gauss-Seidel value iteration over every reachable state. - vpi_
rtdp - Solves an SSP from
initialwith VPI-RTDP, keeping a lower and an upper bound on every stored state’s optimal value.
Type Aliases§
- Solve
Result - The result of solving the MDP
M: aSolutionor theErrorthat stopped the run.