76
Planning Chapter 11

Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

Embed Size (px)

Citation preview

Page 1: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

Planning

Chapter 11

Page 2: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

2

Planning

• The Planning problem• Planning with State-space search• Partial-order planning• Planning graphs• Planning with propositional logic• Analysis of planning approaches

Page 3: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

3

What is Planning

• Generate sequences of actions to perform tasks and achieve objectives.– States, actions and goals

• Search for solution over abstract space of plans.• Assists humans in practical applications

– design and manufacturing

– military operations

– games

– space exploration

Page 4: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

4

Difficulty of real world problems

• Assume a problem-solving agentusing some search method …– Which actions are relevant?

• Exhaustive search vs. backward search

– What is a good heuristic functions?• Good estimate of the cost of the state?• Problem-dependent vs, -independent

– How to decompose the problem?• Most real-world problems are nearly decomposable.

Page 5: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

5

An Example

• Tom wants to travel from NTU to NTOU.– Initial state: Tom at NTU– Goal state: Tom at NTOU– Operator difference table:

– Heuristic: solve the major part first

distance train MRT bus taxi walk(km) 3~400 1~40 0.2~60 0~1000 0~1Precond. At(TS1) At(M1) At(BS1) At(Org) At(Org)Effects At(TS2) At(M2) At(BS2) At(Des) At(Des)

Page 6: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

6

An Example

distance train MRT bus taxi walk(km) 3~400 1~40 0.5~60 0~1000 0~1Precond. At(TS1) At(M1) At(BS1) At(Org) At(Org)Effects At(TS2) At(M2) At(BS2) At(Des) At(Des)

NTU NTOU39.5

Page 7: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

7

An Example

distance train MRT bus taxi walk(km) 3~400 1~40 0.5~60 0~1000 0~1Precond. At(TS1) At(M1) At(BS1) At(Org) At(Org)Effects At(TS2) At(M2) At(BS2) At(Des) At(Des)

NTU NTOUTaipei Main Keelung295

train5.5

Page 8: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

8

An Example

distance train MRT bus taxi walk(km) 3~400 1~40 0.5~60 0~1000 0~1Precond. At(TS1) At(M1) At(BS1) At(Org) At(Org)Effects At(TS2) At(M2) At(BS2) At(Des) At(Des)

NTU NTOUTaipei Main Keelung29

4

train

0.5

NTOU Eng.Gungguan

MRT5

bus1

Page 9: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

9

An Example

distance train MRT bus taxi walk(km) 3~400 1~40 0.5~60 0~1000 0~1Precond. At(TS1) At(M1) At(BS1) At(Org) At(Org)Effects At(TS2) At(M2) At(BS2) At(Des) At(Des)

NTU NTOUTaipei Main Keelung29

4

train

0.5

NTOU Eng.Gungguan

MRT5

bus1walkwalk

39.5taxi

Page 10: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

10

Planning language

• What is a good language?– Expressive enough to describe a wide variety of

problems.– Restrictive enough to allow efficient algorithms to

operate on it.– Planning algorithm should be able to take

advantage of the logical structure of the problem.

• STRIPS and ADL

Page 11: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

11

The STRIP approach

(Fikes, Hart, Nilsson, 1972)

• Operators describe actions– Precondition formula: must be true for op to be

applicable– Delete-list: formulas made false by the action– Add-list: formulas made true by the action

Page 12: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

12

The STRIP approach

• An example of an operator– Name: buy-yacht(person, yacht)– Precondition: rich(person) enjoy(person,yacht)– Delete-list: rich(person)– Add-list: has(person,yacht)

buy-yacht(person, yacht)

rich(person)

enjoy(person,yacht)

has(person,yacht)

Page 13: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

13

General language features

• Representation of states– Decompose the world in logical conditions and represent a

state as a conjunction of positive literals. • Propositional literals: Poor Unknown• FO-literals (grounded and function-free): At(Plane1, Melbourne)

At(Plane2, Sydney)

– Closed world assumption

• Representation of goals– Partially specified state and represented as a conjunction of

positive ground literals– A goal is satisfied if the state contains all literals in goal.

Page 14: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

14

General language features

• Representations of actions– Action = PRECOND + EFFECT

Action(Fly(p,from, to),PRECOND: At(p,from) Plane(p) Airport(from) Airport(to)

EFFECT: ¬At(p,from) At(p,to))

