cost-partition
Cost partitioning over any sas_plus::Abstraction (projections, merge-and-shrink, ...): saturated cost partitioning for a given order, and the maximum over several orders. Different kinds of abstractions can share one order as Vec<&dyn Abstraction>.
Splitting each operator's cost among several abstractions, so that the parts sum to at most the original cost, makes the sum of their heuristics admissible. The crate implements saturated cost partitioning after Seipp, Keller & Helmert (JAIR 2020) and its maximum over orders, is no_std with alloc, and is checked against exact goal distances on random tasks and real translator output.
Who this is for
- Authors of optimal classical planners who have several abstraction heuristics (pattern databases, merge-and-shrink, Cartesian or their own) and want an admissible combination that is usually stronger than taking their maximum.
- Researchers comparing cost partitioning strategies: the saturated cost function of every abstraction is exposed (
cost_functions), and any type that implementssas_plus::Abstractioncan take part. - Teams that plan on embedded hardware, since the crate is
no_stdand has a single dependency. - For the abstractions themselves, use sas-plus (projections) and merge-and-shrink; for landmark cost partitioning, LM-cut or operator counting, planning-heuristics, which also wraps this crate's heuristics for its
Heuristictrait.
Part of the planning and search crates; see also this crate's overview page.
What cost partitioning is
A planning heuristic estimates, for a state, the cost of the cheapest plan to a goal. Optimal search such as A* needs it to be admissible: it never estimates more than the true optimum h*.
An abstraction gives such a heuristic cheaply. It maps every state to a smaller abstract state space, for example a projection that keeps only some variables, and uses the goal distance there as the estimate. Each abstraction is admissible on its own, but usually weak, because it sees only part of the task.
Adding the estimates of several abstractions is not admissible in general. Each one charges the full cost of every operator it needs, so an operator that several abstractions need is paid for several times. On the translated gripper-4 task, the projections' estimates add up to 24, while the optimal plan costs 9.
Cost partitioning removes the double counting. Each operator's cost is split into shares, one per abstraction, so that the shares sum to at most the original cost. Each abstraction then computes its goal distances under its own shares only. Any plan pays every operator at most once in total across the abstractions, so the sum of their estimates is admissible again.
How saturated cost partitioning works
Saturated cost partitioning (SCP) builds the shares greedily, one abstraction at a time, in a given order:
- Compute the abstraction's goal distances under the costs that are still left.
- Take its saturated cost function: for each operator, the least cost that keeps all of those goal distances. That is the largest drop in goal distance along any transition the operator labels. Operators that do not bring this abstraction closer to the goal get 0.
- Subtract the saturated costs from what is left, and pass the rest on to the next abstraction.
An abstraction early in the order keeps its full estimate and takes only the costs it needs, so later abstractions still get the costs it has no use for. Abstractions left out of the order get no costs, but still report dead ends: states from which no plan exists.
A small example: operators a (cost 2) and b (cost 3), with the optimal plan a, b, so h* = 5. Abstraction X only notices a, and abstraction Y notices both.
share of a share of b estimate
X, full costs 2 3 2
Y, full costs 2 3 5
sum, full costs 7 > h* = 5, not admissible
SCP in order X, Y
X 2 0 2 b does not change X's distances
Y 0 3 3 only the costs X left over
sum 2 3 5 = h* = 5
Different orders give different estimates, and none is best for every state. MaxOverOrders computes SCP for several orders and takes the largest estimate, which is still admissible.
Installation
Or in Cargo.toml:
[]
= "0.2"
Usage
Build projections of a task from Fast Downward's translator, partition the costs among them, and evaluate the heuristic:
use ;
use Projection;
use SasFile;
# let output_sas = concat!;
// `output_sas` is the path of a translator output file.
let task = parse?.to_task;
let costs = task.costs;
let projections: =
.map
.collect;
// Saturated cost partitioning in one order.
let order: = .collect;
let scp = saturated_cost_partitioning;
let h = scp.value;
// The maximum over several orders dominates each of them.
let reversed: = order.iter.rev.copied.collect;
let max = new;
assert!;
# Ok::
None from value means a dead end: no plan exists from that state.
Examples
Both are meant for small tasks. They run on the translated gripper-4 task from this repository by default, or on the translator output passed as an argument. task examples runs both (task examples -- path/to/output.sas for another task).
heuristics shows why costs are partitioned. Adding the projections' estimates with full costs overestimates the optimum, so the sum is not admissible. SCP splits the costs first: it stays admissible and is stronger than the best single projection. Its estimates for gripper-4:
optimal plan cost (h*) 9
best single projection 2
sum, full costs 24 inadmissible
SCP, one order 4
max of SCP over 8 orders 4
astar solves the task optimally with A*, blind and guided by SCP, and prints the plan. Both plans are optimal; the guided search expands fewer states. Its summary for gripper-4, before the plan:
blind (h = 0) cost 9 230 expansions
max of SCP over 8 orders cost 9 178 expansions
Tested
SCP ≤ h*, SCP ≥ its first component, no false dead ends, and cost functions sum to at most the original costs. These hold as proptest properties and a fuzz target on random tasks (the properties also with a merge-and-shrink abstraction in the order), and on translator output, both with and without conditional effects and axioms (derived variables).
Features
no_std (needs alloc). The crate has no Cargo features. It depends on sas-plus without its default features.
MSRV
Rust 1.86. Raising it is a minor-version change.
Not yet implemented
Greedy and diversified orders, general (negative) costs, an optimal LP baseline (good_lp), uniform cost partitioning.
Reference: Seipp, Keller & Helmert, Saturated Cost Partitioning for Optimal Classical Planning, JAIR 2020.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSES/Apache-2.0.txt)
- MIT license (LICENSES/MIT.txt)
at your option. Test fixtures derived from VHPOP are GPL-2.0-or-later and are not part of the published crate; see REUSE.toml.
Contributing
See CONTRIBUTING.md.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.