symbolic_search/lib.rs
1//! # Symbolic search
2//!
3//! Symbolic state-space search over SAS+ tasks with binary decision diagrams
4//! (BDDs). Sets of states are BDDs over a binary encoding of the task's
5//! variables; one search step maps a whole layer of states at once through
6//! the operators' transition relations.
7//!
8//! ## Implemented
9//!
10//! - Binary encoding of [`sas_plus::Task`] states, with interleaved current
11//! and next bits and a Gamer-style static variable order
12//! ([`VariableOrder`]).
13//! - Per-operator transition relations, including conditional effects,
14//! merged per cost into disjunctive groups up to a node limit
15//! ([`Config::merge_node_limit`]), or split into per-variable conjunctive
16//! clusters with an early-quantification schedule
17//! ([`Partitioning::Conjunctive`]).
18//! - Symbolic forward and backward breadth-first search (unit cost).
19//! - Symbolic Dijkstra forward, backward and bidirectional (action costs,
20//! zero costs included).
21//! - `BDDA*` and symbolic greedy best-first search with a [`Heuristic`]
22//! stored as one BDD per `h` value: symbolic pattern databases
23//! ([`SymbolicTask::pdb`]), canonical PDB collections
24//! ([`SymbolicTask::canonical_pdbs`]), symbolic merge-and-shrink
25//! ([`SymbolicTask::merge_and_shrink`]) or explicit estimates
26//! ([`SymbolicTask::heuristic`]).
27//! - `SymBA*`: bidirectional `A*` with perimeter abstractions that drop
28//! variables or merge values by dropping single bits
29//! ([`AbstractionHierarchy`]), resumable abstract searches, separate concrete and abstract
30//! node limits and an expansion and time budget ([`SymbaConfig`]).
31//!
32//! Every search reconstructs a plan as operator ids in execution order and
33//! returns it with its cost ([`Solution`]). `SymBA*` budgets report the
34//! best plan so far and a lower bound ([`Error::BudgetExhausted`]).
35//! [`Config::for_task`] sizes the node table from the task, and running out
36//! of nodes retries with a larger table up to
37//! [`Config::max_node_capacity`]. Conjunctive clusters use a greedy or the
38//! IWLS95 quantification schedule ([`Schedule`]). The BDD library sits
39//! behind the public [`backend::Backend`] trait.
40//!
41//! ## Not yet implemented
42//!
43//! Axioms, mutex pruning, non-linear merge strategies and bisimulation for
44//! merge-and-shrink, time-based step estimates for `SymBA*`.
45//!
46//! ## Example
47//!
48//! ```
49//! use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
50//! use symbolic_search::{Config, SymbolicTask};
51//!
52//! // One counter from 0 to 2, incremented by two operators.
53//! let step = |from, to| Operator {
54//! name: format!("inc{from}"),
55//! pre: vec![Fact::new(0, from)],
56//! eff: vec![Effect::new(Fact::new(0, to))],
57//! cost: 1,
58//! };
59//! let task = Task {
60//! variables: vec![Variable::new("counter", 3)],
61//! operators: vec![step(0, 1), step(1, 2)],
62//! initial: State(vec![0]),
63//! goal: vec![Fact::new(0, 2)],
64//! axioms: vec![],
65//! };
66//!
67//! let config = Config {
68//! node_capacity: 1 << 10,
69//! cache_capacity: 1 << 8,
70//! ..Config::default()
71//! };
72//! let symbolic = SymbolicTask::new(&task, config)?;
73//! let solution = symbolic.forward_bfs()?.expect("the goal is reachable");
74//! assert_eq!(solution.plan, [0, 1]);
75//! assert_eq!(solution.cost, 2);
76//! # Ok::<(), symbolic_search::Error>(())
77//! ```
78//!
79//! Repository: <https://github.com/sunsided/symbolic-search>
80
81#![forbid(unsafe_code)]
82
83pub mod backend;
84mod encoding;
85mod error;
86mod model;
87mod order;
88mod relation;
89mod search;
90
91pub use error::Error;
92pub use order::VariableOrder;
93pub use search::{
94 AbstractionHierarchy, Config, DEFAULT_MAX_SUBSETS, Heuristic, Partitioning, Schedule, Solution,
95 SymbaConfig, SymbolicTask,
96};