Skip to main content

Config

Struct Config 

Source
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: Pruning

The dominance criterion. Default: Pruning::Adaptive.

§fold_g: bool

Whether 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: Leaves

Prices or reachability only. Default: Leaves::Priced.

§max_analysis_states: usize

The 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: bool

Whether 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

  1. x' ⪯ x: staying at x is as good, or
  2. another leaf action b applicable in x replaces it, and either a does not replace b in turn or b has 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: bool

Whether 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::Frontier and Pruning::EffectivePrices with Config::fold_g off, 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, and Config::reduce_leaves rest on the randomized cross-checks against Dijkstra only.
§symbolic_leaves: bool

Whether 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: usize

The 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: bool

Whether 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

Source

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.

Source

pub fn astar( &self, task: &Task, factoring: &Factoring, heuristic: &(impl DecoupledHeuristic + ?Sized), ) -> Result<Outcome, Error>

Decoupled A* with this configuration; see astar.

§Errors

As Config::search.

Source

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(()));
Source

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

Source

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§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Config

Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Config

Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.