= action schema (p, from, to need to be instantiated)• Action name and parameter list• Precondition (conj. of function-free literals)• Effect (conj of function-free literals and P is True and not P is

false)

– Add-list vs delete-list in Effect

Page 15: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

15

Language semantics?

• How do actions affect states?– An action is applicable in any state that satisfies

the precondition.– For FO action schema applicability involves a

substitution for the variables in the PRECOND.At(P1,JFK) At(P2,SFO) Plane(P1) Plane(P2)

Airport(JFK) Airport(SFO)Satisfies: At(p,from) Plane(p) Airport(from)

Airport(to)With ={p/P1,from/JFK,to/SFO}Thus the action is applicable.

Page 16: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

16

Language semantics?

• The result of executing action a in state s is the state s’ – s’ is same as s except

• Any positive literal P in the effect of a is added to s’• Any negative literal ¬P is removed from s’

At(P1,SFO) At(P2,SFO) Plane(P1) Plane(P2) Airport(JFK) Airport(SFO)

– STRIPS assumption: (avoids representational frame problem)

every literal NOT in the effect remains unchanged

Page 17: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

17

Expressiveness and extensions

• STRIPS is simplified – Important limit: function-free literals– Allows for propositional representation

• Function symbols lead to infinitely many states and actions

• Recent extension: Action Description language (ADL)Action( Fly(p: Plane, from: Airport, to: Airport),

PRECOND: At(p,from) (from to)EFFECT: ¬At(p,from) At(p,to) )

Standardization : Planning domain definition language (PDDL)

Page 18: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

18

Example: air cargo transport

Init( At(C1, SFO) At(C2,JFK) At(P1,SFO) At(P2,JFK) Cargo(C1) Cargo(C2) Plane(P1) Plane(P2) Airport(JFK) Airport(SFO) )

Goal( At(C1,JFK) At(C2,SFO) )Action( Load(c,p,a)

PRECOND: At(c,a) At(p,a) Cargo(c) Plane(p) Airport(a)EFFECT: ¬At(c,a) In(c,p) )

Action( Unload(c,p,a)PRECOND: In(c,p) At(p,a) Cargo(c) Plane(p) Airport(a)EFFECT: At(c,a) ¬In(c,p) )

Action( Fly(p,from,to)PRECOND: At(p,from) Plane(p) Airport(from) Airport(to)EFFECT: ¬At(p,from) At(p,to) )

[Load(C1,P1,SFO), Fly(P1,SFO,JFK), Unload(C1,P1,JFK), Load(C2,P2,JFK), Fly(P2,JFK,SFO), Unload(C2,P2,SFO)]

Page 19: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

19

Example: Blocks world

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

Goal( On(A,B) On(B,C) )Action( Move(b,x,y), PRECOND: On(b,x) Clear(b) Clear(y) Block(b)

(bx) (by) (xy) EFFECT: On(b,y) Clear(x) ¬ On(b,x) ¬ Clear(y) )

Action( MoveFromTable(b,x), PRECOND: On(b,Table) Clear(b) Clear(x) Block(b) (bx)

EFFECT: On(b,x) ¬ On(b,Table) ¬ Clear(x) ) Action( MoveToTable(b,x), PRECOND: On(b,x) Clear(b) Block(b) Block(x)

(bx) EFFECT: On(b,Table) Clear(x) ¬ On(b,x) )

A B C

A

B

C

Initial state Goal state

Page 20: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

20

Example: Blocks world

State = On(A, Table) On(B,Table) On(C,Table) Block(A) Block(B) Block(C) Clear(A) Clear(B) Clear(C)

Action( MoveFromTable(B,C)PRECOND: On(B, Table) Clear(B) Clear(C) Block(B) (BC) EFFECT: On(B,C) ¬ On(B, Table) ¬ Clear(C) )

State’ = On(A, Table) On(C,Table) Block(A) Block(B) Block(C) Clear(A) Clear(B) On(B,C)

A B CB

A C

State State’

Page 21: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

21

Example: Blocks world

State’ = On(A, Table) On(C,Table) Block(A) Block(B) Block(C) Clear(A) Clear(B) On(B,C)

Action( MoveFromTable(A,B)PRECOND: On(A, Table) Clear(A) Clear(B) Block(A) (AB) EFFECT: On(A,B) ¬ On(A, Table) ¬ Clear(B) )

