pub struct Config {
pub pruning: Pruning,
pub fold_g: bool,
pub leaves: Leaves,
pub max_analysis_states: usize,
pub reduce_leaves: bool,
pub stubborn_sets: bool,
pub symbolic_leaves: bool,
pub symbolic_min_states: usize,
pub symbolic_center: bool,
}Expand description
Options for decoupled search.
§Examples
use decoupled_search::{Config, Factoring, Pruning};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
let op = |pre: Vec<Fact>, eff: Fact| Operator {
name: "op".into(),
pre,
eff: vec![Effect::new(eff)],
cost: 1,
};
let task = Task {
variables: vec![Variable::new("truck", 2), Variable::new("pkg", 3)],
operators: vec![
op(vec![Fact::new(0, 0)], Fact::new(0, 1)),
op(vec![Fact::new(0, 1)], Fact::new(0, 0)),
op(vec![Fact::new(0, 0), Fact::new(1, 0)], Fact::new(1, 2)),
op(vec![Fact::new(0, 1), Fact::new(1, 2)], Fact::new(1, 1)),
],
initial: State(vec![0, 0]),
goal: vec![Fact::new(1, 1)],
axioms: vec![],
};
let config = Config {
pruning: Pruning::Basic,
..Config::default()
};
let outcome = config.search(&task, &Factoring::fork(&task))?;
assert_eq!(outcome.plan.map(|p| p.cost), Some(3));
assert!(outcome.statistics.expanded >= 1);Fields§
§pruning: PruningThe dominance criterion. Default: Pruning::Adaptive.
fold_g: boolWhether a stored state may dominate one reached more cheaply, when
its cheaper prices pay for the difference in g (one budget shared
by all leaves). Without it, the stored state needs no higher g.
Default: true.
leaves: LeavesPrices or reachability only. Default: Leaves::Priced.
max_analysis_states: usizeThe largest leaf (in leaf states) that frontier, effective-price and simulation analyses run on; larger leaves use the basic comparison. Simulation takes time quadratic in the leaf size per refinement round, effective prices keep one bound per leaf state in every stored state. Default: 256.
reduce_leaves: boolWhether to shrink the leaf state spaces by leaf simulation before
searching: the superfluous-transition rule of Torralba, Gnad,
Dubbert and Hoffmann (IJCAI 2016, Section 6 of the extended
technical report), with a removal order that makes it sound.
Default: false.
On every analysed leaf (see Config::max_analysis_states), the
leaf simulation ⪯ of Pruning::Simulation is computed once.
Say that x -b-> y' replaces x -a-> x' if cost(b) <= cost(a),
b’s center preconditions are contained in a’s, and x' ⪯ y'. A
leaf transition x -a-> x' is removed if
x' ⪯ x: staying atxis as good, or- another leaf action
bapplicable inxreplaces it, and eitheradoes not replacebin turn orbhas the smaller index.
The report states rule 2 without the last condition and without a
removal order; read as one simultaneous step, it would remove both
of two transitions that replace each other (for example two copies
of one action), which is unsound. Removing one transition at a time,
each justified by one still present, removes exactly what the rules
above remove, up to which of two mutually replacing transitions
stays. The report also drops leaf states that become unreachable and
leaf actions without transitions; here leaf closure skips removed
transitions, so those states are never reached and stored
(Statistics::reduced_leaf_transitions and
Statistics::unreachable_leaf_states report the effect).
Config::reduced_task drops the operators left without a useful
transition, for building heuristics.
Soundness (the report gives no proof). “Replaces” is reflexive and
transitive on the transitions leaving x; ordering by it, and by
index between transitions that replace each other, is a strict
partial order on a finite set, and rule 2 removes only transitions
below a greater one. Take any compliant leaf path ρ of the full
leaf system, and its first removed step s_i -a-> s_{i+1}.
Following rule 2 upwards ends in a maximal transition s_i -c-> z,
which rule 2 keeps, with s_{i+1} ⪯ z by transitivity; if rule 1
removes it, staying at s_i (z ⪯ s_i) is as good. c is
applicable wherever a was (weaker center preconditions) and no
dearer. By the simulation, the rest of ρ is mirrored from z (or
s_i) at no higher cost, in no more steps, meeting the same global
preconditions and ending in a goal leaf state. Repeating at the next
removed step terminates: each round either fixes one more step or
(staying) shortens the path. So every completion of the full system
has one of the reduced system at no higher cost, which preserves
optimality and solvability, and every reduced completion is a real
one. The dominance analyses still use the full transitions, which
only makes frontier and effective-price bounds more conservative,
and mirrored paths in the simulation bound are converted the same
way.
stubborn_sets: boolWhether to apply, in every expanded state, only the global actions
of a decoupled strong stubborn set (Gnad, Hoffmann and Wehrle, JAIR
2019, Definitions 4 to 8, general star topologies, with the paper’s
approximations). Default: false.
The set is the closure of: in a non-goal state, the achievers of an
open part of the goal (a leaf fact no reached leaf state has, else a
leaf’s goal part no single reached leaf state has, else a center
fact); in a goal state, the actions that could still lower some
leaf’s goal price (none: the state is not expanded); for an
unreached action in the set, the achievers of an open part of its
precondition; for a reached one, every action that interferes with
it and has a consistent precondition, and every action leaving a
reached leaf state towards its leaf preconditions. The paper proves
that this keeps a strongly optimal decoupled plan, so uniform-cost
search, A* and anytime A* stay optimal and every search stays
complete. Statistics::stubborn_pruned counts what it removes.
Where the paper’s guarantee stops:
- Tasks with conditional effects or axioms are searched with full expansion; the construction is not defined for them.
- The paper covers duplicate detection, not dominance pruning. For
Pruning::Basic,Pruning::FrontierandPruning::EffectivePriceswithConfig::fold_goff, a dominating state can follow the pruned one’s center path at no higher cost, which is the property the proof needs (an argument of this crate, not a proof). The other criteria,fold_g, andConfig::reduce_leavesrest on the randomized cross-checks against Dijkstra only.
symbolic_leaves: boolWhether to keep the pricing function of every leaf with at least
Config::symbolic_min_states states as binary decision diagrams,
one per price, instead of a price per enumerated leaf state (Gnad,
Torralba and Hoffmann 2017); smaller leaves stay enumerated. Needs
the symbolic-leaves feature. Default: false.
The decoupled state space is the same as with explicit leaves, so
costs, plans and the number of expanded states agree; leaves larger
than crate::MAX_LEAF_STATES become searchable when their reached
sets have small diagrams. Supports every search and heuristic and
both Leaves modes, with Pruning::Basic (with or without
Config::fold_g) only; other criteria, Config::reduce_leaves,
Config::stubborn_sets, conditional effects and axioms are
rejected with Error::SymbolicUnsupported.
symbolic_min_states: usizeThe fewest leaf states for which Config::symbolic_leaves uses
diagrams; 0 makes every leaf symbolic. Default: 1024, about where
diagrams start to pay off on the crate’s benchmark.
symbolic_center: boolWhether to expand sets of center states at once: a search node is a
set of center states, kept as a BDD, that share one pricing function
and one g. Needs the symbolic-leaves feature; leaves follow
Config::symbolic_leaves and Config::symbolic_min_states.
Default: false.
This is the crate’s own formulation, not a published one;
docs/design.md argues why it is sound, and the randomized
cross-checks against Dijkstra test it. Each member is an ordinary
decoupled state, so cost-optimal searches stay optimal; the nodes
differ from the explicit search’s, so the counters do too. Supports uniform-cost search, A* and GBFS with
Pruning::Basic and Config::fold_g off, under the same
restrictions as Config::symbolic_leaves; anytime A* and fold_g
are rejected with Error::SymbolicUnsupported. Heuristics see a
center fact as reached when some member has it.
Implementations§
Source§impl Config
impl Config
Sourcepub fn search(
&self,
task: &Task,
factoring: &Factoring,
) -> Result<Outcome, Error>
pub fn search( &self, task: &Task, factoring: &Factoring, ) -> Result<Outcome, Error>
Uniform-cost decoupled search with this configuration; see
search().
§Errors
As search(), and Error::ReachabilityNotOptimal with
Leaves::Reachability.
Sourcepub fn astar(
&self,
task: &Task,
factoring: &Factoring,
heuristic: &(impl DecoupledHeuristic + ?Sized),
) -> Result<Outcome, Error>
pub fn astar( &self, task: &Task, factoring: &Factoring, heuristic: &(impl DecoupledHeuristic + ?Sized), ) -> Result<Outcome, Error>
Sourcepub fn gbfs(
&self,
task: &Task,
factoring: &Factoring,
heuristic: &(impl DecoupledHeuristic + ?Sized),
) -> Result<Outcome, Error>
pub fn gbfs( &self, task: &Task, factoring: &Factoring, heuristic: &(impl DecoupledHeuristic + ?Sized), ) -> Result<Outcome, Error>
Decoupled greedy best-first search with this configuration; see
gbfs. With Leaves::Reachability, states keep no prices.
§Errors
As search().
§Examples
use decoupled_search::{Config, Factoring, HFf, Leaves};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
let op = |pre: Vec<Fact>, eff: Fact, cost| Operator {
name: "op".into(),
pre,
eff: vec![Effect::new(eff)],
cost,
};
let task = Task {
variables: vec![Variable::new("truck", 2), Variable::new("pkg", 3)],
operators: vec![
op(vec![Fact::new(0, 0)], Fact::new(0, 1), 4),
op(vec![Fact::new(0, 0), Fact::new(1, 0)], Fact::new(1, 2), 2),
op(vec![Fact::new(0, 1), Fact::new(1, 2)], Fact::new(1, 1), 3),
],
initial: State(vec![0, 0]),
goal: vec![Fact::new(1, 1)],
axioms: vec![],
};
let config = Config { leaves: Leaves::Reachability, ..Config::default() };
let outcome = config.gbfs(&task, &Factoring::fork(&task), &HFf::new(&task))?;
let plan = outcome.plan.expect("solvable");
assert_eq!(plan.cost, 9, "costs are summed from the plan's operators");
assert_eq!(plan.validate(&task), Ok(()));Sourcepub fn anytime_astar(
&self,
task: &Task,
factoring: &Factoring,
root: &(impl DecoupledHeuristic + ?Sized),
fork: &(impl DecoupledHeuristic + ?Sized),
) -> Result<Outcome, Error>
pub fn anytime_astar( &self, task: &Task, factoring: &Factoring, root: &(impl DecoupledHeuristic + ?Sized), fork: &(impl DecoupledHeuristic + ?Sized), ) -> Result<Outcome, Error>
Anytime decoupled A* (Gnad and Hoffmann’s Anytime Fork-Root A*,
ICAPS 2015, generalised to star factorings): A* ordered by g plus
the root heuristic, which estimates only the cost of the remaining
global actions, with fork (an estimate of the whole remaining cost,
as for Config::astar) used to prune nodes that cannot beat the
best solution found so far.
The root heuristic sees every reached leaf fact at price 0. Build it
on Factoring::with_free_leaf_actions, for example
HMax::new(&factoring.with_free_leaf_actions(&task)?): any
completion of a member state is then a plan of that task costing
only its global actions, so h^max there is root-admissible.
The search records solutions when they are generated and stops once
the popped key plus the least goal price any decoupled goal state can
have (per leaf, the cheapest leaf-action cost from the initial leaf
state to a goal leaf state, global parts free, ignoring the center)
reaches the best solution cost, or when the open list is empty. This
subsumes the paper’s early termination (an expanded goal whose goal
price equals that minimum) and is sound by the same argument as
Config::astar: while the optimum C* is not recorded, a node
covering it is open, with key at most C* minus its goal price.
Nodes with g + fork at least the best cost are pruned
(Statistics::bound_pruned), which cannot cut below C*.
The plan is cost-optimal if root is root-admissible and fork is
admissible.
§Errors
As Config::search.
§Examples
use decoupled_search::{Config, Factoring, HMax};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
let op = |pre: Vec<Fact>, eff: Fact| Operator {
name: "op".into(),
pre,
eff: vec![Effect::new(eff)],
cost: 1,
};
let task = Task {
variables: vec![Variable::new("truck", 2), Variable::new("pkg", 3)],
operators: vec![
op(vec![Fact::new(0, 0)], Fact::new(0, 1)),
op(vec![Fact::new(0, 0), Fact::new(1, 0)], Fact::new(1, 2)),
op(vec![Fact::new(0, 1), Fact::new(1, 2)], Fact::new(1, 1)),
],
initial: State(vec![0, 0]),
goal: vec![Fact::new(1, 1)],
axioms: vec![],
};
let factoring = Factoring::fork(&task);
let root = HMax::new(&factoring.with_free_leaf_actions(&task)?);
let outcome = Config::default().anytime_astar(&task, &factoring, &root, &HMax::new(&task))?;
assert_eq!(outcome.plan.map(|p| p.cost), Some(3));Source§impl Config
impl Config
Sourcepub fn reduced_task(
&self,
task: &Task,
factoring: &Factoring,
) -> Result<Task, Error>
pub fn reduced_task( &self, task: &Task, factoring: &Factoring, ) -> Result<Task, Error>
task without the operators that Config::reduce_leaves makes
useless under factoring, for building heuristics (the last step of
the leaf reduction in Torralba, Gnad, Dubbert and Hoffmann’s
technical report).
An operator is removed if it is a leaf action of an analysed leaf
(see Config::max_analysis_states) and none of its kept leaf
transitions starts in a leaf state that the reduced leaf can still
reach (over kept leaf actions and global parts, under any center).
Variables, goal and the remaining operators are unchanged, so fact
prices of the search fit heuristics built on the result.
Soundness. Only use heuristics built on the result in searches
with reduce_leaves: true, the same factoring and the same
max_analysis_states. There, every reached leaf state is reachable
in the reduced leaf, and by the soundness argument on
Config::reduce_leaves every decoupled state has a cheapest
completion that uses only kept transitions from such states, hence
only operators of the result. A heuristic admissible on the result
is therefore admissible for the search, and fewer operators can only
raise its estimates. Without leaf reduction in the search the
estimates may exceed the true cost.
The result is the same for both Leaves modes: the simulation
and the removed transitions do not depend on it.
§Errors
As Config::search, except that Config::leaves is ignored.
§Examples
use decoupled_search::{Config, Factoring, HMax, Pruning};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
// A truck over three locations and a package (3: in the truck) that
// must go from location 0 to location 1.
let op = |pre: Vec<Fact>, eff: Fact| Operator {
name: "op".into(),
pre,
eff: vec![Effect::new(eff)],
cost: 1,
};
let mut operators = Vec::new();
for x in 0..3 {
for y in (0..3).filter(|&y| y != x) {
operators.push(op(vec![Fact::new(0, x)], Fact::new(0, y)));
}
operators.push(op(vec![Fact::new(0, x), Fact::new(1, x)], Fact::new(1, 3)));
operators.push(op(vec![Fact::new(0, x), Fact::new(1, 3)], Fact::new(1, x)));
}
let task = Task {
variables: vec![Variable::new("truck", 3), Variable::new("pkg", 4)],
operators,
initial: State(vec![0, 0]),
goal: vec![Fact::new(1, 1)],
axioms: vec![],
};
let config = Config { reduce_leaves: true, ..Config::default() };
let factoring = Factoring::fork(&task);
let reduced = config.reduced_task(&task, &factoring)?;
// Only loading at 0 and unloading at 1 remain of the package's six.
assert_eq!(reduced.operators.len(), task.operators.len() - 4);
let outcome = config.astar(&task, &factoring, &HMax::new(&reduced))?;
assert_eq!(outcome.plan.map(|p| p.cost), Some(3));Trait Implementations§
impl Copy for Config
impl Eq for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Forget for Config
impl Freeze for Config
impl Move for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more