Task a's optimal plan. The object names are the local names of the graph's IRIs.
Once the planner has committed to one drink for one person, the order of the six is forced by their preconditions
The planner rediscovers that order on every task, and task d pays for it twice
One action in place of six
The meta-action
What it is
A composition of skills, authored in the knowledge graph, fixed in length, whose preconditions and effects are derived from its steps and never declared.
It is one more action in the planning domain.
D3, the knowledge-graph design.
It lives in the graph
In the same Turtle files as the map and the beliefs.
On the node
What it carries
rdfs:label
The name the domain uses
isfr:parameter
Its parameters, each with an isfr:parameterIndex
isfr:step
Its steps, each with an isfr:stepIndex
A parameter carries an isfr:variable, the name the steps use, and an isfr:parameterClass, the ontology class its argument must belong to
A step carries an isfr:call, one skill name and its arguments in PDDL shape
fetch has five parameters
Index
Variable
isfr:parameterClass
0
?from
isfr:Place
1
?src
isfr:Place
2
?drink
isfr:Drink
3
?dst
isfr:Place
4
?person
isfr:Person
Where the robot starts, where the drink is, which drink, where the person is, and who.
The parameter types come from the graph
The generator types a skill's parameter by its name. A meta-action's parameters are named by whoever authors it, so isfr:parameterClass gives the PDDL type instead.
isfr:parameterClass
PDDL type
isfr:Place
place
isfr:Drink
drink
isfr:Container
drink
isfr:Person
person
A parameter with no class, or with a class outside that table, is an error that names the meta-action and the variable.
Nothing about those two numbers was chosen. They follow from the six skill declarations and the order of the steps.
When the derivation rejects
grasp-twice
The micro-project ships a second meta-action, with two parameters and two steps that are both (grasp ?obj ?place).
You leave it as it is. A correct derivation rejects it, and that rejection is the first thing your code has to get right.
Step 0
None of grasp's five preconditions is supplied by an earlier step, so all five become preconditions of the whole
Then step 0's effects run. It makes (holding ?obj) true.
And it makes (gripper-empty), (gripper-at ?obj), (base-placed-for ?obj) and (object-at ?obj ?place) false.
Step 1 asks for an atom step 0 destroyed
The report names the step and the atom
grasp-twice: rejected: grasp-twice: step 1 (grasp ?obj ?place)
needs (gripper-at ?obj), which an earlier step made false
(gripper-empty) is false at that point too, and so is (object-at ?obj ?place)
One failed precondition is enough to reject, so which one your walk reports depends on the order you check them in
What matters is that the rejection happens at all.
Caught when the graph loads
Before any planning, and long before any driving.
An author who had written the preconditions of grasp-twice by hand would have written something plausible
The planner would have used it
The robot would have discovered the problem by trying to grasp an object it was already holding
The derivation caught a real mistake
While this course's fetch was first derived, the catalogue's grasp took one parameter and deleted one atom
The derivation left (gripper-at ?drink) and (base-placed-for ?drink) among fetch's positive effects, and never touched (object-at ?drink ?src)
So after a fetch, the planner believed the drink was still on the worktop, with the gripper at it and the base parked for it
One delete where four were needed
What that makes the derivation
It saves you from writing an annotation for every composition
It also checks the annotations you already wrote by hand, on the skills
A skill's declaration is only ever read one skill at a time. A derivation reads six of them in order and shows what the sequence leaves behind.
Binding and nesting
Distinct parameters may bind to one object
The derivation treats ?from, ?src and ?dst as three different things
A planner is under no such obligation. It binds each parameter to an object, and nothing stops it binding two of them to the same object.
The robot already stands where the drink is
Bind ?from and ?src to one place. Derive fetch again with both replaced by ?p.
The composition stays consistent
There are still six preconditions, and one of them is now (reachable ?p ?p)
That holds, because week 6 made reachability reflexive
Week 6's lecture notes said this week was the reason.
Eleven effects become ten
And step 0 drives nowhere
A reflexive navigate-to is harmless, for the reason week 6 gave.
Its add list is \( \{(\mathit{at}\ p)\} \). Its delete list \( \mathit{Del} \) holds \( (\mathit{at}\ p) \), (base-placed) and (arm-placed). The deletes apply first.
Same syntax, same predicates, same grounding. The planner has no way of telling that one of them is six skills.
What an action costs
Every action in week 6's domain cost 1, because the generator set no metric
Leave it that way and fetch costs 1 against the six skills it replaces
The macro domain then wins on plan cost for a reason that has nothing to do with planning
So a meta-action costs the number of primitive steps in its full expansion, and a skill costs 1. fetch costs 6.
fast-downward-opt honours that price. fast-downward reads it and then searches as if every action cost 1, so to it fetch is one cheap step whatever it is priced at.
Break the rule and you change the problem
This week's example prices its macro below the cost of its steps and plans again.
The optimal engine returns a plan that costs less than any flat plan, because you have changed the problem rather than the search.
Expansion, before anything runs
A plan that holds fetch is not a plan the robot can run. The executive knows skills, and fetch is not one.
So a plan is expanded before it is executed, and before it is replayed. One fetch becomes six skill calls with their arguments bound.
Expansion is also what makes the comparison honest. A one-step plan holding fetch is not less work than a six-step plan of skills.
Every row of this week's table carries both the length as returned and the length after expansion.
Then the plan is replayed
Every expanded plan is replayed against the skills' own preconditions and effects, step by step, deletes before adds
The replay checks the plan against the catalogue rather than against your derivation
A replay against your own annotations would check the plan against the very preconditions that let it through
A wrong derivation shows up in one of three ways. The plan fails the replay, the plan is longer than it should be, or there is no plan at all.
Does it pay
The apartment, measured
Task
Engine
Domain
Length
Expanded
Expansions
a
fast-downward-opt
flat
6
6
9
a
fast-downward-opt
macro
1
6
3
a
fast-downward
flat
7
7
11
a
fast-downward
macro
1
6
2
d
fast-downward-opt
flat
12
12
53
d
fast-downward-opt
macro
2
12
22
d
fast-downward
flat
13
13
33
d
fast-downward
macro
2
12
3
expanded is the plan length after every meta-action is replaced by its steps. expansions is the number of search nodes the engine expanded. They count different things.
Reading it
The macro domain expands fewer nodes in all four cells. Nine become three and fifty-three become twenty-two under the optimal engine, eleven become two and thirty-three become three under the satisficing one.
The expanded lengths are equal under the optimal engine, 6 against 6 and 12 against 12, which is what the cost metric guarantees
Under the satisficing engine the macro plans are shorter once expanded, 6 against 7 and 12 against 13, because that engine's flat plans were not shortest to begin with
What comes back
The returned plan is one fetch on task a and two on task d, one per delivery.
A meta-action of fixed length cannot do anything else.
That is the price of a fixed length, from block 2, in the table.
The same macro, the opposite verdict
On the apartment, the macro cuts expansions under both engines
How far that result travels is a separate question, and this week's example answers it on a second domain
It runs the Gripper domain of week 6, flat and with carry-two, a macro that picks two balls, moves, and drops them both.
Expansions against the number of balls
Eleven balls
Engine
Domain
Length
Expanded
States
Seconds
fast-downward-opt
flat
33
33
161355
1.32
fast-downward-opt
macro
13
33
161355
3.97
fast-downward
flat
33
33
49
0.09
fast-downward
macro
13
33
19
0.12
The macro buys the optimal engine nothing at all, and costs about three times the wall clock for the same search.
From examples/07-planning-with-meta-actions/README.md, whose states column counts what the apartment table calls expansions. State counts are the same on every machine. Seconds vary.
The likely mechanism
A macro adds to a node's successor list states that would normally be reached in several steps
So it can reduce the maximal depth of a search
And it pays for that reduction with a larger branching factor
Botea, Enzenberger, Müller & Schaeffer (2005), section 3.4.1, Journal of Artificial Intelligence Research 24, 581–621.
What the macro adds: estimate first
Adding an action schema adds ground actions, one for each way of substituting objects of the right type for its parameters.
How many does fetch add to the apartment problems?
Five parameters over the problem's places, drinks and people run to the order of \( 10^{5} \) substitutions. That is the estimate this week started from.
Then measure
Task
Flat domain
fetch adds
a
519 ground actions
154
d
526 ground actions
308
On the apartment problems, with the reference encoding.
More than two orders of magnitude below the estimate. The planner plainly does not keep every combination, so estimate the grounding of a schema and then measure it.
Why the seconds are not in the table
The macro does not save time on the apartment. Every search in its table takes under 5 ms, and the macro domain is slower end to end in all four cells.
The likely reason is the grounding just counted. Building those ground actions costs more than the shorter search saves.
Expansions come out the same on every machine. Seconds at this size are mostly the cost of translating the problem.
Read your own seconds column for whether the macro row is slower, and not by how much.
Why the two domains differ
The apartment
fetch's six steps are a chain the search walks one step at a time, and fetch grounds narrowly, so the depth it removes is worth more in node expansions than the actions it adds.
Gripper
The optimal engine must prove that no cheaper plan exists, over a state space the macro does not shrink. carry-two adds edges to it and no shortcut through it, since going the long way costs what the macro costs.
That is the likely reason, and not a measured cause.
The utility problem
Control knowledge has a hidden cost that can defeat its purpose, the cost of testing whether the knowledge applies as the search is carried out. For it to improve efficiency, its benefits must outweigh its costs.
Minton reports that it is harder to improve performance over a population of examples than on isolated examples
PRODIGY measured a rule's utility as its average saving times how often it applied, minus its average matching cost, and discarded a rule whose utility was negative
Minton (1988), pages 564 and 567, Proceedings of AAAI-88, 564–569. His subject is search control rules in PRODIGY.
The same problem, for macros
The overhead of poor macros can outweigh their benefit. Adding operators to a domain raises both the preprocessing cost and the cost per node in the search.
If all instantiations of a macro are considered, the branching factor can increase significantly, and the induced overhead can be larger than the savings achieved by the useful instantiations
So the question a meta-action has to answer is a quantitative one. Is the depth it removes worth the ground actions it adds, for the engine you plan with, on the problems you solve?
Botea et al. (2005), sections 2.2.2 and 3.3, citing Minton for the utility problem.
Learned macros, and week 8
fetch is authored
Someone decided its six steps and wrote them into the graph.
The alternative is to learn macros from plans the planner has already found, and that idea is as old as the triangle table.
Your walk is older than PDDL
Fikes, Hart and Nilsson store a plan in a triangle table, a lower triangular array whose rows and columns correspond to the operators of the plan
Column i holds the add list of operator i at the top, and below it the part of that add list which survives each later operator
So cell (i, j) holds the clauses added by operator j that are still true when operator i applies
The conjunction of the formulas in the row to the left of an action is the precondition for executing that action
The formulas in the column beneath an action are those on its add list that are also preconditions of later actions or effects in the last row
Preconditions not realised by any action in the table must hold before it is executed, and are the initial preconditions of the table
Any literal needed by an action and provided by a previous action must survive the intervening actions
Nilsson (1990), Triangle-table trees, section B, page 4. The union of the bottom row is the plan's add list and the left-most column its precondition formula (Fikes, Hart & Nilsson, 1972, pages 258 and 261).
Shakey learned them
A plan STRIPS had produced was stored as a triangle table, then generalised by replacing every constant in the left-most column with a new parameter
Multiple occurrences of one constant become distinct parameters, which is block 5's binding problem
The lifted table is constrained so that each row still supports its operator's preconditions
The generalised plan was stored as a macro operator, a MACROP, and was available to later problems
Fikes, Hart & Nilsson (1972), section 4.2, page 262, and section 4.3, page 268. Fikes & Nilsson (1993), pages 227 and 228, is the authors' own account of the period. Botea et al. (2005) is the modern form, with macros learned automatically.
This course does not learn them
The thesis stated in week 1 is that only what classical methods do badly is learned
The three things on that list are navigation, base placement and collision-free reaching
Composing skills is not on it
fetch is authored instead, which also means a person can say why its six steps are those six.
Next week the plan runs
A plan is a sequence of skill calls that the planner believed would have their declared effects
On the robot, any call can terminate in failure
Week 8 compiles a plan into a tree of guarded steps, checks each guard against the graph and the robot before the step runs, and replans when a step fails
That monitor has an ancestor too. PLANEX used triangle tables to monitor the execution of plans, checking what was still true before it carried on.