Skip to main content

Crate planning_heuristics

Crate planning_heuristics 

Source
Expand description

§Planning heuristics

Goal-distance estimates for classical planning tasks given as sas_plus::Task.

§Implemented

  • HMax, HAdd and HFf: the delete-relaxation heuristics h_max, h_add and h_FF (Bonet & Geffner 2001, Hoffmann & Nebel 2001), computed with a worklist (generalized Dijkstra) over Relaxation, which also extracts RelaxedPlans and their preferred operators.
  • HSetAdd: the set-additive heuristic h_sa (Keyder & Geffner 2008); AdditiveHMax: h_max summed over a partition of the operator costs; H2: h² (Haslum & Geffner 2000), which sees pairs of facts.
  • RedBlack: the red-black heuristic h_RB (Domshlak, Hoffmann & Katz 2015), with the black variables chosen by a Painting: greedy, or by the papers’ strategies (Strategy) for an arcless or acyclic black causal graph (Fragment), or a few black variables searched as a product (Painting::bounded); options (RedBlackOptions) for relaxed plan forwarding and red facts following.
  • Relaxation::landmarks: h^1 fact landmarks with natural orderings (LandmarkGraph), and the heuristics LandmarkCount (inadmissible) and UniformLandmarkCost (admissible, uniform cost partitioning); with feature lp, OptimalLandmarkCost (admissible, optimal cost partitioning by linear programming).
  • With feature lp, OperatorCounting: the state equation (Bonet 2013) and LM-cut landmarks as an operator-counting LP (Pommerening, Röger, Helmert & Bonet 2014).
  • Relaxation::rhw_landmarks: back-chained landmarks (Richter, Helmert & Westphal 2008) with disjunctive and domain-transition-graph landmarks, as OrderedLandmarks with natural, greedy-necessary and reasonable orderings (OrderingKind).
  • PathHeuristic: path-dependent heuristics; LandmarkTracker tracks the accepted landmarks along the search path, as LAMA’s landmark count or admissibly with uniform cost partitioning; with feature lp, OptimalLandmarkTracker with optimal cost partitioning. The optimal cost partitioning over LM-cut’s action landmarks is OperatorCounting with only the LM-cut constraints (its LP dual).
  • LmCut: the landmark-cut heuristic h_LM-cut (Helmert & Domshlak 2009), admissible, with its disjunctive ActionLandmarks.
  • AbstractionHeuristic: goal distances of any sas_plus::Abstraction, such as a pattern database over a sas_plus::Projection. Features merge-and-shrink and cost-partition implement GoalDistance for those crates’ heuristics, which Adapter turns into a Heuristic.
  • RelevanceScore: the relevance score h_Ξ (Kim & Sridharan 2024), landmark-like and inadmissible, over a partially explored backtracking tree.
  • GoalIntention: goal-intention ranking keys ol_rp / op_rp (Rosa et al. 2026) from sampled relaxed plans, tracked along a path with IntentionTracker.

§Example

use planning_heuristics::{HAdd, HFf, HMax, Heuristic, Relaxation};
use sas_plus::{Effect, Fact, Operator, State, Task, Variable};

// One binary variable, one operator that sets it, goal `v0 = 1`.
let task = Task {
    variables: vec![Variable::new("v0", 2)],
    operators: vec![Operator {
        name: "set".into(),
        pre: vec![Fact::new(0, 0)],
        eff: vec![Effect::new(Fact::new(0, 1))],
        cost: 3,
    }],
    initial: State(vec![0]),
    goal: vec![Fact::new(0, 1)],
    axioms: vec![],
};
let state = task.initial_state();

// Each heuristic owns its relaxation ...
assert_eq!(HMax::new(&task).estimate(&state), Some(3));

// ... or borrows a shared one; one heuristic per thread, the relaxation is `Sync`.
let relaxation = Relaxation::new(&task);
let mut h_add = HAdd::with_relaxation(&relaxation);
let mut h_ff = HFf::with_relaxation(&relaxation);
assert_eq!(h_add.estimate(&state), Some(3));
assert_eq!(h_ff.value(&state), Some(3_u64));

Repository: https://github.com/sunsided/planning-heuristics

Structs§

