pub struct HSetAdd<'r> { /* private fields */ }Expand description
The set-additive heuristic h_sa (Keyder & Geffner 2008): like h_add, but each fact
carries a relaxed plan, a set of operators, instead of a cost, so an operator shared by
two subgoals is counted once.
A rule conditions → head offers the union of its conditions’ plans plus its operator;
the head keeps the cheapest offer (by summed operator cost). The offers are swept until no
plan gets cheaper (Bellman-Ford), and the estimate is the cost of the union of the goal
facts’ plans. Each offer costs at most h_add’s sum, so h_sa <= h_add. Without
conditional effects the union is a relaxed plan, so h_max <= h_sa; with them, a relaxed
plan may need one operator twice (before and after an effect condition holds), which the
set counts once, so h_sa can fall below h_max. Not admissible.
One sweep is O(rules × operators / 64); sweeps repeat until nothing improves.
§Examples
use planning_heuristics::{HAdd, HSetAdd, Heuristic};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};
// `tool` (cost 3) is needed for both goals: h_add counts it twice, h_sa once.
let op = |name: &str, pre: Vec<Fact>, eff: Fact, cost: u32| Operator {
name: name.into(),
pre,
eff: vec![Effect::new(eff)],
cost,
};
let task = Task {
variables: vec![Variable::new("tool", 2), Variable::new("a", 2), Variable::new("b", 2)],
operators: vec![
op("tool", vec![], Fact::new(0, 1), 3),
op("a", vec![Fact::new(0, 1)], Fact::new(1, 1), 1),
op("b", vec![Fact::new(0, 1)], Fact::new(2, 1), 1),
],
initial: State(vec![0, 0, 0]),
goal: vec![Fact::new(1, 1), Fact::new(2, 1)],
axioms: vec![],
};
let state = task.initial_state();
assert_eq!(HAdd::new(&task).estimate(&state), Some(8));
let mut h_sa = HSetAdd::new(&task);
assert_eq!(h_sa.estimate(&state), Some(5));
assert_eq!(h_sa.plan(&state).unwrap(), [0, 1, 2]);Implementations§
Source§impl<'r> HSetAdd<'r>
impl<'r> HSetAdd<'r>
Sourcepub fn with_relaxation(relaxation: &'r Relaxation) -> Self
pub fn with_relaxation(relaxation: &'r Relaxation) -> Self
Builds h_sa over a shared relaxation.