State’’ = On(C,Table) Block(A) Block(B) Block(C) Clear(A) On(B,C) On(A,B)

Passed Goal Test: On(A,B) On(B,C)

B

A C

State’A

B

C

State’’

Page 22: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

22

Planning with state-space search

• Both forward and backward search possible• Progression planners

– forward state-space search

– Consider the effect of all possible actions in a given state

• Regression planners – backward state-space search

– To achieve a goal, what must have been true in the previous state.

Page 23: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

23

Progression and regression

At(P1, A)At(P2, A)

At(P1, B)At(P2, A)

At(P1, A)At(P2, B)

Fly(P1,A,B)

Fly(P2,A,B)

At(P1, B)At(P2, B)

At(P1, B)At(P2, A)

At(P1, A)At(P2, B)

Fly(P2,A,B)

Fly(P1,A,B)

(a) progression

(b) regression

Initial state

Goal

Page 24: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

24

Progression algorithm

• Formulation as state-space search problem:– Initial state = initial state of the planning problem

• Literals not appearing are false

– Actions = those whose preconditions are satisfied• Add positive effects, delete negative

– Goal test = does the state satisfy the goal– Step cost = each action costs 1

• No functions … any graph search that is complete is a complete planning algorithm.

• Inefficient: (1) irrelevant action problem (2) good heuristic required for efficient search

Page 25: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

25

Regression algorithm

• How to determine predecessors?– What are the states from which applying a given action

leads to the goal?Goal state = At(C1, B) At(C2, B) … At(C20, B)Relevant action for first conjunct: Unload(C1,p,B)Works only if pre-conditions are satisfied.Previous state= In(C1, p) At(p, B) At(C2, B) … At(C20, B)Subgoal At(C1,B) should not be present in this state.

• Actions must not undo desired literals (consistent)• Main advantage: only relevant actions are considered.

– Often much lower branching factor than forward search.

Page 26: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

26

Regression algorithm

• General process for predecessor construction– Give a goal description G– Let A be an action that is relevant and consistent– The predecessors is as follows:

• Any positive effects of A that appear in G are deleted.• Each precondition literal of A is added , unless it already appears.

• Any standard search algorithm can be added to perform the search.

• Termination when predecessor satisfied by initial state.– In FO case, satisfaction might require a substitution.

Page 27: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

27

Heuristics for state-space search

• Neither progression or regression are very efficient without a good heuristic.– How many actions are needed to achieve the goal?– Exact solution is NP hard, find a good estimate

• Two approaches to find admissible heuristic:– The optimal solution to the relaxed problem.

• Remove all preconditions from actions

– The subgoal independence assumptio:The cost of solving a conjunction of subgoals is approximated by the

sum of the costs of solving the subproblems independently.

Page 28: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

28

Partial-order planning

• Progression and regression planning are totally ordered plan search forms.– They cannot take advantage of problem

decomposition.• Decisions must be made on how to sequence actions on

all the subproblems

• Least commitment strategy:– Delay choice during search

Page 29: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

29

Shoe example

Goal( RightShoeOn LeftShoeOn )Init()Action( RightShoe, PRECOND: RightSockOn

EFFECT: RightShoeOn )Action( RightSock, PRECOND:

EFFECT: RightSockOn )Action( LeftShoe, PRECOND: LeftSockOn

EFFECT: LeftShoeOn )Action( LeftSock, PRECOND:

EFFECT: LeftSockOn )

Planner: combine two action sequences (1) leftsock, leftshoe (2) rightsock, rightshoe

Page 30: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

30

Partial-order planning

• Any planning algorithm that can place two actions into a plan without which comes first is a POL.

Page 31: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

31

Partial-order planning

Right Sock

Start

Left Sock

Right Shoe

Left Shoe

Finish

Right Sock

Start

Left Sock

Left Shoe

Right Shoe

Finish

Left Sock

Start

Right Sock

Right Shoe

Left Shoe

Finish

Left Sock

Start

Right Sock

Left Shoe

Right Shoe

Finish

Right Sock

Start

Right Shoe

Left Sock

Left Shoe

Finish

Left Sock

Start

Left Shoe

Right Sock

Right Shoe

Finish

Left Sock

Start

Left Shoe

Right Sock