AbstractionHeuristic
The goal distances of an abstraction as a heuristic: admissible, since every transition of the task maps to a path of at most its cost in the abstraction.
AcceptedLandmarks
The landmarks a search path has accepted: the per-node information of a LandmarkTracker. One bit per landmark of the tracker’s graph.
ActionLandmark
A disjunctive action landmark found by LmCut::landmarks: every plan from the state applies at least one of ActionLandmark::ops.
Adapter
A GoalDistance used as a Heuristic: forwards to GoalDistance::value and saturates at u32::MAX, like every heuristic of this crate.
AdditiveHMax
Additive h_max over a partition of the operators: for each part i, h_max under the costs of the operators in part i (all others cost 0), summed over the parts.
CountingConstraints
Which constraints an OperatorCounting heuristic uses.
Exploration
The result of Relaxation::explore: the cost of every fact from one state.
GoalIntention
Fact observation probabilities for the relaxed plan observation heuristics ol^rp (likelihood) and op^rp (posterior) of Rosa et al. (2026).
H2
The h² heuristic (Haslum & Geffner 2000): the cost of the cheapest regression where every set of more than two facts costs as much as its most expensive pair. Admissible, at least h_max, and it sees deletes: two facts that no plan makes true together cost more than either alone.
HAdd
h_add (Bonet & Geffner 2001): the sum of the goal fact costs when every rule costs its operator plus the sum of its conditions. Not admissible; counts shared subgoals twice.
HFf
h_FF (Hoffmann & Nebel 2001): the cost of a relaxed plan extracted from h_add best supporters (see Relaxation::relaxed_plan). Not admissible; h_max <= h_FF <= h_add.
HMax
h_max (Bonet & Geffner 2001): the cost of the most expensive goal fact when every rule costs its operator plus its most expensive condition. Admissible.
HSetAdd
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.
HeuristicFn
A closure used as a Heuristic; created by heuristic_fn.
IntentionParams
Parameters of the fact probability estimation.
IntentionTracker
The relaxed plan observation heuristics as a path heuristic: the observation of a path is the set of facts its operators added (the effects that fired), its estimate the cost of that set under IntentionKind. With restart (the paper’s ol^rp_r and op^rp_r), the observation restarts empty at every state that lowers the goal count below all earlier states on the path. Estimates are f64 (lower is better) and never None.
LandmarkCount
The landmark-count heuristic: the number of fact landmarks of the state that do not hold in it yet. Not admissible (one operator can achieve several landmarks) and blind to costs.
LandmarkGraph
The fact landmarks of one state and their natural orderings.
LandmarkOrdering
An ordering between two landmarks of an OrderedLandmarks graph, by index.
LandmarkTracker
Landmark heuristics that track, along the search path, which landmarks of the start state have been achieved (LAMA; Richter & Westphal 2010), as a PathHeuristic.
LmCut
The landmark-cut heuristic h_LM-cut (Helmert & Domshlak 2009). Admissible, and never below h_max.
Observation
The facts observed along a path and their cost, carried by IntentionTracker.
OperatorCounting
An operator-counting heuristic (Pommerening, Röger, Helmert & Bonet 2014): minimize the cost Σ cost(o) · Y_o of operator counts Y_o ≥ 0 that satisfy constraints every plan’s counts satisfy. Admissible. Feature lp.
OptimalLandmarkCost
An admissible landmark heuristic: the optimal cost partitioning over the fact landmarks (Karpas & Domshlak 2009), solved as a linear program. Feature lp.
OptimalLandmarkTracker
The optimal cost partitioning over the landmarks a search path still has to achieve (Karpas & Domshlak 2009), as a PathHeuristic. Feature lp.
OrderedLandmarks
A landmark graph whose landmarks may be disjunctions of facts, with typed orderings.
Painting
A choice of black variables for crate::RedBlack; every other variable is red.
RedBlack
The red-black heuristic h_RB, by default by relaxed plan repair.
RedBlackOptions
Options of RedBlack, set with RedBlack::with_options; the default is plain relaxed plan repair. Both are ignored with a Painting::bounded painting, which uses product search.
RedBlackPlan
A plan under red-black semantics, from RedBlack::plan.
Relaxation
The delete relaxation of a task, indexed for the worklist in Relaxation::explore.
RelaxedPlan
A relaxed plan: operators that reach the goal when deletes are ignored.
RelevanceParams
Parameters of the exploration (their Algorithm 2).
RelevanceScore
The relevance score heuristic h_Ξ (Kim & Sridharan 2024): the sum over all facts of the probability that a randomly acting agent samples the fact while backchaining from the goal under the delete relaxation.
Stateless
A stateless Heuristic as a PathHeuristic with no per-node information.
UniformLandmarkCost
An admissible landmark heuristic: uniform cost partitioning over the fact landmarks (Karpas & Domshlak 2009).

Enums§

CausalLevel
Which end of the causal graph Painting::causal_graph_level keeps black.
Combine
How a rule combines the costs of its conditions.
Fragment
The tractable fragment a painting strategy targets: the shape of the causal graph induced on the black variables.
H2Error
Why H2::new cannot handle a task.
IntentionKind
Which of the two heuristics an IntentionTracker computes.
OrderingKind
How two landmarks of an OrderedLandmarks graph are ordered.
PaintingError
Why a set of variables cannot be painted black; see Painting::new.
Strategy
The choice point of the painting algorithm of Domshlak, Hoffmann & Katz (2015, Figure 8): which black variable to paint red next. Every strategy stops at a maximal painting for its Fragment; see super::Painting::with_strategy.
TrackingMode
What a LandmarkTracker estimates from the landmarks still to achieve.

Constants§

MAX_BOUNDED_PRODUCT
The largest product of the domain sizes of the black variables of a Painting::bounded painting.

Traits§

GoalDistance
A heuristic of another crate with an inherent value(&State) -> Option<u64>, which Adapter turns into a Heuristic.
Heuristic
An estimate of the cost from a state of type S to the nearest goal, in cost type C.
PathHeuristic
A heuristic whose estimate depends on the path to a state, through per-node information the search carries along (Karpas & Domshlak 2009; LAMA’s accepted landmarks).

Functions§

heuristic_fn
Turns a closure FnMut(&S) -> Option<C> into a Heuristic.