Classical Planning Partial-Order Planning Sections 10.1,10.4.4 - - PowerPoint PPT Presentation

classical planning partial order planning
SMART_READER_LITE
LIVE PREVIEW

Classical Planning Partial-Order Planning Sections 10.1,10.4.4 - - PowerPoint PPT Presentation

Classical Planning Partial-Order Planning Sections 10.1,10.4.4 Nilufer Onder Department of Computer Science Michigan Technological University Ch. 10a p.1/47 Outline Search vs. planning PDDL operators Partial-order planning


slide-1
SLIDE 1

Classical Planning Partial-Order Planning

Sections 10.1,10.4.4 —– Nilufer Onder Department of Computer Science Michigan Technological University

  • Ch. 10a – p.1/47–
slide-2
SLIDE 2

Outline

Search vs. planning PDDL operators Partial-order planning

  • Ch. 10a – p.2/47–
slide-3
SLIDE 3

What is AI planning?

Planning is the task of finding a set of actions that will achieve a goal. A planner is a program that searches for a plan. It inputs a description of the world and the goals. The output is a plan. The simplest plan is a sequence of actions: ‘‘do action1, do action2 ...’’ More complex plans may include branching actions: “if (condition) do action1 else do action2”

  • Ch. 10a – p.3/47–
slide-4
SLIDE 4

Planning Domain Definition Language (PDDL)

Tidily arranged actions descriptions, restricted language

BUY (s,x) At(s) ~Bought(x) Sells(s,x) Bought(x)

ACTION: Buy(s, x) PRECONDITION: At(s), ¬Bought(x), Sells(s, x) EFFECT: Bought(x)

  • Ch. 10a – p.4/47–
slide-5
SLIDE 5

PDDL operators (cont’d)

ACTION: Buy(s, x) PRECONDITION: At(s), ¬Bought(x), Sells(s, x) EFFECT: Bought(x) Restricted language =

⇒ efficient algorithm

(but many important details will have to be abstracted away) Action schema: name, parameters, preconditions, effects Precondition: conjunction of positive literals Effect: conjunction of literals STRIPS is the earliest planning representation

  • Ch. 10a – p.5/47–
slide-6
SLIDE 6

Search vs. planning (cont’d)

Search Planning States Data structure Logical sentences Actions Program Preconditions/outcomes Goal Program Logical sentence (conjunction) Plan Path from S0 (Sequence of) actions

  • Ch. 10a – p.6/47–
slide-7
SLIDE 7

Search vs. planning (cont’d)

Planning systems do the following:

  • 1. open up action and goal representation to allow

selection

  • 2. divide-and-conquer by subgoaling
  • 3. relax requirement for sequential construction of

solutions

  • Ch. 10a – p.7/47–
slide-8
SLIDE 8

States

The state of the world is represented by a collection

  • f variables

(factored representation ) Each state is represented as a conjunction of fluents that are ground, functionless atoms. A state is a set (set semantics) Use database semantics, closed world assumption: If a fluent is not mentioned, assume it is false. Fluents that are non-ground, negated, or using functions are not allowed.

  • Ch. 10a – p.8/47–
slide-9
SLIDE 9

Partially ordered plans

Partially ordered collection of steps with START step has the initial state description as its effect FINISH step has the goal description as its precondition causal links from outcome of one step to precondition of another temporal ordering between pairs of steps

  • Ch. 10a – p.9/47–
slide-10
SLIDE 10

Partially ordered plans (cont’d)

A partially ordered plan is a 5-tuple (A, O, C, OC, UL) A is the set of actions that make up the plan. They are partially ordered. O is a set of ordering constraints of the form A ≺ B. It means A comes before B. C is the set of causal links in the form (A, p, B) where A is the supplier action, where B is the consumer action, and p is the condition supplied. It is read as “A achieves p for B.”

  • Ch. 10a – p.10/47–
slide-11
SLIDE 11

Partially ordered plans (cont’d)

A partially ordered plan is a 5-tuple (A, O, C, OC, UL) OC is a set of open conditions, i.e., conditions that are not yet supported by causal links. It is of the form p for A where p is a condition and A is an action. UL is a set of unsafe links, i.e., causal links whose conditions might be undone by other actions.

  • Ch. 10a – p.11/47–