Right Shoe

Finish

RightSockOnLefttSockOn

RightShoeOnLefttShoeOn

Partial Order Plan: Total Order Plans:

Page 32: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

32

POL as a search problem

• States are (mostly unfinished) plans.– The empty plan contains only start and finish actions.

• Each plan has 4 components:– A set of actions (steps of the plan)– A set of ordering constraints: A B

• Cycles represent contradictions.

– A set of causal links• The plan may not be extended by adding a new action C that

conflicts with the causal link. (if the effect of C is ¬p and if C could come after A and before B)

– A set of open preconditions.• If precondition is not achieved by action in the plan.

BA p

Page 33: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

33

POL as a search problem

• A plan is consistent iff there are no cycles in the ordering constraints and no conflicts with the causal links.

• A consistent plan with no open preconditions is a solution.

• A partial order plan is executed by repeatedly choosing any of the possible next actions.– This flexibility is a benefit in non-cooperative

environments.

Page 34: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

34

Solving POL

• Assume propositional planning problems:– The initial plan contains Start and Finish, the

ordering constraint Start Finish, no causal links, all the preconditions in Finish are open.

– Successor function :• picks one open precondition p on an action B and

• generates a successor plan for every possible consistent way of choosing action A that achieves p.

– Test goal

Page 35: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

35

Enforcing consistency

• When generating successor plan:– The causal link and the ordering

constraing A B is added to the plan.• If A is new also add start A and A B to the plan

– Resolve conflicts between new causal link and all existing actions

– Resolve conflicts between action A (if new) and all existing causal links.

BA p

Page 36: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

36

Process summary

• Operators on partial plans– Add link from existing plan to open precondition.– Add a step to fulfill an open condition.– Order one step w.r.t 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.

Page 37: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

37

Example: Spare tire problemInit( 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,Groundp) ¬At(Flat,Axle)EFFECT: At(Spare,Axle) ¬At(Spare,Ground) )

Action( LeaveOvernightPRECOND:EFFECT: ¬ At(Spare,Ground) ¬ At(Spare,Axle) ¬ At(Spare,trunk) ¬At(Flat,Ground) ¬ At(Flat,Axle) )

Page 38: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

38

Solving the problem

Start Finish

At(Spare, Axle)At(Spare, Trunk)At(Flat, Axle)

• Intial plan: Start with EFFECTS and Finish with PRECOND.

Page 39: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

39

Solving the problem

Start FinishPutOn(Spare, Axle)

At(Spare, Axle)At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• Pick an open precondition: At(Spare, Axle)• Only PutOn(Spare, Axle) is applicable• Add causal link:

• Add constraint : PutOn(Spare, Axle) Finish

