Automated Planning. Hierarchical Task Networks

Automated Planning Hierarchical Task Networks Jonas Kvarnström Automated Planning Group Department of Computer and Information Science Linköping Unive...
Author: Marcia Reed
2 downloads 4 Views 7MB Size
Automated Planning Hierarchical Task Networks Jonas Kvarnström Automated Planning Group Department of Computer and Information Science Linköping University [email protected] – 2014



2

Classical Planning vs. Hierarchical Task Networks: Objective is to achieve a goal:

Objective is to perform a task:

at(TimesSquare) { on(A,B), on(C,D) } …

travel-to(TimesSquare) place-blocks-correctly …

Find any sequence of actions that achieves the goal

Incrementally refine the task until you reach the level of primitive actions travel-to(TimesSquare)  taxi-to(airport); fly-to(JFK); …

Provides guidance but still requires planning

jonkv@ida

HTNs: Ideas

A simple form of Hierarchical Task Network, as defined in the book



A primitive task is an operator / action  As in classical planning, what is primitive depends on the execution system

and on how detailed you want your plans to be ▪ For you, fly(here,there) may be a primitive task ▪ For the pilot, it may be decomposed into many smaller steps stack(A,B) load(crane1, loc3, cont5, …) point(camera4, obj4)

Dark green (in this presentation): "Done", no need to think further

 Can be ground or non-ground: stack(A,x) ▪ No separate terminology, as in operator/action

4

jonkv@ida

Terminology 1: Primitive Task



A non-primitive task:  Cannot be directly executed  Must be decomposed into 0 or more subtasks put-all-blocks-in-place() make-tower(A,B,C,D,E) move-stack-of-blocks(x, y) Should be decomposed to sequences of pickup, putdown, stack, unstack actions!

Orange: There's a problem that we need to solve

5

jonkv@ida

Terminology 2: Non-Primitive Task



6

A method specifies one way to decompose a primitive task  Can have many methods per non-primitive task travel(from, to)

travel(from, to)

go-by-plane(from, to)

go-on-foot(from, to)

Light green: A potential template for a solution

jonkv@ida

Terminology 3: Method

7

jonkv@ida

Totally Ordered STNs In Totally Ordered Simple Task Networks (STN), each method must specify a sequence of subtasks (indicated by the horizontal arrow) The “travel” task has a method called “go-by-plane”

buy-ticket (airport(x), airport(y))

travel (x, airport(x))

travel(x,y)

Task

go-by-plane(x,y)

Method

fly(airport(x), airport(y))

Each method can also have a precondition (exemplified later)

travel (airport(y), y)



8

Since a non-primitive task can have many methods: 

You still need to search, to determine which method to use



…and to determine parameters (shown later)

get-taxi-at(x)

travel(x,y)

Task

taxi-travel(x,y)

Method

ride-taxi(x, y)

pay-driver

travel(x,y)

Task

foot-travel(x,y)

Method

walk(x, y)

Non-primitive subtasks

Primitive subtask

jonkv@ida

Multiple Methods



9

jonkv@ida

Composition Properties of these plans:  Hierarchical  Consist of tasks  Based on graphs ≈ networks

buy-ticket (airport(x), airport(y))

travel (x, airport(x))

travel(x,y)

Task

go-by-plane(x,y)

Method

fly (airport(x), airport(y))

foot-travel(x,y)

taxi-travel(x,airport(x))

get-taxi-at(x)

ride-taxi(x, airport(x))

travel (airport(y), y)

pay-driver

walk(x, y)



10

Let’s switch to Dock Worker Robots…

c3 c1 p1

p2

loc1

jonkv@ida

DWR



11

jonkv@ida

Methods To move the topmost container from one pile to another: 

The task has parameters given from above



A method can have additional parameters, whose values are chosen by the planner – just as in classical planning!



If you are asked to check all possible values for

The precond adds constraints: must be some crane in the same as the piles, must be the topmost container of ,…

Interpretation: where the preconds are satisfied



12

To move the topmost container from one pile to another:  





move-topmost-container(pile1, pile2) take-and-put(…)

take(…)

put(…)

jonkv@ida

Methods (2)



13

Suppose want to move three entire stacks of containers  But preserve the order of the containers!  Call this task

()

Initial state, with 3 locations, 3 piles to move

Corresponding goal, all piles moved

jonkv@ida

Example



How do we do it?  First move all containers to another pile,

so they end up in inverse order  Then move them to the real destination

14

jonkv@ida

Example



15

A total-order method using this technique: :

 ▪ ▪ ▪

No parameters: Hardcoded which stacks to move

: : :

Tuple: All subtasks are sequentially ordered

jonkv@ida

Example 2: move-each-twice



Alternative:  ▪ ▪ Let the planner choose intermediate piles (there might be several alternatives)! ▪

16

jonkv@ida

Example 2b: move-each-twice



17

How can we implement the task

?

 Must move all containers in a stack, but we don’t know how many…  HTN planning allows recursion ▪ Move the topmost container (we know how to do that!) ▪ Then move the rest  First attempt: ▪ ▪ : ▪ : ▪ : move-stack(pile1, pile2) recursive-move(pile1, pile2, …) move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

recursive-move(pile1, pile2, …)

jonkv@ida

Recursion (1)



18

But consider the BW and DWR "pile models"… BW

A

DWR clear(A) on(A,B)

B C

A

top(A, pile1) on(A,B)

B on(B,C) ontable(C)

The bottom block is not "on" anything

C

on(B,C) on(C,pallet)

The bottom block is "on" the pallet, a "special container" We don't want to move the pallet!

jonkv@ida

Recursion (2)



To fix this:

Add two method params

 ▪ ▪ ▪

19

: : cont is on top of something (x), so cont can’t be the pallet

jonkv@ida

Recursion (3)



20

The planner can now create a structure like this: move-stack(pile1, pile2) recursive-move(pile1, pile2, …) move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

recursive-move(pile1, pile2, …)

take(…)

put(…) move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

recursive-move(pile1, pile2, …)

take(…)

put(…)

move-topmost

But when will the recursion end?

move-stack

jonkv@ida

Recursion (4)



21

At some point, only the pallet will be left in the stack  Then recursive-move will not be applicable  But we specified that we must execute some form of move-stack! move-stack(pile1, pile2) recursive-move(pile1, pile2, …) move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

recursive-move(pile1, pile2, …)

take(…)

put(…) move-topmost-container(pile1, pile2) take-and-put(…)

take(…)

put(…)

move-stack(pile1, pile2) is empty! No applicable methods… Planner would backtrack!

jonkv@ida

Recursion (5)



22

We need a method that terminates the recursion Unique pallet object – not a variable!

:



: :

▪ ▪ ▪

move-stack(pile1, pile2) :

recursive-move(pile1, pile2, …)

move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

recursive-move(pile1, pile2, …)

take(…)

put(…) move-topmost-container(pile1, pile2)

move-stack(pile1, pile2)

take-and-put(…)

already-moved(pile1,pile2)

take(…)

put(…)

Method preconds satisfied Zero subtasks!

jonkv@ida

Recursion (6)



An HTN planning domain specifies:  Tasks that are available (primitive and non-primitive)  Methods to decompose non-primitive tasks into subtasks  Constraints to be enforced ▪ E.g., don't use a taxi for long distances



An HTN problem instance specifies:  Initial state information  One or more tasks to perform, with concrete parameters ▪ For Total Order Simple Task Networks: A sequence of tasks to perform ▪

Suggest Documents