slide-12
SLIDE 12

Partially ordered plans (cont’d)

A plan is complete iff every precondition is achieved, and there are no unsafe links. A precondition is achieved iff it is the effect of an earlier step and no possibly intervening step undoes it In other words, a plan is complete when OC ∪ UL = ∅.

OC ∪ UL is referred to as the flaws in a plan.

When a causal link is established, the corresponding condition is said to be closed.

  • Ch. 10a – p.12/47–
slide-13
SLIDE 13

Example

START FINISH LeftShoeOn RightShoeOn CleanLeftSock CleanRightSock OC= LeftShoeOn for FINISH RightShoeOn for FINISH

  • Ch. 10a – p.13/47–
slide-14
SLIDE 14

Example (cont’d)

START LEFT SHOE FINISH LeftShoeOn CleanLeftSock CleanRightSock LeftSockOn OC= RightShoeOn for FINISH LeftSockOn for LEFTSHOE RightShoeOn

  • Ch. 10a – p.14/47–
slide-15
SLIDE 15

Example (cont’d)

START LEFT SOCK LEFT SHOE FINISH LeftShoeOn CleanLeftSock CleanRightSock LeftSockOn RightShoeOn OC = CleanLeftSock for LEFTSOCK RightShoeOn for FINISH

  • Ch. 10a – p.15/47–
slide-16
SLIDE 16

Example (cont’d)

START LEFT SOCK LEFT SHOE FINISH LeftShoeOn RightShoeOn CleanLeftSock CleanRightSock LeftSockOn OC = RightShoeOn for FINISH

  • Ch. 10a – p.16/47–
slide-17
SLIDE 17

Example (cont’d)

START LEFT SOCK LEFT SHOE RIGHT SHOE FINISH LeftShoeOn RightShoeOn CleanLeftSock CleanRightSock LeftSockOn RightSockOn OC = RightSockOn for RIGHTSHOE

  • Ch. 10a – p.17/47–
slide-18
SLIDE 18

Example (cont’d)

START LEFT SOCK RIGHT SOCK LEFT SHOE RIGHT SHOE FINISH LeftShoeOn RightShoeOn CleanLeftSock CleanRightSock LeftSockOn RightSockOn OC = CleanRightSock for RIGHTSOCK

  • Ch. 10a – p.18/47–
slide-19
SLIDE 19

Example (cont’d)

START LEFT SOCK RIGHT SOCK LEFT SHOE RIGHT SHOE FINISH LeftShoeOn RightShoeOn CleanLeftSock CleanRightSock LeftSockOn RightSockOn OC= { }

  • Ch. 10a – p.19/47–
slide-20
SLIDE 20

Planning process

Operators on partial plans: **** close open conditions: **** **** add a link from an existing action to an **** **** **** open condition **** **** add a step to fulfill an open condition **** resolve threats: **** **** order one step wrt another to remove **** **** **** possible conflicts Gradually move from incomplete/vague plans to complete, correct plans Backtrack if an open condition is unachievable or if a conflict is unresolvable

  • Ch. 10a – p.20/47–
slide-21
SLIDE 21

POP is a search in the plan space

function TREE-SEARCH (problem) returns a solution, or failure initialize the frontier using the initial state of problem loop do if the frontier is empty then return failure choose a leaf node and remove it from the frontier if the node contains a goal state then return the corresponding solution else expand the chosen node and add the resulting nodes to the frontier end

  • Ch. 10a – p.21/47–
slide-22
SLIDE 22

POP algorithm specifics

The initial state, goal state and the operators are given. The planner converts them to required structures. Initial state: MAKE-MINIMAL-PLAN (initial,goal) Goal-Test: SOLUTION?(plan) SOLUTION? returns true iff OC and UL are both empty. Successor function: The successors function could either close an open condition or resolve a threat.

  • Ch. 10a – p.22/47–
slide-23
SLIDE 23

POP algorithm specifics (cont’d)

