Sei sulla pagina 1di 31

Planning

Overview
The blocks world

B C B
A C D A D

start goal

How to achieve the goal from the start?

2
Overview

• Problem-solving is searching and moving through a


state space.

3
Overview

• Problem-solving is searching and moving through a


state space.

• Planning is searching for sucessful paths through a


state space.

4
Overview

• Planning is the process of computing several steps of


a problem-solving procedure before executing them.

• Planning = problem sloving in advance.

5
Overview

• Planning is important if solutions cannot be undone.


• If the universe is not predictable, then a plan can fail
⇒ dynamic plan revision.

6
The Blocks World

B C B
A C D A D

start goal

Planning = generating a sequence of actions to


achieve the goal from the start

7
The Blocks World
Actions:

• UNSTACK(A, B)-Pick up block A from its current position


on block B. The arm must be empty and block A must
have no blocks on top of it.

• STACK(A, B)- Place block A on block B. The arm must


already be holding and the surface of B must be clear.

• PICKUP(A)- Pick up block A from the table and hold it.


The arm must be empty and there must be nothing on
top of block A.

• PUTDOWN(A)- Put block A down on the table. The arm


must have been holding block A.

8
The Blocks World

Conditions and results:

• ON(A, B)-Block A is on block B


• ONTABLE(A)- Block A is on Table
• CLEAR(A)- There is nothing on top of block A
• HOLDING(A)- The arm is holding block A
• ARMEMPTY- The arm is holding nothing.
9
The Blocks World

Specification of actions:

• PRECONDITION: list of predicates that must be true


for an operator to be applied.

• ADD: list of new predicates that an operator causes


to become true.

• DELETE: list of old predicates that an operator


causes to become false.
• Predicates not in ADD nor DELETE are unaffacted.
10
The Blocks World

Specification of actions:
STACK(x, y):
P: CLEAR(y)  HOLDING(x)
D: CLEAR(y)  HOLDING(x)
A: ARMEMPTY  ON(x, y)

UNSTACK(x, y):
P: ON(x, y)  CLEAR(x)  ARMEMPTY
D: ON(x, y)  ARMEMPTY

A: HOLDING(x)  CLEAR(y)
11
The Blocks World

Specification of actions:
PICKUP(x):
P: CLEAR(x)  ONTABLE(x)  ARMEMPTY
D: ONTABLE(x)  ARMEMPTY
A: HOLDING(x)
PUTDOWN(x):
P: HOLDING(x)
D: HOLDING(x)

A: ONTABLE(x)  ARMEMPTY
12
The Blocks World

B C B
A C D A D

start: ON(B, A)  goal: ON(C, A) 


ONTABLE(A)  ON(B, D) 
ONTABLE(C)  ONTABLE(A) 
ONTABLE(D)  ONTABLE(D) 
ARMEMPTY

13
Goal Stack Planning
Goal stack planning is one of the most basic and earliest planning techniques.

Here is what the stack contains:

1) Goals

2) operators – ADD, DELETE and PREREQUISITE list

3) A database that maintains current situation for each operator

Each sub-goal is solved separately and then the conjoined sub-goal is solved.
For example,
Goal Stack Planning

Stack Database

Goals
Current situation

Operators to
+ Specification of
satisfy
Operators/Actions
the Goals

15
Goal Stack Planning

Push the original goal to the stack. Repeat until the


stack is empty:
– If stack top is a compound goal, push its unsatisfied
subgoals to the stack.
– If stack top is a single unsatisfied goal, replace it by an
operator that makes it satisfied and push the operator’s
precondition to the stack.
– If stack top is an operator, pop it from the stack, execute it
and change the database by the operation’s affects.
– If stack top is a satisfied goal, pop it from the stack.

16
Goal Stack Planning

B C B
A C D A D

start: ON(B, A)  goal: ON(C, A) 


ONTABLE(A)  ON(B, D) 
ONTABLE(C)  ONTABLE(A) 
ONTABLE(D)  ONTABLE(D) 
ARMEMPTY

17
Goal Stack Planning
Initial State: ON(B, A) ^ ONT(C) ^ ONT(A) ^ ONT(D) ^ CL(B) ^CL(C) ^ CL(D) ^ AE

Goal State: ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE

 The following goals are already true in the initial state:


ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE

 The only goals to solve are ON(C, A) and ON(B, D).

 So, let’s solve ON(C, A)

Goal stack:
ON(C,A)
ON(B,D)
ON(C,A)^ ON(B,D)^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE

To solve ON(C, A), we can apply S(C, A) operation. So, replace it

Goal Stack:
S (C, A)
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
S(C, A) can be applied if its preconditions are true. So add its preconditions on the stack.
Goal Stack Planning
Goal Stack:
ON(B, A) B
CL(B) Preconditions of UNSTACK
AE A C D
ON(B, A) ^ CL(B) ^ AE
US(B, A) Operator
HOLD(C) Preconditions of STACK C B
CL(A) ) ^ HOLD(C) A D
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE

ON(B, A), CL(B) and AE are all true in an initial state, so pop these along with its
compound goal.
Next pop top operator US(B, A) and produce new state by using its ADD and DELETE
lists.
Add US(B, A) in a queue of a sequence of operators.
SQUEUE = US (B, A)
State_1:
ONT(A) ^ONT(C) ^ ONT(D) ^ HOLD(B) ^CL(A) ^ CL(C) ^ CL(D)
Goal Stack Planning
Goal Stack:

HOLD(C) Preconditions of STACK


CL(A) ) ^ HOLD(C)

S (C, A) Operator

ON(B, D)

ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE


To execute the S(C, A), all the preconditions of Stack operator should be true. But in
this case HOLD(C) is not true. To make the state true use the operator S(B, D)

S(B,D) Operator
HOLD(C)
CL(A) ) ^ HOLD(C) Preconditions of STACK
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
Write down the preconditions of S(B, D)
Goal Stack Planning
Goal Stack
CL (D) ^ HOLD (B) Preconditions of STACK
S(B,D) Operator
HOLD(C)
CL(A) ) ^ HOLD(C) Preconditions of STACK
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
Add S(B, D) in a queue of a sequence of operators.

SQUEUE = US (B, A), S (B, D)


State_2:
ONT(A) ^ONT(C) ^ ONT(D) ^ ON(B, D) ^ CL(A) ^ CL(C) ^ CL(B) ^ AE
Goal Stack Planning
Goal Stack
HOLD(C)
CL(A) ) ^ HOLD(C) Preconditions of STACK
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
To execute S(C, A) all the preconditions should be true.here HOLD(C) is not
true, to make the state true use the operator PU(C) and write the
preconditions.
Goal Stack
ONT (C)^CL (C)^ AE Preconditions of PICKUP
PU (C) Operator
HOLD(C)
CL(A) ) ^ HOLD(C) Preconditions of STACK
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
Here, all the preconditions of PU operator are true, so add PU(C) in a queue
of a sequence of operators.
SQUEUE = US (B, A), S (B, D),PU(C)
State_3:
ONT(A) ^ HOLD(C) ^ ONT(D) ^ ON(B, D) ^ CL(A) ^ CL(B)
Goal Stack Planning
Goal Stack
HOLD(C)
CL(A) ) ^ HOLD(C) Preconditions of STACK
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
Here all the preconditions of S(C, A) is true , so add S(C,A) in queue
SQUEUE = US (B, A), S (B, D),PU(C),S(C,A)
State_4:
ONT(A)^ON(C, A)^ ONT(D) ^ON(B, D) ^CL(C) ^CL(B)^ AE
Finally ,we reached goal state after S(C,A) using Goal Stack algorithm. So, the plan
for the given problem is,
UnStack (B, A)
Stack (B, D)
PickUp(C)
Stack(C,A)
Goal Stack Planning
Goal Stack:
CL(A)
HOLD(C) Preconditions of STACK
CL(A) ^ HOLD(C)
S (C, A) Operator
ON(B, D)
ON(C, A) ^ ON(B, D) ^ ONT(A) ^ ONT(D) ^ CL(C) ^ CL(B) ^ AE
To do the S(C, A) operation all preconditions should be true. In the given problem
CL(A) is not true.So, to make the state true , replace CL(A) by U(B, A) and write the
preconditions of Unstack operator.
Goal Stack Planning
Stack Database
ON(C, A) ON(B, A)
ON(B, D) OTACD
ON(C, A)  ON(B, D)  OTAD ARMEMPTY

CLEAR(A) ON(B, A)
HOLDING(C) OTACD
CLEAR(A)  HOLDING(C) ARMEMPTY
STACK(C, A)
ON(B, D) 
ON(C, A)  ON(B, D)  OTAD
25
Goal Stack Planning
Plan
1. UNSTACK(B, A)
2. STACK(B, D)
3. PICKUP(C)
4. STACK(C, A)

26
Goal Stack Planning

A
C B
A B C

start: ON(C, A)  goal: ON(A, B) 


ONTABLE(A)  ON(B, C)
ONTABLE(B) 
ARMEMPTY

Sussman Anomaly (1975)


27
Goal Stack Planning
Plan
1. UNSTACK(C, A)
2. PUTDOWN(C)
3. PICKUP(A)
4. STACK(A, B)
5. UNSTACK(A, B)
6. PUTDOWN(A)
7. PICKUP(B)
8. STACK(B, C)
9. PICKUP(A)
10. STACK(A, B)

28
Goal Stack Planning
Plan
1. UNSTACK(C, A)
2. PUTDOWN(C)
3. PICKUP(A)
4. STACK(A, B)
5. UNSTACK(A, B)
6. PUTDOWN(A)
7. PICKUP(B)
8. STACK(B, C)
9. PICKUP(A)
10. STACK(A, B)

29
Questions

• Why stacks used?


• Why a compound goal retained in the stack with its
subgoals?

• Does the order of subgoals in the stack matter?

30
Linear vs. Non-Linear Planning

• Goal Stack planning is linear: satisfies subgoals


sequentially, one after another.

• Non-linear planning: consider interaction among


subgoals.

31

Potrebbero piacerti anche