FinishAxleSparePutOn AxleSpareAt ),(),(

Page 40: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

40

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• Pick an open precondition: At(Spare, Ground)• Only Remove(Spare, Trunk) is applicable• Add causal link:

• Add constraint : Remove(Spare, Trunk) PutOn(Spare,Axle)

),(),( ),( AxleSparePutOnTrunkSpareRemove GroundSpareAt

Page 41: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

41

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

LeaveOvernight

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• Pick an open precondition: At(Flat, Axle)

• LeaveOverNight is applicable

• Conflict with:),(),( ),( AxleSparePutOnTrunkSpareRemove GroundSpareAt

At(Flat, Axle)At(Flat, Ground)At(Spare, Axle)At(Spare, Ground)At(Spare, Trunk)

Page 42: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

42

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

LeaveOvernight

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• To resolve, add constraint:LeaveOverNight Remove(Spare, Trunk)

• Add causal link:

At(Flat, Axle)At(Flat, Ground)At(Spare, Axle)At(Spare, Ground)At(Spare, Trunk)

),(),( AxleSparePutOnightLeaveOvern GroundSpareAt

Page 43: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

43

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

LeaveOvernight

At(Flat, Axle)At(Flat, Ground)At(Spare, Axle)At(Spare, Ground)At(Spare, Trunk)

• Pick an open precondition: At(Spare, Trunk)

• Only Start is applicable

• Add causal link: ),(),( TrunkSpareRemoveStart TrunkSpareAt

Page 44: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

44

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

LeaveOvernight

At(Flat, Axle)At(Flat, Ground)At(Spare, Axle)At(Spare, Ground)At(Spare, Trunk)

• Conflict: of causal link with effect At(Spare,Trunk) in LeaveOverNight

– No re-ordering solution possible.

• backtrack

Page 45: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

45

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• Remove LeaveOvernight and causal link

),(),( AxleSparePutOnightLeaveOvern GroundSpareAt

Page 46: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

46

Solving the problem

Start Finish

Remove(Spare, Trunk)

PutOn(Spare, Axle)

Remove(Flat, Axle)

At(Spare, Axle)At(Spare, Trunk)

At(Spare, Trunk)At(Flat, Axle)

At(Flat, Axle)

At(Spare, Ground) At(Flat, Axle)

• Consider again the open precondition: At(Flat, Axle)

• Remove(Flat, Axle) is applicable

• Choose Start to achieve At(Spare, Trunk) and At(Flat, Axle)

• Finish!

Page 47: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

47

Some details …

• What happens when a first-order representation that includes variables is used?– Complicates the process of detecting and resolving

conflicts.– Conflicts can be resolved by introducing inequality

constraint.

• CSP’s most-constrained-variable constraint can be used for planning algorithms to select a PRECOND.

Page 48: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

48

Planning graphs

• Used to achieve better heuristic estimates.– A solution can also directly extracted using GRAPHPLAN.

• Consists of a sequence of levels that correspond to time steps in the plan.– Level 0 is the initial state.

– Each level consists of a set of literals and a set of actions.• Literals = all those that could be true at that time step, depending

upon the actions executed at the preceding time step.

• Actions = all those actions that could have their preconditions satisfied at that time step, depending on which of the literals actually hold.

Page 49: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

49

Planning graphs

• “Could”?– Records only a restricted subset of possible negative

interactions among actions.

• They work only for propositional problems.• Example:

Init(Have(Cake))Goal(Have(Cake) Eaten(Cake))Action(Eat(Cake), PRECOND: Have(Cake)

EFFECT: ¬Have(Cake) Eaten(Cake))Action(Bake(Cake), PRECOND: ¬ Have(Cake)

EFFECT: Have(Cake))

Page 50: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

50

Cake example

• Start at level S0 and determine action level A0 and next level S1.

• A0: all actions whose preconditions are satisfied in the previous level.

• Connect precond in S0 and effect in S1 of actions

S0

Have(Cake)

Eaten(Cake)Eaten(Cake)

Eat(Cake)

Have(Cake)

A0 S1 A1 S2

Page 51: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

51

Cake example

• Inaction is represented by persistence actions.– Inaction means conditions remains unchanged.– Use a little square to denote persistence actions.

• Now level A0 contains the actions that could occur.

S0

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Eat(Cake)

Have(Cake)

Eaten(Cake)

A0 S1 A1 S2

Page 52: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

52

Cake example

• Conflicts between actions are represented by mutual exclusion, or mutex links.

• A mutex relation holds between two actions when:– Inconsistent effects: one action negates the effect of another.– Interference: one of the effects of one action is the negation of a

precondition of the other.– Competing needs: (will see later)

S0

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Eat(Cake)

Have(Cake)

Eaten(Cake)

A0 S1 A1 S2

Page 53: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

53

Cake example

• Level S1 contains all literals that could result from picking any subset of actions in A0

– Conflicts between literals that can not occur together are represented by mutex links.

• A mutex relation holds between two literals when:– If one is the negation of the other, or – Inconsistent support: if every possible action pair that could achieve the

literals is mutex.

S0

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Eat(Cake)

Have(Cake)

Eaten(Cake)

A0 S1 A1 S2

Page 54: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

54

Cake example

• The third case of mutex relation between two actions:– Competing needs: one of the preconditions of one action is mutually

exclusive with a precondition of the other.

• Continue until two consecutive levels are identical: (called leveled off)– Or contain the same amount of literals (explanation follows later)

S0

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Eat(Cake)

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Have(Cake)

Eaten(Cake)

Eat(Cake)

Bake(Cake)

A0 S1 A1 S2

Page 55: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

55

PG and heuristic estimation

• PG’s provide information about the problem– A literal that does not appear in the final level of the graph

cannot be achieved by any plan.• Useful for backward search (cost = ).

– Level of appearance can be used as cost estimate of achieving any goal literals = level cost.

– Small problem: several actions can occur• Restrict to one action using serial PG (add mutex links between

every pair of actions, except persistence actions).

– Max-level, level sum, and set-level heuristics.

PG is a relaxed problem.

Page 56: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

56

The GRAPHPLAN Algorithm

• How to extract a solution directly from the PG

function GRAPHPLAN(problem) return solution or failure

graph INITIAL-PLANNING-GRAPH(problem)

goals GOALS[problem]

loop do

if goals all non-mutex in last level of graph then do

solution EXTRACT-SOLUTION(graph, goals, LENGTH(graph))

if solution failure then return solution

else if NO-SOLUTION-POSSIBLE(graph) then return failure

graph EXPAND-GRAPH(graph, problem)

Page 57: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

57

GRAPHPLAN example

graph INITIAL-PLANNING-GRAPH(problem)

• Initially the plan consist of 5 literals from the initial state and the CWA literals (S0).

S0At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Page 58: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

58

GRAPHPLAN example• Goal At(Spare, Axle) cannot be achieved, so• Add actions whose preconditions are satisfied by EXPAND-GRAPH (A0)

S0

Remove(Spare, Trunk)

A0

At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

Page 59: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

59

GRAPHPLAN example

graph EXPAND-GRAPH (A0)• Also add persistence actions and mutex relations (not shown here).

S0

Remove(Spare, Trunk)

A0

At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

Page 60: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

60

GRAPHPLAN example

graph EXPAND-GRAPH (A0)• Add the effects at level S1.

S0At(Spare, Trunk)

Remove(Spare, Trunk)

A0 S1

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

Page 61: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

61

GRAPHPLAN example

• EXPAND-GRAPH also looks for mutex relations– Inconsistent effects

• E.g. Remove(Spare, Trunk) and LeaveOverNight

– Interference • E.g. Remove(Flat, Axle) and LeaveOverNight

– Competing needs• E.g. PutOn(Spare,Axle) and Remove(Flat, Axle)

– Inconsistent support• E.g. in S2, At(Spare,Axle) and At(Flat,Axle)

Page 62: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

62

GRAPHPLAN example

• Loop until goal At(Spare, Axle) can be achieved.

S1At(Spare, Trunk)

Remove(Spare, Trunk)

A1 S2

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

At(Spare, Trunk)

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)