function SUCCESSORS (plan) returns a set of partially ordered plans flaw-type ← SELECT-FLAW-TYPE (plan) if flaw-type is an open condition then Sneed, c ← SELECT-SUBGOAL (plan) return CLOSE-CONDITION (plan, operators, Sneed,c) if flaw-type is a threat then Sthreat, Si, c, Sj ← SELECT-THREAT(plan) return RESOLVE-THREAT (plan, Sthreat, Si, c, Sj)

  • Ch. 10a – p.23/47–
slide-24
SLIDE 24

POP algorithm specifics (cont’d)

function CLOSE-CONDITION (plan, operators, Sneed,c) returns a set of partially ordered plans plans ← ∅ for each Sadd from operators or STEPS(plan) that has c has an effect do new-plan ← plan if Sadd is a newly added step from operators then add Sadd to STEPS (new-plan) add START ≺ Sadd ≺ FINISH to ORDERINGS (new-plan) add the causal link (Sadd, c, Sneed) to LINKS (new-plan) add the ordering constraint (Sadd ≺ Sneed) to ORDERINGS (new-plan) add new-plan to plans end return new-plans

  • Ch. 10a – p.24/47–
slide-25
SLIDE 25

POP algorithm specifics (cont’d)

function RESOLVE-THREAT (plan, Sthreat, Si, c, Sj) returns a set of partially ordered plans plans ← ∅ //Demotion: new-plan ← plan add the ordering constraint (Sthreat ≺ Si) to ORDERINGS (new-plan) if new-plan is consistent then add new-plan to plans //Promotion: new-plan ← plan add the ordering constraint (Sj ≺ Sthreat) to ORDERINGS (new-plan) if new-plan is consistent then add new-plan to plans return new-plans

  • Ch. 10a – p.25/47–
slide-26
SLIDE 26

Shopping example

BUY (?s, ?i) effects: bought(?i) ~bought(~i) The operators are: GO (?x, ?y) preconditions: at(?x) preconditions: at(?s), effects: ~at(?x), at(?y) The subgoals that are currently open are italicized. for at(H) for f at(H) at(H) INIT bought(B) bought(A) ~bought(A) ~bought(B) ~bought(A) ~bought(B) bought(A) bought(B) f f at(H) add a go(J,H) action START for at(H) for f add a causal link from START FINISH Agenda:

  • pen subgoals:

bought(A) for f bought(B) for f at(H) for f INIT GO(J,H) at(J) ~at(J) at(H) ~bought(A) ~bought(B) at(H) bought(B) bought(A) 1 FINISH FINISH f new Agenda:

  • pen subgoals:

bought(A) for f bought(B) for f at(J) for 1

  • Ch. 10a – p.26/47–
slide-27
SLIDE 27

Shopping example (cont’d)

New agenda:

  • pen subgoals:

at(H) for 2 add a go(J, H) action supply at(H) for 2 from START ~at(H) GO(J,H) ~at(J) 1 GO(H,J)2 ~bought(A) ~bought(B) ~at(H) GO(J,H) ~at(J) GO(H,J)2 ~bought(A) ~bought(B) at(H) bought(A) bought(B) at(H) bought(A) for f bought(B) for f bought(A) bought(B) add a go(H,J) action (2) 1 . . . at(J) at(H) at(H) at(J) at(H) START FINISH f START 0 FINISH f

  • Ch. 10a – p.27/47–
slide-28
SLIDE 28

Shopping example (cont’d)

at(J) bought(B) ~at(H) GO(J,H) ~at(J) BUY(J,A) 1 GO(H,J)2 3 new agenda:

  • pen subgoals:

bought(B) for f ~bought(A) for 3 ~bought(A) support ~bought(A) from START at(J) for 3 at(H) at(J) at(H) bought(A) ~bought(A) ~bought(B) at(J) bought(B) ~at(H) GO(J,H) ~at(J) BUY(J,A) 1 GO(H,J)2 3 new agenda:

  • pen subgoals:

bought(B) for f at(J) for 3 bought(A) ~bought(A) at(H) at(J) at(H) Support at(J) from GO(H,J)−2 add BUY(J,A) (3) START 0 FINISH START 0 FINISH f f

  • Ch. 10a – p.28/47–
