Hierarchical Task Network (HTN) Planning José Luis Ambite*

advertisement
Hierarchical Task Network (HTN)
Planning
José Luis Ambite*
[* Based in part on presentations by Dana Nau and Rao Kambhampati]
1
Hierarchical Decomposition
2
Task Reduction
3
Hierarchical Planning Brief History
ƒ Originally developed about 25 years ago
ƒ NOAH [Sacerdoti, IJCAI 1977]
ƒ NONLIN [Tate, IJCAI 1977]
ƒ Knowledge-based Æ Scalable
ƒ Task Hierarchy is a form of domain-specific knowledge
ƒ Practical, applied to real world problems
ƒ Lack of theoretical understanding until early
1990’s [Erol et al, 1994] [Yang 1990] [Kambhampati 1992]
ƒ Formal semantics, sound/complete algorithm,
complexity analysis [Erol et al, 1994]
4
Deployed, Practical Planners
ƒ SIPE, SIPE-2 [Wilkins, 85-]
ƒ http://www.ai.sri.com/~sipe/
ƒ NONLIN/O-Plan/I-X [Tate et. al., 77-]
ƒ http://www.aiai.ed.ac.uk/~oplan/
ƒ http://www.aiai.ed.ac.uk/project/ix/
ƒ Applications:
ƒ Logistics
ƒ Military operations planning: Air campaign planning, NonCombatant Evacuation Operations
ƒ Crisis Response: Oil Spill Response
ƒ
ƒ
ƒ
ƒ
Production line scheduling
Construction planning: Space platform building, house construction
Space applications: mission sequencing, satellite control
Software Development: Unix administrator's script writing
5
Deployed, Practical Planners
Many features:
ƒ Hierarchical decomposition
ƒ Resources
ƒ Time
ƒ Complex conditions
ƒ Axioms
ƒ Procedural attachments
ƒ Scheduling
ƒ Planning and Execution
ƒ Knowledge acquisition tools
ƒ Mixed-initiative
6
7
O-Plan
8
HTN Planning
ƒ Capture hierarchical structure of the
planning domain
ƒ Planning domain contains non-primitive
actions and schemas for reducing them
ƒ Reduction schemas:
ƒ given by the designer
ƒ express preferred ways to accomplish a task
9
HTN Formalization (1)
ƒ State: list of ground atoms
ƒ Tasks:
ƒ Primitive tasks: do[f(x1, …, xn)]
ƒ Non-primitive tasks:
ƒ Goal task: achieve(l)
(l is a literal)
ƒ Compound task: perform[t(x1, …, xn)]
ƒ Operator:
ƒ [operator f(x1, …, xn) (pre: l1, …, ln) (post: l’1, …, l’n)]
ƒ Method: (α, d)
ƒ α is a non-primitive task and d is a task network
ƒ Plan: sequence of ground primitive tasks
(operators)
10
HTN Formalization (2)
ƒ Task network: [(n1 : α1) … (nm : αm), φ]
ƒ ni = node label
ƒ αi = task
ƒ φ = formula that includes
ƒ Binding constraints: (v = v’) or (v ≠ v’)
ƒ Ordering constraints: (n < n’)
ƒ State constraints:
ƒ (n, l, n’): interval preservation constraint (causal link)
ƒ (l, n): l must be true in state immediately before n
ƒ (n, l): l must be true in state immediately after n
11
Task Network Example
12
HTN Planning Algorithm (intuition)
Problem reduction:
ƒ Decompose tasks into subtasks
ƒ Handle constraints
ƒ Resolve interactions
ƒ If necessary, backtrack and try other
decompositions
13
Basic HTN Procedure
1. Input a planning problem P
2. If P contains only primitive tasks, then resolve
the conflicts and return the result. If the
conflicts cannot be resolved, return failure
3. Choose a non-primitive task t in P
4. Choose an expansion for t
5. Replace t with the expansion
6. Find interactions among tasks in P and
suggest ways to handle them. Choose one.
7. Go to 2
14
ground total ordering
satisfying constraints
m = (α’, d’) s.t.
mgu(α, α’) = θ
τ= “critics” to
resolve conflicts
Reduce(d, n, m) = task network obtained
from d by replacing (n : α)θ with d’θ
(and modifying the constraint formula)
15
Similarity between reduction schemas
and plan-space planning
GobyBus(S,D)
In(B)
t1: Getin(B,S)
Hv-Tkt
t2: BuyTickt(B)
t3: Getout(B,D)
Hv-Money
At(D)
Get(Money)
At(Msn)
GobyBus(Phx,Msn)
Buy(WiscCheese)
Hv-Money
t1: Getin(B,Phx)
In(B)
Hv-Tkt
t2: BuyTickt(B)
Get(Money)
Hv-Money
t3: Getout(B,Msn)
At(D)
Buy(WiscCheese)
16
17
18
19
Refinement
Planning
[Kambhampati 96]
Task
reduction
20
Refinement Planning
ƒ Unified framework for state-space,
plan-space, and HTN planning
[Kambhampati et al, 96]
21
Expressiveness of
STRIPS vs HTN planning
ƒ Solutions to STRIPS problems are regular
sets: (a1| a2|… an)*
ƒ Solutions to HTN problems can be
arbitrary context-free sets: a1n a2n… ann
HTN’s are more expressive than STRIPS
22
Task Decomposition via Plan Parsing
ƒ Task decomposition hierarchy can be
seen as a context-free grammar
ƒ Prune plans that do not conform to the
grammar in a Partial-Order planner
[Barret & Weld, AAAI94]
23
Task Decomposition via Plan Parsing
24
Ordered Task Decomposition
ƒ Adaptation of HTN planning
ƒ Subtasks of each method to be totally ordered
ƒ Decompose these tasks left-to-right
ƒ The same order that they’ll later be executed
Make the artwork for a PC board
Preclean for artwork
Spindling
Apply photoresist
Spraying
Spreading
Photolithography
Etching
Painting
25
26
SHOP
(Simple Hierarchical Ordered Planner)
ƒ Domain-independent algorithm for
Ordered Task Decomposition
ƒ Sound/complete
ƒ Input:
ƒ State: a set of ground atoms
ƒ Task List: a linear list of tasks
ƒ Domain: methods, operators, axioms
ƒ Output: one or more plans, it can return:
ƒ
ƒ
ƒ
ƒ
the first plan it finds
all possible plans
a least-cost plan
all least-cost plans
27
Simple Example
ƒ Initial task list:
((travel home park))
ƒ Initial state: ((at home) (cash 20) (distance home park 8))
ƒ Methods (task, preconditions, subtasks):
ƒ (:method (travel ?x ?y)
((at x) (walking-distance ?x ?y)) ' ((!walk ?x ?y)) 1)
Optional cost;
ƒ (:method (travel ?x ?y)
default is 1
((at ?x) (have-taxi-fare ?x ?y))
' ((!call-taxi ?x) (!ride ?x ?y) (!pay-driver ?x ?y)) 1)
ƒ Axioms:
ƒ (:- (walking-dist ?x ?y) ((distance ?x ?y ?d) (eval (<= ?d 5))))
ƒ (:- (have-taxi-fare ?x ?y)
((have-cash ?c) (distance ?x ?y ?d) (eval (>= ?c (+ 1.50 ?d))))
ƒ Primitive operators (task, delete list, add list)
ƒ (:operator (!walk ?x ?y) ((at ?x)) ((at ?y)))
ƒ …
28
Initial state:
(at home)
(cash 20)
(distance home park 8)
Simple Example
(Continued)
(travel home park)
Precond:
(at home)
Succeed
Precond:
(walking-distance
Home park)
Fail (distance > 5)
(!call-taxi home)
(!walk home park)
(at home)
(have-taxi-fare home park)
Succeed
Succeed (we have $20,
and the fare is only $9.50)
(!ride home park)
(!pay-driver home park)
Final state: (at park)
(cash 10.50)
(distance home park 8)
29
The SHOP Algorithm
state S; task list T=( t1 ,t2,…)
procedure SHOP (state S, task-list T, domain D)
operator instance o
1.
if T = nil then return nil
2.
t1 = the first task in T
state o(S) ; task list T=(t2, …)
3.
U = the remaining tasks in T
4.
if t is primitive & an operator instance o matches t1 then
5.
P = SHOP (o(S), U, D)
nondeterministic choice
6.
if P = FAIL then return FAIL
among all methods m
7.
return cons(o,P)
whose preconditions
8.
else if t is non-primitive
can be inferred from S
& a method instance m matches t1 in S
& m’s preconditions can be inferred from S then
9.
return SHOP (S, append (m(t1), U), D)
10. else
task list T=( t1 ,t2,…)
11.
return FAIL
method instance m
12.
end if
end SHOP
task list T=( u ,…,u ,t ,…)
1
k
2
30
Blocks World
ƒ 100 randomly
generated problems
ƒ 167-MHz Sun Ultra
with 64 MB of RAM
ƒ Blackbox and IPP
could not solve
any of these problems
ƒ TLplan’s running time
was only slightly worse
than SHOP’s
1000
Time
100
10
SHOP
TLPlan
1
0.1
0.01
400
350
300
ƒ TLplan’s pruning rules 250
[Bacchus et al., 2000] 200
have expressive power 150
similar to SHOP’s
100
ƒ Using its pruning rules, 50
0
they encoded a blockstacking algorithm
similar to ours
Number of actions in plan
SHOP
TLPlan
31
Logistics
ƒ 110 randomly
generated problems
ƒ Same machine
as before
ƒ As before, Blackbox
and IPP could not
solve any of these
problems
ƒ TLplan ran
somewhat slower
than SHOP
(about an order of
magnitude on large
problems)
10000
1000 Time
100
10
1
0.1
SHOP
TLPlan
500
400Number of actions in plan
300
200
SHOP
TLPlan
100
0
32
Logistics
ƒ
ƒ
ƒ
ƒ
ƒ
30 problems from
the Blackbox
distribution
SHOP and TLplan
on the same
machine as before
Blackbox on a faster
machine, with 8GB
of RAM
SHOP was about an
order of magnitude
faster than TLplan
TLplan was about
two orders of
magnitude faster
than Blackbox
10000
1000
100
Time
10
1
Blackbox
TLPlan
SHOP
0.1
100
80 Number of actions in plan
60
40
20
Blackbox
TLPlan
SHOP
0
33
SHOP demo
34
35
Download