At(Spare, Ground)

PutOn(Spare, Axle) At(Spare, Axle)

Page 63: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

63

GRAPHPLAN example

• In S2, the goal literal exists and is not mutex with any other– Solution might exist and EXTRACT-SOLUTION will try to find it

S1At(Spare, Trunk)

Remove(Spare, Trunk)

A1 S2

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

At(Spare, Trunk)

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)

At(Spare, Ground)

PutOn(Spare, Axle) At(Spare, Axle)

Page 64: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

64

GRAPHPLAN example

• EXTRACT-SOLUTION can use Boolean CSP to solve the problem or a search process:– Initial state = last level of PG and goals of planning

problem

– Actions = select any set of non-conflicting actions that cover the goals in the state

• Non-conflict means no mutex among them.

• The union of preconditions will become the goal of next state.

– Goal = reach level S0 such that all goals are satisfied

– Cost = 1 for each action.

Page 65: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

65

EXTRACT-SOLUTION

• The only action achieving the goal is PutOn.

S1At(Spare, Trunk)

Remove(Spare, Trunk)

A1 S2

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

At(Spare, Trunk)

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)

At(Spare, Ground)

PutOn(Spare, Axle) At(Spare, Axle)

Page 66: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

66

EXTRACT-SOLUTION

• Two choices to achieve At(Flat, Axle) and At(Spare, Ground) 1. Remove(Spare, Trunk) and LeaveOvernight, but they are mutex.

S0At(Spare, Trunk)

Remove(Spare, Trunk)

A0 S1

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

Page 67: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

67

EXTRACT-SOLUTION

• Two choices to achieve At(Flat, Axle) and At(Spare, Ground) 2. Remove(Spare, Trunk) and Remove(Flat, Axle), got it!

S0At(Spare, Trunk)

Remove(Spare, Trunk)

A0 S1

At(Spare, Trunk)

At(Flat, Axle)At(Flat, Axle)

At(Spare, Axle)

At(Spare, Ground)

At(Flat, Ground)At(Flat, Ground)At(Spare, Ground)