slide-29
SLIDE 29

Shopping example (cont’d)

support ~bought(B) for 4 from START new agenda:

  • pen subgoals:

at(J) for 4 new agenda:

  • pen subgoals:

none bought(B) ~at(H) GO(J,H) ~at(J) BUY(J,A) 1 GO(H,J)2 3 ~bought(A) bought(A) at(H) at(J) at(J) at(H) support at(J) from GO(H,J)−2 add BUY(J,B) (4) new agenda: bought(B) for f ~bought(A) for 3

  • pen subgoals:

new agenda:

  • pen subgoals:

~bought(B) for 4 ~at(H) GO(J,H) BUY(J,A) BUY(J,B) 1 GO(H,J)2 3 4 bought(B) bought(A) at(H) ~at(J) at(H) ~bought(A) ~bought(B) at(J) at(J) at(J) at(J) for 4 support ~at(J) for 4 from GO(H,J)−2 HAVEN’T CONSIDERED THE THREATS YET! FINISH START 0 f START 0 FINISH f

  • Ch. 10a – p.29/47–
slide-30
SLIDE 30

Shopping example (cont’d)

2 3 4 1 2 3 1 4 2 4 3 1 2 4 1 3 2 1 3 4 2 1 4 3 Now, the solution is a possible ordering of this plan. Those are: ~at(H) GO(J,H) BUY(J,A) BUY(J,B) 1 GO(H,J)2 3 4 bought(B) bought(A) at(H) ~at(J) at(H) ~bought(A) ~bought(B) at(J) at(J) at(J) FINISH START 0 f It should not be possible to order GO(J,H) before any of the BUY actions.

  • Ch. 10a – p.30/47–
slide-31
SLIDE 31

Shopping example (cont’d)

~at(H) GO(J,H) BUY(J,A) BUY(J,B) 1 GO(H,J)2 3 4 bought(B) bought(A) at(H) ~at(J) at(H) ~bought(A) ~bought(B) at(J) at(J) at(J) START 0 FINISH f This is a correct partially ordered plan. It is complete. The possible total orders are: 2 3 4 1 2 4 3 1 The agent has to go to Jim’s first. It order of getting the items does not matter. Then it has to go back home.

  • Ch. 10a – p.31/47–
slide-32
SLIDE 32

Threats and promotion/demotion

A threatening step is a potentially intervening step that destroys the condition achieved by a causal link. E.g., GO(J,H) threatens At(J)

GO(H,J) At(J) BUY(Apples) GO(J,H) At(H) ~At(J) Demotion: put before GO(H,J) Promotion: put BUY(Apples)

  • Ch. 10a – p.32/47–
slide-33
SLIDE 33

Properties of POP

Nondeterministic algorithm: backtracks at choice points on failure: choice of Sadd to achieve Sneed choice of demotion or promotion for threat resolution selection of Sneed is irrevocable POP is sound, complete, and systematic (no repetition) Extensions for disjunction, universals, negation, conditionals Particularly good for problems with many loosely related subgoals

  • Ch. 10a – p.33/47–
slide-34
SLIDE 34

Additional POP examples

The flat tire example shows the effect of inserting an “impossible” action. The Sussman anomaly shows that “divide-and-conquer” is not always optimal. POP can find the optimal plan.

  • Ch. 10a – p.34/47–
slide-35
SLIDE 35

The flat tire domain

