Classical Planning: Schemas, Relaxations and Graphs
Why planning gets its own representation rather than being a footnote to search, how deleting parts of an action description produces a heuristic for free, and what a planning graph notices that per-goal heuristics systematically miss.
Prerequisites: Constraint Satisfaction and Propagation
Search will solve a planning problem, given a heuristic. The interesting question is where the heuristic comes from, and the answer turns out to be a claim about representation rather than about algorithms.
A. What a factored state buys
A problem-solving agent treats a state as an atom. It can test the state for goalhood and nothing else, so every heuristic has to be supplied from outside. A logical agent can look inside a state, but reasons with ground sentences and drowns in them: in the wumpus world, moving forward needed a separate sentence for each of four orientations, time steps and locations.
Planning takes the middle path. A state is a collection of variables - a conjunction of fluents that are ground, positive and function-free:
Under the closed-world assumption anything unmentioned is false, so negation never has to be written down. The state is then readable two ways at once, as a logical sentence or as a set, and almost every algorithm takes the second.
Actions are schemas, describing only what changes:
The positive literals are the add list, the negated ones the delete list, and applying an action is one set expression: . The frame problem is not solved so much as declined: attention is restricted to domains where most actions leave most things alone, and persistence becomes the default.
B. The cost of grounding
A schema is compact; its instances are not. With two cargos, two planes and two airports, three air-cargo schemas expand to twenty ground actions, and the flight schema alone with ten planes and five airports gives .
Runs in your browser. The first run downloads the Python runtime (~10 MB), then it is cached.
The guard on the last comprehension is not tidiness. Without it the schema produces , whose effect is , a contradiction; the principled fix is an inequality precondition.
This is why forward search struggles. It is complete and, at uniform cost, optimal, but it will consider flying an empty plane between two irrelevant airports as readily as loading the right cargo. Backward search from the goal considers only relevant actions, regressing a goal to , and branches far less - but its nodes are sets of states rather than states, which needs unification and leaves the good heuristics harder to define.
C. Heuristics by deletion
Here the representation pays. A heuristic is the cost of an easier problem, and the schemas can simply be edited.
Ignore preconditions strips every precondition, making every action applicable everywhere. What remains is covering the unmet goal literals with as few add lists as possible. This is where the classical puzzle heuristics come from: in the 8-puzzle, dropping gives misplaced-tiles, and dropping alone gives Manhattan distance. Both fall out mechanically.
Ignore delete lists strips every negative effect. Nothing can undo anything, so progress is monotonic and hill-climbing finds an approximate relaxed plan in polynomial time.
On air cargo, both report 2 at the initial state against a true cost of 6 (the delete-list figure counts the layers of the relaxed problem, as a planning graph does; the shortest relaxed plan itself is 5 actions):
| search | states expanded |
|---|---|
| breadth-first, no heuristic | 56 |
| A* with ignore preconditions | 51 |
| A* with ignore delete lists | 45 |
The margins are small because the problem is small. What matters is that nobody wrote a heuristic for air cargo.
D. What a planning graph notices
A planning graph alternates literal levels and action levels, adds a persistence action for every literal, and is built in polynomial time with no search. Its substance is the mutex links, recording pairs that cannot hold together: actions with inconsistent effects, actions that interfere, actions with competing needs, and literals whose every pair of producers is mutex.
Take the smallest problem that makes the point. Initially you have a cake; you want to have it and to have eaten it. Eating deletes having, and baking requires not having.
| level | literals | mutex pairs |
|---|---|---|
| , | 0 | |
| all four | 4 | |
| all four | 3 |
Both goal literals appear at , so per-literal reasoning says one step is enough. It is not: at they are mutex, because the only way to have the cake is to persist it and the only way to have eaten it is to eat it, and eating deletes having. By the mutex is gone and the graph has levelled off.
The level cost of a literal is where it first appears, giving three heuristics. Max-level takes the largest, level-sum adds them, and set-level waits for the first level where all goal literals appear with no mutex among them. Here they give , and . The optimal plan - eat the cake, then bake another - has length , so only set-level is right, and only it looked at whether the goals could coexist.
Max-level and set-level are admissible and set-level dominates. Level-sum treats subgoals as independent and can overshoot, so it is inadmissible in general, which does not stop it from being the most useful of the three in practice.
The figure below builds that graph rather than quoting it - every mutex in it is computed from the three action conditions and the two literal ones, which is why the counts come out 0, 4, 3, 3 on their own. Look at the line joining the two goal literals. It is there at S1 and gone at S2, and that single disappearing line is the whole difference between a heuristic that answers 1 and the true answer of 2.
Interactive: the line that disappears at level two
Every mutex here is computed, not quoted. Watch the goal pair at S1 and at S2.
- Max-level
- 1
- Level-sum
- 1
- Set-level
- 2
- True optimum
- 2
At S1 both goal literals are already present, which is why max-level and level-sum both answer 1. They are also joined by a line: the only way to have the cake is to persist it, the only way to have eaten it is to eat it, and those two interfere. Set-level is the only one of the three that looks at that line, so it waits until S2 - and that is the true optimum, because the plan really does need both steps. A planning graph approximates in one direction only: a literal absent at level i is definitely unreachable in i steps, but present and unblocked is not a promise, only the absence of the cheapest proof of impossibility.
Where this leaves you
The approximation runs one way only. A literal absent at level is genuinely unachievable within steps, which is what makes level costs lower bounds. A literal present, even without a mutex, promises nothing; only pairwise inconsistencies are computed, so a three-way conflict passes unnoticed. That asymmetry is the honest shape of the whole subject: classical planning does not make hard problems easy, it makes the description of a problem something a solver can read. The training path Classical Planning builds the schemas, the relaxations and the graph by hand and in code.
References & further reading
- Stuart Russell, Peter Norvig, Artificial Intelligence: A Modern Approach, Pearson (3rd edition), 2010· Kudos AI reference library
Copyrighted works are cited for reference only and are not hosted here; please consult the publisher for access.