Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
Hierarchical Task Network (HTN) Planning
Section 11.2
Sec. 11.2 – p.1/25
Outline
Example
Primitive vs. non-primitive operators
HTN planning algorithm
Practical planners
Additional references used for the slides:
desJardins, M. (2001). CMSC 671 slides.www.cs.umbc.edu
Sec. 11.2 – p.2/25
Hierarchical Task Network (HTN) planning
Idea: Many tasks in real life already have a built-inhierarchical structure
For example: a computational task, a militarymission, an administrative task
It would be a waste of time to construct plans fromindividual operators. Using the built-in hierarchyhelp escape from exponential explosion
Running example: the activity of building a houseconsists of obtaining the necessary permits, findinga builder, constructing the exterior/interior, ...
HTN approach: use abstract operators as well asprimitive operators during plan generation.
Sec. 11.2 – p.3/25
Building a house
ObtainPermit
Construct PayBuilder
HireBuilder
decomposes to
decomposes to
BuildHouse
BuildFoundation
BuildFrame
BuildRoof
BuildWalls
BuildInterior
Sec. 11.2 – p.4/25
Hierarchical decomposition
HTN is suitable for domains where tasks arenaturally organized in a hierarchy.
Uses abstract operators to start a plan.
Use partial-order planning techniques and actiondecomposition to come up with the final plan
The final plan contains only primitive operators.
What is to be considered primitive is subjective:what an agent considers as primitive can be anotheragent’s plans.
Sec. 11.2 – p.5/25
Representing action decompositions
A plan library contains both primitive andnon-primitive actions.
Non-primitive actions have external preconditions,as well as external effects.
Sometimes useful to distinguish between primaryeffects and secondary effects.
Sec. 11.2 – p.6/25
Building a house with causal links
PayBuilder
ObtainPermit
Construct
HireBuilder
decomposes to
BuildHouse
Land House
Land
Money
House
~ Money
Start Finish
Sec. 11.2 – p.7/25
Another way of building a house
Construct
ObtainPermit
GetFriend
decomposes to
BuildHouse
Land House
Land
House
BadBack
Start Finish
Cut logs
GoodFriend
Sec. 11.2 – p.8/25
Example action descriptions
Action(BuyLand, PRECOND:Money, EFFECT: Land ∧¬ Money)Action(GetLoan, PRECOND:GoodCredit, EFFECT: Money ∧ Mortgage)Action(BuildHouse, PRECOND:Land, EFFECT: House)
Action(GetPermit, PRECOND:Land, EFFECT: Permit)Action(HireBuilder, EFFECT: Contract)Action(Construct, PRECOND:Permit ∧ Contract,
EFFECT: HouseBuilt ∧¬ Permit)Action(PayBuilder, PRECOND:Money ∧ HouseBuilt,
EFFECT: ¬ Money ∧ House ∧¬ Contract)
Sec. 11.2 – p.9/25
Example action descriptions
Decompose(BuildHouse,Plan(STEPS:{S1: GetPermit, S2: HireBuilder,Plan(STEPS:{ S3: Construction, S4: PayBuilder,}Plan( ORDERINGS: { Start ≺ S1 ≺ S2 ≺ S3 ≺ S4 ≺ Finish,Plan( ORDERINGS: { Start ≺ S2 ≺ S3 },Plan( L INKS: { Start Land
−−−→S1, Start Money
−−−−→S4,
Plan( L INKS: { S1 Permit−−−−−→
S3, S2 Contract−−−−−−→
S3, S3 HouseBuilt−−−−−−−−→
S4,
Plan( L INKS: { S4 House−−−−→
Finish, S4 ¬Money−−−−−−→
Finish}))
Sec. 11.2 – p.10/25
Correctness
A decomposition should be a correctimplementation of the action.
A plan d implements an action a correctly if d is acomplete and consistent partial-order plan for theproblem of achieving the effects of a given thepreconditions of a (result of a sound POP).
The plan library contains several decompositions forany high-level action.
Each decomposition might have differentpreconditions and effects. The preconditions of thehigh-level action should be the intersection of thepreconditions of the decompositions (similarly forthe external effects.)
Sec. 11.2 – p.11/25
Information hiding
The high-level description hides all the internaleffects of decompositions (e.g., Permit andContract).
It also hides the duration the internal preconditionsand effects hold.
Advantage: reduces complexity by hiding details
Disadvantage: conflicts are hidden too
Sec. 11.2 – p.12/25
Example
Start
PayBuilder
Finish
FinishBuy Land
GetPermit
Construct
HireBuilder
decomposes to
BuildHouse
House
House
~ Money
Start
Land
Buy Land
GetLoan
Money
GoodCredit
Land
Money
Money
~ Money
Sec. 11.2 – p.13/25
For each decomposition d of an action a
Remove the high level action, and insert/reuseactions for each action in d.reuse → subtask sharing
Merge the ordering constraints (If there is anordering constraint of the form B ≺ a, should everystep of d come after B?)
Merge the causal links
Sec. 11.2 – p.14/25
Action ordering
Start
GiveChain
Start
~ WatchCombHappy(She)
Finish Start
GiveComb
Finish
WatchHair
WatchHair Happy(He)
Chain
Give Combon credit
DeliverWatch
Start
DeliverHair
Give Chainon credit
WatchHair
Hair
Watch
comb
chainowe(hair)happy(He)
watch
hair~hair~owe(hair)
happy(she)owe(watch)
~owe(hair)~watch
~Hair
HairWatch
Happy(She)Happy(He)
Sec. 11.2 – p.15/25
HTN planners
Most industrial strength planners are HTN based.
O-PLAN combines HTN planning with scheduling todevelop production plans for Hitachi.
SIPE-2 is an HTN planner with many advancedfeatures
SHOP is an HTN planner developed at the Universityof Maryland. It can deal with action durations.
Sec. 11.2 – p.16/25
The features of SIPE-2
Plan critics
Resource reasoning
Constraint reasoning (complex numerical orsymbolic variable and state constraints)
Interleaved planning and execution
Interactive plan development
Sophisticated truth criterion
Conditional effects
Parallel interactions in partially ordered plans
Replanning if failures occur during execution
Sec. 11.2 – p.17/25
An operator with constraints
OPERATOR decomposePURPOSE: ConstructionCONSTRAINTS:
Length (Frame) Wt(Frame) + Wt(Roof)
+ Wt(Walls) + Wt(Interior) + Wt(Contents)PLOT: Build (Foundation)
Build (Frame)PARALLEL
Build (Roof)Build (Walls)
END PARALLELBuild (Interior)
Sec. 11.2 – p.18/25
More on SIPE-2
Russell & Norvig explicitly represent causal links;these can also be computed dynamically by using amodel of preconditions and effects (this is whatSIPE-2 does)
Dynamically computing causal links means thatactions from one operator can safely be interleavedwith other operators, and subactions can safely beremoved or replaced during plan repair
Russell & Norvig’s representation only includesvariable bindings, but more generally we canintroduce a wide array of variable constraints
Sec. 11.2 – p.19/25
Truth Criterion
Determining whether a formula is true at a particularpoint in a partially ordered plan is, in the generalcase, NP-hard
Intuition: there are exponentially many ways tolinearize a partially ordered plan
In the worst case, if there are N actions unorderedwith respect to each other, there are N!linearizations
Sec. 11.2 – p.20/25
Truth Criterion
Ensuring soundness of the truth criterion requireschecking the formula under all possiblelinearizations
Use heuristic methods instead to make planningfeasible
Check later to be sure no constraints have beenviolated
Sec. 11.2 – p.21/25
Truth Criterion in Sipe-2
Heuristic: prove that there is one possible orderingof the actions that makes the formula true, but don’tinsert ordering links to enforce that order
Such a proof is efficientSuppose you have an action A1 with aprecondition PFind an action A2 that achieves P (A2 could beinitial world state)Make sure there is no action necessarilybetween A2 and A1 that negates P
Applying this heuristic for all preconditions in theplan can result in infeasible plans
Sec. 11.2 – p.22/25
Comments on HTN planning
The major idea is to gain efficiency by using thelibrary of preconstructed plans.
When there is recursion, it is undecidable even if theunderlying state space is finite.
recursion can be ruled outthe length of solutions can be boundcan use a hybrid POP and HTN approach
Sec. 11.2 – p.23/25
Comments on HTN planning (cont’d)
Subtask sharing is nice, but it takes time/resourcesto notice the opportunities
Would interprocedural optimization be a possibility?Consider tan(x) − sin(x). Both have Taylor seriesapproximations:tan(x) ≈ x + x
3
3 +2x5
15 +17x7
315
sin(x) ≈ x − x3
6 +x5
120 −x7
5040
It would be nice to share terms but a compiler canonly optimize within the code because it does nothave the source; and if it did interproceduraloptimization tan and sin would always have to bechanged together.
Sec. 11.2 – p.24/25
Comments on HTN planning (cont’d)
Suppose that we want to construct a plan with nactions
Forward state space planning takes O(bn) with ballowable actions at each state.HTN planning can construct d(n−1)/(k−1)
decomposition trees with d possibledecompositions with k actions each→ keeping d small and k large can result in hugesavings (long macros usable across a widerange of problems)HTN-based planners do not address uncertainty
Sec. 11.2 – p.25/25
OutlineHierarchical Task Network (HTN) planningBuilding a houseHierarchical decompositionRepresenting action decompositionsBuilding a house with causal linksAnother way of building a houseExample action descriptionsExample action descriptionsCorrectnessInformation hidingExampleFor each decomposition $d$ of an action $a$Action orderingHTN plannersThe features of SIPE-2An operator with constraintsMore on SIPE-2Truth CriterionTruth CriterionTruth Criterion in Sipe-2Comments on HTN planningComments on HTN planning (cont'd)Comments on HTN planning (cont'd)