Init(At(Flat,Axle) ∧ At(Spare,Trunk)) Goal(At(Spare,Axle)) Action(REMOVE(spare,trunk), ***Precond: At(spare,trunk) ***Effect: ¬At(spare,trunk) ∧ At(spare,ground) Action(REMOVE(flat,axle), ***Precond: At(flat,axle) ***Effect: ¬At(flat,axle) ∧ At(flat,ground) Action(PUTON(spare,axle), ***Precond: At(spare,ground) ∧ ¬ at(flat,axle) ***Effect: ¬At(spare,ground) ∧ At(spare,axle) Action(LEAVEOVERNIGHT ***Precond: ***Effect: ¬At(spare,ground) ∧ ¬ At(spare,axle) ***Effect: ¬At(spare,trunk) ∧ ¬ At(flat,ground) ***Effect: ¬At(flat,axle)

  • Ch. 10a – p.35/47–
slide-36
SLIDE 36

The flat tire plan

START REMOVE(spare,trunk) at(spare,ground) ~at(flat,axle) at(spare,axle) at(flat,axle) at(spare,trunk) at(spare,trunk) FINISH PUTON(spare,axle)

  • Ch. 10a – p.36/47–
slide-37
SLIDE 37

The flat tire plan (cont’d)

START REMOVE(spare,trunk) LEAVEOVERNIGHT ~at(flat,axle) ~at(flat,ground) ~at(spare,axle) ~at(spare,ground) ~at(spare,trunk) at(spare,ground) ~at(flat,axle) at(spare,axle) at(flat,axle) at(spare,trunk) at(spare,trunk) FINISH PUTON(spare,axle)

  • Ch. 10a – p.37/47–
slide-38
SLIDE 38

The flat tire plan (cont’d)

START REMOVE(spare,trunk) at(spare,ground) ~at(flat,axle) at(spare,axle) at(flat,axle) at(spare,trunk) REMOVE(flat,axle) at(flat,axle) at(spare,trunk) FINISH PUTON(spare,axle)

  • Ch. 10a – p.38/47–
slide-39
SLIDE 39

Sussman anomaly

B A C C B A

PUTONTABLE(x) Clear(x) On(x,z) ~On(x,z) Clear(z) On(x,Table) PUTON(x,y) Clear(x) On(x,z) Clear(y) ~On(x,z) ~Clear(y) Clear(z) On(x,y) + several inequality constraints

  • Ch. 10a – p.39/47–
slide-40
SLIDE 40

Sussman anomaly (cont’d)

FINISH START

B A C

On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C)

C B A

  • Ch. 10a – p.40/47–
slide-41
SLIDE 41

Sussman anomaly (cont’d)

FINISH START

B A C C C A

On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C)

C B A

If we try the first goal ( on(A,B) ) first, we can’t proceed without undoing work

B A B

  • Ch. 10a – p.41/47–
slide-42
SLIDE 42

Sussman anomaly (cont’d)

FINISH START

B A C B

On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C)

C B A

If we try the second goal ( on (B,C) ) first, we can’t proceed without undoing work.

A C

  • Ch. 10a – p.42/47–
slide-43
SLIDE 43

Sussman anomaly (cont’d)

FINISH START

B A C

On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C) Clear(B) On(B,z) Clear(C) PUTON(B,C)

C B A

  • Ch. 10a – p.43/47–
slide-44
SLIDE 44

Sussman anomaly (cont’d)

FINISH START

B A C

On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C) Clear(A) On(A,z) Clear(B) Clear(B) On(B,z) Clear(C) PUTON(A,B) PUTON(B,C)

C B A

PUTON(A,B) threatens Clear(B) Order after PUTON(B,C)

  • Ch. 10a – p.44/47–
slide-45
SLIDE 45

Sussman anomaly (cont’d)

FINISH START

B A C

PUTON(B,C) threatens Clear(C)

  • rder after

PUTON(A,B) On(A,B) On(B,C) On(C,A) On(A,Table) Clear(B) On(B,Table) Clear(C) Clear(A) On(A,z) Clear(B) On(C,z) Clear(C) Clear(B) On(B,z) Clear(C) PUTONTABLE(C) PUTON(A,B) PUTON(B,C)

C B A

  • Ch. 10a – p.45/47–
slide-46
SLIDE 46

Heuristics for POP

POP be made efficient with good heuristics derived from problem description Which plan to select? Which flaw to choose? (We will see more after planning graphs)

  • Ch. 10a – p.46/47–
slide-47
SLIDE 47

Sources for the slides

AIMA textbook (3rd edition) AIMA slides (http://aima.cs.berkeley.edu/) Writing Planning Domains and Problems in PDDL, by Patrik Haslum

(http://users.cecs.anu.edu.au/ patrik/pddlman/writing.html)

Weld, D.S. (1999). Recent advances in AI planning. AI Magazine, 20(2), 93-122.

  • Ch. 10a – p.47/47–