+ All Categories
Home > Documents > Chapter03b

Chapter03b

Date post: 13-Apr-2017
Category:
Upload: tianlu-wang
View: 221 times
Download: 0 times
Share this document with a friend
63
1 Dana Nau and Vikas Shivashankar: Lecture slides for Automated Planning and Ac0ng Updated 3/24/15 This work is licensed under a CreaCve Commons AFribuConH NonCommercial H ShareAlike 4.0 InternaConal License . Chapter 3 Delibera.on with Refinement Methods Planning (Sec.on 3.4) Dana S. Nau and Vikas Shivashankar University of Maryland
Transcript
Page 1: Chapter03b

1"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

This"work"is"licensed"under"a"CreaCve"Commons"AFribuConHNonCommercialHShareAlike"4.0"InternaConal"License."

Chapter(3((Delibera.on(with(Refinement(Methods(

(Planning((Sec.on(3.4)(

Dana S. Nau and Vikas Shivashankar

University of Maryland

Page 2: Chapter03b

2"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

ungrasp

graspknob

turnknob

maintainmove back

pull

monitor

identifytype of

doorpull

monitor

move close

to knob

open door

……

get out close door

respond to user requests

… …bring o7 to room2

go to hallway

deliver o7

…… … …

move to door

fetch o7

navigate to room2

navigate to room1

Mo.va.on(●  Actor is hierarchically organized ●  Suppose a node of the tree contains

an action a ●  At the next level down, a is a task

that needs to be performed !  Recursively refine

tasks into subtasks ●  Dashed blue lines:

!  CSV planner can do the refinement

●  Solid red lines: !  need other techniques

●  A refinement method is

an operational model !  A program to compute

a refinement !  Actor can use it online

Page 3: Chapter03b

3"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Nota.on(and(Terminology(●  Recall from Chapter 2 that the actor’s state ξ may differ from the state s that the

actor gives to the planner !  ξ is the actor’s current state

•  the execution platform keeps it up-to-date !  Ξ = {all possible states}

●  Fact: an atom that’s true in the current state ●  Task: an activity that the actor needs to carry out

●  State variables are like CSV state variables, but more flexible: !  If x is a state variable, Range(x) can be anything you want

•  integers, real numbers, vectors, matrices, other data structures ●  Assignments are like the ones in CSV operators

!  x ← v ●  Simple test: x = v, x ≠ v, x > v, x < v ●  Compound test: conjunction, disjunction, or negation of simple tests

Page 4: Chapter03b

4"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

State(Variables(●  Like CSV state variables, but more general

!  Range(x) can be anything you want •  integers, real numbers, vectors, matrices, other data structures

●  Used in assignments and tests !  Assignments are a generalization of the ones in CSV operators

•  x ← expression !  Simple tests: x = v, x ≠ v, x > v, x < v !  Compound tests:

•  conjunctions, disjunctions, negations of simple (and compound?) tests

Page 5: Chapter03b

5"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(●  Objects

!  Robots = {rbt}, Containers = {c1, c2, …}, Locations = {loc1, loc2, …}. ●  State variables

!  loc(r) ∈ Locations !  load(r) ∈ Containers ⋃ {nil} !  pos(c) ∈ Locations ⋃ Robots ⋃ {unknown} !  view(l) ∈ {T, F}

•  whether the robot has looked at location l or not •  If view(l)=T then for every container c in l, pos(c) = l

●  Commands to the execution platform: !  goto(r,l): robot r goes to location l !  take(r,o): r takes object o !  put(r,o): r puts o !  perceive(r,l): robot r perceives what objects are at a location l

Page 6: Chapter03b

6"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Refinement(Methods(●  Refinement method: a triple (task or event, precondition, body)

!  a task or event that the method can be used for !  precondition that needs to be true for the method to be applicable !  body: a program

●  Write in the following format: •  method-name(arg1, …, argk)

task: task or event: event pre: precondition body: body

●  body: sequence of steps !  assignments, commands, tasks !  control constructs: if-then-else, while, loop, etc.

Page 7: Chapter03b

7"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Con.nue(Previous(Example(●  Task: fetch container c ●  Method: if you know c’s location, then go get it; else search

mHfetch(r,c) task: fetch(r,c) pre: body: if pos(c) = unknown then search(r,c) else if loc(r) = pos(c) then take(r,c) else do goto(pos(c)) take(r,c)

mHsearch(r,c) task: search(r,c) pre: pos(c) = unknown body: if ∃l (view(l)=F) then

goto(l) perceive(l) if pos(c)=l then take(r,c) else search(r,c) else fail

Page 8: Chapter03b

8"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Con.nue(Previous(Example(

●  Event: emergency call !  Stop current activity, go where the emergency is

●  Another state variable !  emergencyHhandling(r) ∈ {T, F}

•  whether r is handling an emergency

●  Method: mHemergency(r,l,i)

task: emergency(l,i) pre: emergencyHhandling=F body: emergencyHhandling ← T

if loaded(r) ≠ nil"then " "put(r,load(r)) goto(l) addressHemergency(l,i)

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 9: Chapter03b

9"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Con.nue(Previous(Example(

●  Commands used for opening a door !  moveHclose(r,o): r moves to a position

where reachable(r,o)=T"!  moveHby(r,λ): r moves with magnitude and

direction given by vector λ !  grasp(r,o): r grasps object o !  ungrasp(r,o): r release grasp on o !  turn(r,o,α): r turns a grasped object

o by angle α ∈ [−π,+π] !  pull(r,λ): r pulls its arm by vector λ !  push(r,λ): r pushes its arm by λ !  monitorHstatus(r,d):

r focuses its perception to keep doorHstatus"updated (starts a process)

!  endHmonitorHstatus(r,d): r stops monitoring d (terminates a process)

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 10: Chapter03b

10"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Con.nue(Previous(Example(

●  Task: open the door mHopendoor(r,d,l,o)""

task: opendoor(r,d)"" pre: loc(r)"="l"∧"adjacent(l,d)"∧"handle(d,o)"""body: while ¬reachable(r,o)"do " " "moveHclose(r,o)""" "monitorHstatus(r,d)""" "if doorHstatus(d)=closed"then unlatch(r,d) "" "throwHwide(r,d) " "endHmonitorHstatus(r,d)

"

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 11: Chapter03b

11"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Con.nue(Previous(Example(m1Hunlatch(r,d,l,o)

task: unlatch(r,d) pre: loc(r,l) ∧ towardHside(l,d) ∧ side(d,leX) ∧ type(d,rotate) ∧ handle(d,o) body: grasp(r,o) turn(r,o,alpha1) pull(r,val1) if doorHstatus(d)=cracked"then ungrasp(r,o) else fail

"

"

m1-throw-wide(r,d,l,o) task: throwHwide(r,d) pre: loc(r,l) ∧ towardHside(l,d) ∧ side(d,leX) ∧ type(d,rotate) ∧ handle(d,o) ∧ doorHstatus(d)=cracked" body: grasp(r,o) pull(r,val1) moveHby(r,val2)"

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 12: Chapter03b

12"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Acting

tasks

Execution Platform

Environment

eventscommands

!M Refinement(Ac.ng(Engine(

(RAE)(

●  Perform external tasks and events in parallel !  For each, an

execution stack ●  Agenda =

{current stacks}

●  Based on OpenPRS !  Programming language, open source software !  Used widely used in robotics

●  Input: facts, external tasks, events ●  Output: commands to execution platform

Page 13: Chapter03b

13"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

●  An execution stack corresponds to the current path in a search tree

●  Each element: !  Task or event τ !  Current method m for τ !  Execution pointer i for body(m)

•  τ[i] = current instruction !  Methods that were

previously tried for m

Acting

tasks

Execution Platform

Environment

eventscommands

!M Execu.on(Stacks(in(RAE(

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 14: Chapter03b

14"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Progressing(a(Stack(

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 15: Chapter03b

15"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

If(a(Method(Fails(●  Similar to backtracking

!  If one method fails, then try another !  If no more applicable methods, then fail

●  But not identical to backtracking !  ξ may have changed during the previous refinement

•  Because of something the actor did •  Because the world may change dynamically

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 16: Chapter03b

16"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Goals(in(RAE(●  Special kind of task: achieve(condition) ●  Like other tasks, except that it includes monitoring

•  Can easily modify the Progress procedure to do this !  If condition becomes true during execution, stop execution early !  If condition isn’t true after execution, then fail (triggers a Retry)

!  mHfetch(r,c) task: fetch(r,c) pre: body: achieve(pos(c) ≠ unknown) goto(pos(c)) take(r,c)

!  mHfindHwhere(r,c) goal: achieve(pos(c) ≠ unknown) pre: body: while there is a location l such that view(l)=F"do goto(l) perceive(l)

Page 17: Chapter03b

17"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Extensions(to(RAE(●  Section 3.3.4 discusses some additional features that extend RAE’s capabilities:

!  Controlling the progress of tasks, e.g., suspend a task for a while !  Refining into concurrent subtasks

•  mHfoo(x,y,z) task: foo(x,y,z) pre: body: .".". {concurrent: ⟨ν1,1,...,ν1,n⟩⟨ν2,1,...,ν2,m⟩...⟨νk,1,...,νk,l⟩}

•  Each ⟨νi,1,...,νi,j⟩ is a sequence of steps, like the body of a method •  Split the current stack into k sub-stacks, one for each ⟨νi,1,...,νi,j⟩

!  Choosing methods, and stack ordering •  If there are multiple stacks, which ones get higher priority?

▸  Application-specific heuristics •  For a task t, which method to try first?

▸  Refinement planning (Section 3.4)

Page 18: Chapter03b

18"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Refinement(Planning(●  When dealing with an event or task, RAE

requires choosing a refinement method to decompose it

●  An important question we need to address: Which method to try first?

●  Important because RAE immediately executes commands that are generated during decomposition !  Costly/irreversible; cannot reverse

effects if bad method is chosen

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Page 19: Chapter03b

19"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Refinement(Planning(

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Blue door has obstacle in front of it. With RAE, agent will realize this impacts the plan only when it attempts to open the door

Page 20: Chapter03b

20"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Refinement(Planning(●  When dealing with an event or task, RAE

requires choosing a refinement method to decompose it

●  An important question we need to address: Which method to try first?

●  Important because RAE immediately executes commands that are generated during decomposition !  Costly/irreversible; cannot reverse

effects if bad method is chosen ●  Solution: predict effects of available

methods to determine best course of action !  Instead of executing commands

immediately, simulate effects of commands using descriptive action models (like in Chap. 2)

startmonitor

open door

m-fetch

take o7

move close to handle

goto door

m-opendoor

get out close door

unlatch throw wide end monitor

go to loc1

fetch o7

… … methods for differentkinds of doors

•••

Ruofei Du
Ruofei Du
Ruofei Du
Ruofei Du
Page 21: Chapter03b

21"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Sequen.al(Refinement(Planning(Engine((SeRPE)(●  An algorithm that does refinement planning to determine best sequence of method

applications (and hence, the best course of action) ●  Refines tasks similar to RAE, except:

!  where RAE executes a command that changes the world state, SeRPE instead uses a descriptive action model to predict the next world state

●  Assumptions SeRPE makes:

!  All action models have deterministic outcomes (like in Chapter 2) •  E.g. unlatch"command in reality has several possible outcomes –

successful execution ensures door is unlatched, failure implies door still latched, etc

•  Our action model for unlatch will only have a single outcome !  No methods have concurrent"operators – so tasks cannot execute in parallel

•  We’ll relax this assumption in the Interleaved"Refinement"Planning"Engine algorithm (IRPE) later on

Page 22: Chapter03b

22"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem(Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

●  Same problem from Chapter 2 !  Now let’s solve this using SeRPE

●  We have seen action models for this domain: load,"unload,"move"

●  Next, we need to define tasks and refinement methods for this domain

Page 23: Chapter03b

23"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

uncover(c) – task of ensuring no containers are on c ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

Page 24: Chapter03b

24"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

uncover(c) – task of ensuring no containers are on c ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If c is not at the top of its pile (and c’ is on top of c), make c’ the top of the pile and then

remove c’

If c has nothing on it, do nothing

Page 25: Chapter03b

25"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

uncover(c) – task of ensuring no containers are on c ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

If c is not at the top of its pile (and c’ is on top of c), make c’ the top of the pile and then

remove c’

If c has nothing on it, do nothing

Page 26: Chapter03b

26"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

uncover(c) – task of ensuring no containers are on c ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If c has nothing on it, do nothing

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

If c is not at the top of its pile (and c’ is on top of c), make c’ the top of the pile and then

remove c’

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 27: Chapter03b

27"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

putHinHpile(c,p’) – task of putting c in pile p’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

Page 28: Chapter03b

28"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

putHinHpile(c,p’) – task of putting c in pile p’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If c is already in pile p’, do nothing

If c is in pile p≠p’, uncover c, pickup c and put it onto pile p’

Page 29: Chapter03b

29"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

putHinHpile(c,p’) – task of putting c in pile p’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If c is already in pile p’, do nothing

If c is in pile p≠p’, uncover c, pickup c and put it onto pile p’

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

Page 30: Chapter03b

30"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

putHinHpile(c,p’) – task of putting c in pile p’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If c is already in pile p’, do nothing

If c is in pile p≠p’, uncover c, pickup c and put it onto pile p’

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 31: Chapter03b

31"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

goto"(r,d’) – task of moving robot r to dock d’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

Page 32: Chapter03b

32"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

goto"(r,d’) – task of moving robot r to dock d’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If r is already at d’, do nothing

If r is not at d’, then go (be) somewhere adjacent to d’ and then move to d’

Page 33: Chapter03b

33"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

goto"(r,d’) – task of moving robot r to dock d’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If r is already at d’, do nothing

If r is not at d’, then go (be) somewhere adjacent to d’ and then move to d’

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 34: Chapter03b

34"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Example(Problem:(Tasks(

goto"(r,d’) – task of moving robot r to dock d’ ●  Need two methods to decompose this

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

If r is already at d’, do nothing

If r is not at d’, then go (be) somewhere adjacent to d’ and then move to d’

92 Chapter 3

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

The second method is applicable if r isn’t at d0. It navigates to a dockd that is adjacent to d0, and then moves r to d0. The dock d may ormay not be r’s current location.

route(r, d, d0)task: navigate(r, d0)pre: loc(r) 6= d0, adjacent(d, d0)

body: navigate(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as inExample 2.9, and s

3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the refinement trees corresponding to two of SeRPE’s non-deterministic execution traces. The terminal nodes of these trees correspondto the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

3.4.2 Interleaved Plans

In Section 3.4.1, one of the restrictions was that none of the methods inM could contain the “concurrent” programming construct described in Sec-

Draft, not for distribution. March 1, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 35: Chapter03b

35"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

●  From SeRPE’s viewpoint, a planning problem consists of: !  s0 – the initial state

•  shown below !  A – action models

•  load,"unload,"move !  M – refinement methods

•  noHremove,"removeHabove,"noHcarry,"carryHtoHpile,"noHgo,"route"

!  τ –task/goal to be accomplished •  putHinHpile (c1,p2)

Initial state s0

Plan(Genera.on(Using(SeRPE(

Section 3.4 91

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

method carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0 ^ occupied(d) = r ^ pile(c) = p

body: uncover(c)load(r, c, pos(c), p, d)if loc(r) 6= d0 then

goto(r, d0)unload(r, c, top(p0), p0, d0)

• goto(r, d0) is the task of moving r along some undetermined route thatends at dock d0. Again there are two methods. The first one returnssuccess if r is already at d0:

method no-go(r, d0)task: goto(r, d0)pre: loc(r) = d0

body: return

The second method is applicable if r isn’t at d0. It routes r through adock d that is adjacent to d0, and then moves r to d0. The dock d mayor may not be r’s current location.

method route(r, d, d0)task: goto(r, d0)pre: adjacent(d, d0)

body: goto(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as in

Draft, not for distribution. February 19, 2015.

Ruofei Du
Ruofei Du
Ruofei Du
Ruofei Du
Page 36: Chapter03b

36"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Plan(Genera.on(Using(SeRPE(

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Ruofei Du
Ruofei Du
Ruofei Du
Ruofei Du
Ruofei Du
Page 37: Chapter03b

37"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 38: Chapter03b

38"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 39: Chapter03b

39"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 40: Chapter03b

40"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

SeRPE called recursively on chosen method

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Ruofei Du
Page 41: Chapter03b

41"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 42: Chapter03b

42"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

… SeRPE called recursively on task

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 43: Chapter03b

43"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 44: Chapter03b

44"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

… SeRPE called recursively on method

Page 45: Chapter03b

45"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 46: Chapter03b

46"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

90 Chapter 3

in these methods have the following ranges: c 2 Containers; r 2 Robots;d, d0 2 Docks; p, p0 2 Piles. There are three kinds of tasks:

• uncover(c) is the task of ensuring that there are no containers on con-tainer c. For this task, there are two methods. The first one, which isapplicable only if nothing needs to be done, just returns success:

method no-remove(c, p)task: uncover(c)pre: pile(c) = nil _ top(p) = c

body: return success

The second method is applicable if there are containers on c and thereis another pile p0 at the same dock. If a robot is present at the dock, ituses the robot to move those containers to the other pile, and otherwiseit returns failure:

method remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p ^ c 6= top(p) ^

loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

method no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the same dock that p is on. It uses the robot to carry cto p0:

Draft, not for distribution. February 19, 2015.

Page 47: Chapter03b

47"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Ruofei Du
Page 48: Chapter03b

48"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

… called recursively on the action

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 49: Chapter03b

49"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 50: Chapter03b

50"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 51: Chapter03b

51"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

… called recursively on this task

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 52: Chapter03b

52"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 53: Chapter03b

53"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 54: Chapter03b

54"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

called recursively on this method

Page 55: Chapter03b

55"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

r already at d1, solved with no-go method with no actions added

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

The second method is applicable if r isn’t at d0. It navigates to a dockd that is adjacent to d0, and then moves r to d0. The dock d may ormay not be r’s current location.

route(r, d, d0)task: navigate(r, d0)pre: loc(r) 6= d0, adjacent(d, d0)

body: navigate(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as inExample 2.9, and s

3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the refinement trees corresponding to two of SeRPE’s non-deterministic execution traces. The terminal nodes of these trees correspondto the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

3.4.2 Interleaved Plans

In Section 3.4.1, one of the restrictions was that none of the methods inM could contain the “concurrent” programming construct described in Sec-

Draft, not for distribution. March 1, 2015.

Page 56: Chapter03b

56"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

92 Chapter 3

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

The second method is applicable if r isn’t at d0. It navigates to a dockd that is adjacent to d0, and then moves r to d0. The dock d may ormay not be r’s current location.

route(r, d, d0)task: navigate(r, d0)pre: loc(r) 6= d0, adjacent(d, d0)

body: navigate(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as inExample 2.9, and s

3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the refinement trees corresponding to two of SeRPE’s non-deterministic execution traces. The terminal nodes of these trees correspondto the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

3.4.2 Interleaved Plans

In Section 3.4.1, one of the restrictions was that none of the methods inM could contain the “concurrent” programming construct described in Sec-

Draft, not for distribution. March 1, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Page 57: Chapter03b

57"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

p1!!!!!c2!c1!

!!!!!!!!!d2!!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1!

Figure 3.8: Initial state for Example 3.8.

The second method is applicable if r isn’t at d0. It navigates to a dockd that is adjacent to d0, and then moves r to d0. The dock d may ormay not be r’s current location.

route(r, d, d0)task: navigate(r, d0)pre: loc(r) 6= d0, adjacent(d, d0)

body: navigate(r, d)move(r, d, d0)

Now consider the planning problem P = (M, A, s3

, put-in-pile(c1

, p2

)),where M contains the above six methods, A is the same set of actions as inExample 2.9, and s

3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the refinement trees corresponding to two of SeRPE’s non-deterministic execution traces. The terminal nodes of these trees correspondto the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

3.4.2 Interleaved Plans

In Section 3.4.1, one of the restrictions was that none of the methods inM could contain the “concurrent” programming construct described in Sec-

Draft, not for distribution. March 1, 2015.

Page 58: Chapter03b

58"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

… recursively invoked on action

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 59: Chapter03b

59"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 60: Chapter03b

60"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE(Pseudocode(92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

92 Chapter 3

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d1,d2)

actionmove(r1,d2)

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

taskgoto(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)methodroute(r1,d3,d2)

taskgoto(r1,d3)

methodroute(r1,d1,d3)

actionmove(r1,d3)

Figure 3.9: Decomposition trees for two solution plans.

Example 2.9, and s3

is the following state, which is shown in Figure 3.8:

s3

= {loaded(r1

) = nil, loc(p1

) = d1

, loc(p2

) = d2

,loc(p

3

) = d2

, loc(p4

) = d3

, loc(r1

) = d1

,occupied(d

1

) = r1

, occupied(d2

) = nil, occupied(d3

) = nil,pile(c

1

) = p1

, pile(c2

) = p1

, pile(c3

) = p2

,pos(c

1

) = c2

, pos(c2

) = nil, pos(c3

) = nil,top(p

1

) = c1

, top(p2

) = c3

, top(p3

) = nil,top(p

4

) = nil}.

(3.1)

Figure 3.9 shows the decomposition trees corresponding to two of SeRPE’snondeterministic execution traces. The terminal nodes of these trees corre-spond to the following solution plans:

⇡1

= hload(r1

, c1

, p1

),move(r1

, d1

, d2

), unload(r1

, c1

, p2

)i;⇡2

= hload(r1

, c1

, p1

),move(r1

, d1

, d3

),move(r1

, d3

, d2

), unload(r1

, c1

, p2

)i.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Section 3.4 91

remove-above(r, c, p, p0, d)task: uncover(c)pre: loc(r) = d ^ loc(p) = d ^ pile(c) = p

^ c 6= top(p) ^ loc(p0) = d ^ p 6= p0

body: if loaded(r) 6= nil thenunload(r, loaded(r), top(p0), p0, d)

while top(p) 6= cload(r, top(p), pos(top(p)), p, d)unload(r, loaded(r), top(p0), p0, d)

• put-in-pile(c, p0) is the task of putting container c into pile p0 if it is notalready there. As before, there are two methods. The first one returnssuccess if c is already in p0:

no-carry(c, p0)task: put-in-pile(c, p0)pre: pile(c) = p0

body: return success

The second method is applicable when c is in a pile p 6= p0 and thereis a robot at the dock p is on. It uses the robot to carry c to p0:

carry-to-pile(r, c, p, d, c0, p0, d0)task: put-in-pile(c, p0)pre: at(p, d) ^ at(p0, d0) ^ p 6= p0

^ occupied(d) = r ^ pile(c) = pbody: uncover(c)

load(r, c, pos(c), p, d)if loc(r) 6= d0 then

navigate(r, d0)unload(r, c, top(p0), p0, d0)

• navigate(r, d0) is the task of moving r along some undetermined routethat ends at dock d0. Again there are two methods. The first onereturns success if r is already at d0:

no-go(r, d0)task: navigate(r, d0)pre: loc(r) = d0

body: return

Draft, not for distribution. March 1, 2015.

Page 61: Chapter03b

61"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

SeRPE:(Refinement(of(Goals(

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

88 Chapter 3

SeRPE(M, A, s, ⌧)case(type(⌧)): // ⌧ is an action, task, goal, or method

action:if s satisfies pre(⌧) then return (h⌧i, �(s, ⌧))else return (h⌧i, failure)

task:Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidatesreturn SeRPE(M, A, s,m)

else return failuregoal:

if s satisfies ⌧ then return (hi, s)Candidates Instances(M(⌧), s)if Candidates 6= ? then

nondeterministically choose m 2 Candidates(⇡, s0) SeRPE(M, A, s,m)if s0 satisfies ⌧ then return (⇡, s0)else return (⇡, failure)

else do one of the following (see the text)⇢return (hi, failure)return Find-plan(M, A, s, ⌧)

method:i 0 // i is the program counter for body(⌧)⇡ hi // ⇡ will be the plan produced by body(⌧)loop

i nextstep(⌧, i)if i = success then return (⇡, s)else if i = failure then return (⇡, failure)// if we get here, ⌧ [i] is an action, task, or method(⇡0, s) SeRPE(M, A, s, ⌧ [i])⇡ ⇡.⇡0

if s = failure then return (⇡, failure)

Figure 3.7: SeRPE, the Sequential Refinement Planning Engine.

Draft, not for distribution. February 19, 2015.

Ruofei Du
Ruofei Du
Ruofei Du
Ruofei Du
Page 62: Chapter03b

62"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Interleaved(Refinement(Tree((IRT)(Procedure(●  Remember: SeRPE does not allow using the ‘concurrent’ programming construct

●  Assume same initial state as before ●  Assume we want to move both c1 and c3, to p2 and p1 respectively

!  Can be represented by two tasks: putHinHpile (c1, p2) and putHinHpile (c3,p1) ●  Problem: without concurrency, SeRPE needs to fully complete one of tasks

before beginning another

94 Chapter 3

!!!!!!!!!d1!

!!!!!!!!!!!d3!!

!!!!!!!!!d2!

p1!!!!!c2!c1!

!!!!!!!!!!!p2!c3!

!!!!!!!!!!!p3!

r1! r2!

Figure 3.10: The same initial state as in Example 2.6.

⇡4

to produce a plan such as this one:

⇡5

= hload(r1

, c1

, p1

), load(r2

, c3

, p2

),move(r2

, d2

, d3

),move(r1

, d1

, d2

),

move(r2

, d3

, d1

), unload(r1

, c1

, p2

), unload(r2

, c3

, p1

)i.

To provide a way of specifying that a plan such as ⇡5

is a permissiblesolution, we will allow the body of a method to include steps of the form

{interleave: p1

, . . . , pk

},

where each pj

is a sequence of steps pj

= h⌫j,1

, . . . , ⌫j,kj i. This operator has

the same semantics as the “concurrent” operator in Section 3.3.4, exceptthat only one command can be performed at a time.

Example 3.10. Continuing with Example 3.9, suppose that M includesone additional method, where c, c0 2 Containers and p, p0 2 Piles:

put-interleaved(c, p, c0, p0)task: put-both(c, p, c0, p0)pre: none

body: {interleave:hput-in-pile(c, p)i,hput-in-pile(c0, p0)i}

Then for the task put-both(c1

, p2

, c3

, p1

), we can generate ⇡5

using the re-finement tree shown in Figure 3.11.

Figure 3.12 shows a planning procedure, IRPE (Interleaved RefinementPlanning Engine), that can generate refinement trees such as the one inFigure 3.11. IRPE is a generalization of SeRPE that includes code to dealwith “interleave” statements. IRPE generates refinement trees that containfive kinds of nodes:

• A task node or action node contains a task or action, respectively.

Draft, not for distribution. March 1, 2015.

Ruofei Du
Ruofei Du
Page 63: Chapter03b

63"Dana"Nau"and"Vikas"Shivashankar:"Lecture"slides"for!Automated!Planning!and!Ac0ng" Updated"3/24/15"

Interleaved(Refinement(Tree((IRT)(Procedure(●  IRT extends SeRPE to

remedy this ●  Refer to 3.4.2 for more

details

Section 3.4 95

taskput-in-pile(c1,p2)

methodcarry-to-pile(r1,c1,p1,d1,p2,d2)

taskuncover(c1)

methodno-remove(c1)

tasknavigate(r1,d2)

actionload(r1,c1,p1)

actionunload(r1,c1,p2)

(no children)

methodroute(r1,d1,d2)

actionmove(r1,d1,d2)

taskput-in-pile(c3,p1)

methodcarry-to-pile(r2,c3,p2,d2,p1,d1)

taskuncover(c3)

methodno-remove(c3)

tasknavigate(r2,d1)

actionload(r2,c3,p2)

actionunload(r2,c3,p1)

(no children)

methodroute(r2,d3,d1)

tasknavigate(r2,d3)

methodroute(r2,d2,d3)

actionmove(r2,d2,d3)

methodput-interleaved(c1,p2,c3,p1)

interleave

taskput-both(c1,p2,c3,p1)

actionmove(r2,d3,d1)

Figure 3.11: Interleaved refinement tree for ⇡5

.

• A method node or program node contains a pair (p, i), where p is amethod or a program, and i is a program counter.

• An interleave node represents a statement of the form{interleave: p

1

, . . . , pk

}. It is an empty node whose children in-clude a program nodes ⌫

1

, . . . , ⌫k

.

The SeRPE algorithm was simple because there was always just one choicefor which node to expand next. For IRPE, the situation is considerablymore complicated, because there will be many di↵erent possible orders inwhich to expand the nodes below each interleave node. IRPE handles this by

Draft, not for distribution. March 1, 2015.

Ruofei Du