Planning
Introduction to Artificial Intelligence
© G. Lakemeyer
G. Lakemeyer
Winter Term 2024/25
Planning
B B
C A A C
© G. Lakemeyer
A (logical) description of the initial state, a descrip-
Given: tion of the goal state, a description of actions (pre-
conditions and effects).
Find a plan involving these actions that takes you
Problem:
from the initial state to the goal state.
AI/WS-2024/25 2 / 22
Why is Planning Different from Search?
In contrast to states in search problems,
states in planning need not be completely specified.
Search treats states as black boxes.
In planning one wants to look at the parts. E.g.: which block is free?
© G. Lakemeyer
Search generates all successor states.
Planning often only generates some.
Search wants to find a sequence of actions leading to a goal.
Planning looks for a description of a plan, e.g. actions may only be
partially ordered.
AI/WS-2024/25 3 / 22
Why is Planning Different from Search?
There are too many actions to choose from. In general, impossible to
generate all successor states.
Talk to Parrot
Go To Pet Store Buy a Dog
Go To School Go To Class
© G. Lakemeyer
Go To Supermarket Buy Tuna Fish
Start
Go To Sleep Buy Arugula
Read A Book Buy Milk
... Finish
Sit in Chair Sit Some More
Etc. Etc. ... ... Read A Book
AI/WS-2024/25 4 / 22
STRIPS Operators
STRIPS: STanford Research Institute Problem Solver
(Planner of the early Seventies. While STRIPS itself is no longer in use, its
operator descriptions are.)
Actions are triples of the following form:
Action name: Function name with parameters
© G. Lakemeyer
Preconditions: only positive literals
Effects: positive und negative literals
In addition:
set of ground literals, no function symbols other
Initial State:
than constants.
set of literals (possibly with free variables, implicitly
Goal State:
existentially quantified)
AI/WS-2024/25 5 / 22
Example Strips Operator
At(here), Path(here, there)
Go(there)
© G. Lakemeyer
At(there), At(here)
Op(Action: Go(there), L
Precond: At(here) ∧ Path(here,there),
Effect: At(there) ∧¬ At(here))
AI/WS-2024/25 6 / 22
STRIPS Operators for the Blocks World
B B
C A A C
Op(Action: pickup(x,y),
Precond: Block(x), On(x,y),
© G. Lakemeyer
Clear(x), Empty(hand),
Effect: Holding(x), ¬Empty(hand), ¬Clear(x),
¬On(x,y), Clear(y))
Op(Action: puton(x,y),
Precond: Block(y), Holding(x), Clear(y)
Effect: ¬Holding(x), ¬Clear(y),
On(x,y), Empty(hand), Clear(x))
Op(Action: putonTable(x),
Precond: Block(x),Holding(x),
Effect: ¬Holding(x), On(x,table),
Empty(hand), Clear(x))
AI/WS-2024/25 7 / 22
What is a Plan?
Plan step = STRIPS-Operator
A Plan consists of
© G. Lakemeyer
a set of partially ordererd (≺) plan steps,
where Si ≺ Sj iff Si must be executed before Sj .
a set of variable assignments x = t,
where x is a variable and t is a constant or a variable.
a set of causal relations,
c
where Si −→ Sj means “Si satisfies the precondition c for Sj .”
AI/WS-2024/25 8 / 22
Complete and Consistent Plans
Complete Plan:
Every precondition of every plan step is satisfied, that is:
∀Sj with c ∈ Precond (Sj ) ∃Si with Si ≺ Sj and c ∈ Effects(Si )
and for every linearization of the plan we have:
© G. Lakemeyer
∀Sk with Si ≺ Sk ≺ Sj , ¬c ̸∈ Effects(Sk ).
Consistent Plan:
If Si ≺ Sj then Sj ̸≺ Si and if x = A then x ̸= B for distinct A and B.
(Unique Names Assumption!)
A complete and consistent plan is called a solution.
AI/WS-2024/25 9 / 22
Problem Description
Problem description = initial plan
Start Start
Initial State
Goal State LeftShoeOn, RightShoeOn
© G. Lakemeyer
Finish Finish
(a) (b)
Plan(Steps:
S1 :Op(Action: Start),
S2 :Op(Action: Finish)
Precond: RightShoeOn ∧ LeftShoeOn)
Orderings: {S1 ≺ S2 }
Bindings: {}
Links: {})
AI/WS-2024/25 10 / 22
Features of the Problem Description
Initial state and goal state are encoded as STRIPS-operators.
Plan step: take a plan step with ≥ 1 unsatisfied preconditions; insert a
new plan step which satisfies one or more of these conditions. (Helps
© G. Lakemeyer
focus the search.)
Decisions about order, variable assignments, etc. are delayed as long as
possible.
Leads to partially ordered plans.
AI/WS-2024/25 11 / 22
Partially Ordered Plans
Partial Order Plan: Total Order Plans:
Start Start Start Start Start Start Start
Right Right Left Left Right Left
Sock Sock Sock Sock Sock Sock
Left Right
Sock Sock
Left Left Right Right Right Left
Sock Sock Sock Sock Shoe Shoe
LeftSockOn RightSockOn
Right Left Right Left Left Right
Left Right
Shoe Shoe Shoe Shoe Sock Sock
Shoe Shoe
© G. Lakemeyer
Left Right Left Right Left Right
Shoe Shoe Shoe Shoe Shoe Shoe
LeftShoeOn, RightShoeOn
Finish Finish Finish Finish Finish Finish Finish
Op(Action: RightShoe, Op(Action: LeftShoe,
Precond: RightSockOn, Precond: LeftSockOn,
Effect: RightShoeOn) Effect: LeftShoeOn)
Op(Action: RightSock, Op(Action: LeftSock,
Effect: RightSockOn) Effect: LeftSockOn)
AI/WS-2024/25 12 / 22
Shopping Example
Start
At(Home) Sells(SM,Banana) Sells(SM,Milk) Sells(HWS,Drill)
Have(Drill) Have(Milk) Have(Banana) At(Home)
Finish
© G. Lakemeyer
Start state: Op(Action: Start,
Effect: At(Home)∧Sells(HWS,Drill)∧
Sells(SM,Milk)∧Sells(SM,Bananas))
Goal state: Op(Action: Finish,
Precond: Have(Drill)∧Have(Milk)∧
Have(Bananas)∧At(Home))
Actions: Op(Action: Go(there), Op(Action: Buy(x),
Precond: At(here), Precond: At(store)∧
Effect: At(there)∧ Sells(store,x)
¬At(here)) Effect: Have(x))
AI/WS-2024/25 13 / 22
Example (2)
Start
At(s), Sells(s,Drill) At(s), Sells(s,Milk) At(s), Sells(s,Bananas)
Buy(Drill) Buy(Milk) Buy(Bananas)
Have(Drill), Have(Milk), Have(Bananas), At(Home)
Finish
© G. Lakemeyer
Start
At(HWS), Sells(HWS,Drill) At(SM), Sells(SM,Milk) At(SM), Sells(SM,Bananas)
Buy(Drill) Buy(Milk) Buy(Bananas)
Have(Drill), Have(Milk), Have(Bananas), At(Home)
Finish
AI/WS-2024/25 14 / 22
Example (3)
Start
At(x) At(x)
Go(HWS) Go(SM)
© G. Lakemeyer
At(HWS), Sells(HWS,Drill) At(SM), Sells(SM,Milk) At(SM), Sells(SM,Bananas)
Buy(Drill) Buy(Milk) Buy(Bananas)
Have(Drill) , Have(Milk) , Have(Bananas) , At(Home)
Finish
AI/WS-2024/25 15 / 22
Example (4)
Start
At(Home) At(Home)
Go(HWS) Go(SM)
At(HWS), Sells(HWS,Drill) At(SM), Sells(SM,Milk) At(SM), Sells(SM,Bananas)
© G. Lakemeyer
Buy(Drill) Buy(Milk) Buy(Bananas)
Have(Drill) , Have(Milk) , Have(Bananas) , At(Home)
Finish
Dead end!
Go(HWS) and Go(SM) block each other because one destroys the
precondition of the other.
AI/WS-2024/25 16 / 22
Protection of Causal Relations
S3
c
L
S1 S1 S1
S3
c
L c c c
S2 S2 S2
© G. Lakemeyer
S3
c
L
(a) (b) (c)
a) Conflict
Conflict resolutions:
b) Demotion
c) Promotion
AI/WS-2024/25 17 / 22
Example of Promotion
© G. Lakemeyer
AI/WS-2024/25 18 / 22
Example (5)
Start
At(Home) At(HWS)
Go(HWS) Go(SM)
© G. Lakemeyer
At(HWS), Sells(HWS,Drill) At(SM), Sells(SM,Milk) At(SM), Sells(SM,Bananas) At(SM)
Buy(Drill) Buy(Milk) Buy(Bananas) Go(Home)
Have(Drill) , Have(Milk) , Have(Bananas) , At(Home)
Finish
AI/WS-2024/25 19 / 22
End of Example
Start
At(Home)
Go(HWS)
At(HWS) Sells(HWS,Drill)
Buy(Drill)
© G. Lakemeyer
At(HWS)
Go(SM)
At(SM) Sells(SM,Milk) At(SM) Sells(SM,Ban.)
Buy(Milk) Buy(Ban.)
At(SM)
Go(Home)
Have(Milk) At(Home) Have(Ban.) Have(Drill)
Finish
AI/WS-2024/25 20 / 22
Threats with Variables
© G. Lakemeyer
AI/WS-2024/25 21 / 22
The POP Algorithm
function POP(initial, goal, operators) returns plan
plan MAKE-MINIMAL-PLAN(initial, goal)
loop do
if SOLUTION?( plan) then return plan
Sneed , c SELECT-SUBGOAL( plan)
CHOOSE-OPERATOR( plan, operators, Sneed, c)
RESOLVE-THREATS( plan)
end
function SELECT-SUBGOAL( plan) returns Sneed , c
pick a plan step Sneed from STEPS( plan)
with a precondition c that has not been achieved
return Sneed , c
© G. Lakemeyer
procedure CHOOSE-OPERATOR(plan, operators, Sneed, c)
choose a step Sadd from operators or STEPS( plan) that has c as an effect
if there is no such step then fail
!
add the causal link Sadd c Sneed to LINKS( plan)
add the ordering constraint Sadd Sneed to ORDERINGS( plan)
if Sadd is a newly added step from operators then
add Sadd to STEPS( plan)
add Start Sadd Finish to ORDERINGS( plan)
procedure RESOLVE-THREATS(plan)
!
for each Sthreat that threatens a link Si c Sj in LINKS( plan) do
choose either
Promotion: Add Sthreat Si to ORDERINGS( plan)
Demotion: Add Sj Sthreat to ORDERINGS( plan)
if not CONSISTENT( plan) then fail
end
AI/WS-2024/25 22 / 22