At(Spare, Trunk)

At(Flat, Axle)

At(Spare, Axle)

At(Flat, Ground)

At(Spare, Ground)

Remove(Flat, Axle)

LeaveOvernight

Page 68: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

68

Planning Graph

• Will EXPAND-GRAPH eventually terminate? YES

• PG are monotonically increasing or decreasing:– Literals increase monotonically

– Actions increase monotonically

– Mutexes decrease monotonically

• Because of these properties and because there is a finite number of actions and literals, every PG will eventually level off !

Page 69: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

69

Planning with propositional logic

• Planning can be done by proving theorem in situation calculus.

• Here: test the satisfiability of a logical sentence:

• Sentence contains propositions for every action occurrence.– A model will assign true to the actions that are part of the correct plan

and false to the others– An assignment that corresponds to an incorrect plan will not be a

model because of inconsistency with the assertion that the goal is true.– If the planning is unsolvable the sentence will be unsatisfiable.

initial state all possible action descriptions goal

Page 70: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

70

SATPLAN algorithm

function SATPLAN(problem, Tmax) return solution or failureinputs:problem, a planning problem

Tmax, an upper limit to the plan length

for T= 0 to Tmax docnf, mapping TRANSLATE-TO_SAT(problem, T)assignment SAT-SOLVER(cnf)if assignment is not null then

return EXTRACT-SOLUTION(assignment, mapping)

return failure

Page 71: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

71

cnf, mapping TRANSLATE-TO_SAT(problem, T)

• Distinct propositions for assertions about each time step.– Superscripts denote the time step

At(P1, SFO)0 At(P2, JFK)0

– No CWA thus specify which propositions are not true¬At(P1, JFK)0 ¬At(P2, SFO)0

– Unknown propositions are left unspecified.

• The goal is associated with a particular time-step– But which one?

Page 72: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

72

• How to determine the time step where the goal will be reached?– Start at T=0

• Assert At(P1, SFO)0 At(P2, JFK)0

– Failure .. Try T=1• Assert At(P1, SFO)1 At(P2, JFK)1

– …

– Repeat this until some minimal path length is reached.

– Termination is ensured by Tmax

cnf, mapping TRANSLATE-TO_SAT(problem, T)

Page 73: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

73

• How to encode actions into PL?– Propositional versions of successor-state axioms

At(P1,JFK)1 (At(P1,JFK)0 ¬(Fly(P1,JFK,SFO)0 At(P1,JFK)0)) (Fly(P1,SFO,JFK)0 At(P1,SFO)0)

– Such an axiom is required for each plane, airport and time step

– If more airports add another way to travel then additional disjuncts are required

• Once all these axioms are in place, the satisfiability algorithm can start to find a plan.

cnf, mapping TRANSLATE-TO_SAT(problem, T)

Page 74: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

74

assignment SAT-SOLVER(cnf)

• Multiple models can be found– They are NOT satisfactory: (for T=1)

Fly(P1,SFO,JFK)0 Fly(P1,JFK,SFO)0 Fly(P2,JFK,SFO)0

• The second action is infeasible

• Yet the plan IS a model of the sentence

• Avoiding illegal actions: pre-condition axioms

Fly(P1,SFO,JFK)0 At(P1,JFK)

• Exactly one model now satisfies all the axioms where the goal is achieved at T=1.

Page 75: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

75

assignment SAT-SOLVER(cnf)

• A plane can fly at two destinations at once– They are NOT satisfactory: (for T=1)

Fly(P1,SFO,JFK)0 Fly(P2,JFK,SFO)0 Fly(P2,JFK,LAX)0

• The second action is infeasible

• Yet the plan allows spurious relations

• Avoid spurious solutions: action-exclusion axioms¬(Fly(P2,JFK,SFO)0 Fly(P2,JFK,LAX))

• Prevents simultaneous actions

• Add expansion of FOL sentences such as:

p,x,y,t xy ¬(At(p,x)t At(p,y)t )

Page 76: Planning Chapter 11. 2 Planning The Planning problem Planning with State-space search Partial-order planning Planning graphs Planning with propositional

76

Analysis of planning approach

• Planning is an area of great interest within AI– Search for solution– Constructively prove a existence of solution

• Biggest problem is the combinatorial explosion in states.

• Efficient methods are under research– E.g. divide-and-conquer