roots of planning
TRANSCRIPT
Roots of planning
n problem solving through state-spacesearch
n software agents (e.g. robotics)
EXAMPLE: “Shakey” (pg. 360)n a robot that roamed the halls of SRI in
the early 1970’sn actions were based on plans
The Problem
Find a sequence of actions that achievesa given goal when performed starting in
a given state.
PLANPLANPLANPLAN
START
FINISH
Initial State
Goal State
OperatorInstances
A Simple Planning Agent
plans ahead before acting (ch3)
selects actions based on explicit,logical representations of thecurrent state and the effects ofactions (ch6)
agent uses beliefs about actionsand their consequences tosearch for a solution over aspace of plans rather than aspace of situations
A Simple Planning Agent
Algorithm: (pg. 338)
1. Generate a goal to achieve
2. Construct a plan to achieve goal fromcurrent state
3. Execute plan until finished
4. Begin again with new goal
A Simple Planning Agent
n Assumptions:– Atomic time
– no concurrent actions allowed
– deterministic actions
– agent is the sole cause of change in theworld
– agent is omniscient
– Closed World Assumption
“The Blocks World”
Domain:– set of cubic blocks sitting on
a table
Actions:– blocks can be stacked
– can pick up a block andmove it to another position
– can only pick up one blockat a time
Goal:– to build a specified stack of
blocks
AAAACCCCBBBB
INITIAL STATE
GOAL STATE
BBBB
AAAACCCC
So what’s the difference?
Problem-Solving:
(State-space search)n representation of actions,
states, goals, plansn actions are represented by a
program that generatescomplete state descriptions
n “black box”n unbroken sequences of
actions beginning from theinitial state to the goal state
Planning:
(Situation Calculus)n “open up” the representation
of states, goals, and actionsn planner is free to add actions
to the plan wherever theyare needed
n most parts of the world areindependent of most otherparts -> divide and conquer
Important Points
n Planning agents uselookahead
n Planning agents differ fromproblem-solving agents– use of more flexible
representations of states,actions, goals, and plans
Situation Calculus
n Augment FOL so that it can reasonabout actions in time– Add situation variables to specify time
– Add predicate holds(f,s)
– Add function result(a,s)
n Example: agent-walks-to-location-y(∀∀ x)(∀∀ y)(∀∀ s)(at(Agent,x,s)) =
at(Agent,y,result(walk(y),s))
Situation Calculus
n You must also specify what doesn’tchange!
n Example: agent-walks-to-location-y– (∀∀ x)(∀∀ y)(∀∀ s)(at(Agent,x,s)) =
at(Agent,y,result(walk(x,y),s))
– (∀∀ x)(∀∀ y)(∀∀ s)(at(Bananas,x,s)) =at(Bananas,x,result(walk(x,y),s))
Practical Planning
n Restrict the language with which wedefine problems
n Use a special-purpose algorithm calleda planner rather
Important Points
n A planning problem isrepresented in situationcalculus by logicalsentences
n Planning by unguidedlogical inference isinefficient and gives noguarantees about theresulting plan
Representing States & Goals
n STRIPS:– describes states & operators in a restricted
language
n States:– a conjunction of “facts” (ground literals that
do not contain variable symbols)
n Goals:– a conjunction of positive literals
Representing States & Goals
Initial State:ontable(A) Λontable(B) Λ
on(C, B) Λ
clear(A) Λclear(C) Λ
handempty
Goal:ontable(B) Λ
on(C,B) Λon(A,C) Λ
clear(A) Λ
handempty
AAAACCCCBBBB
INITIAL STATE
GOAL STATE
BBBB
AAAACCCC
Representing Actions
1. Action descriptionName: pickup(x)
2. PreconditionPreconditions: ontable(x), clear(x), handempty
3. EffectEffect: holding(x), ~ontable(x), ~clear(x),
~handempty
An operator is APPLICABLE if all preconditions areAn operator is APPLICABLE if all preconditions aresatisfied.satisfied.
Actions in “Blocks World”
n pickup(x)– picks up block ‘x’
from table
n putdown(x)– if holding block ‘x’,
puts it down on table
n stack(x,y)– if holding block ‘x’,
puts it on top ofblock ‘y’
n unstack(x,y)– picks up block ‘x’ that
is currently onblock ‘y’
Important Points
n The STRIPS languagedescribes actions in termsof their preconditions andeffects. It captures much ofthe expressive power ofsituation calculus, but notall domains and problemscan be described in theSTRIPS language
Planning as Search
n Situation Space– start at initial
state, applyoperators untilreached goal(e.g. searching)
n Plan Space– search through a
space of plans
See Figure 11.2 (pg. 340)
See Figure 11.5 (pg. 348)
FinishStartpickup(A)
unstack(C,B)
putdown(A)
stack(A,C)
...putdown(C)
stack(C,A)
stack(C,B)
Start
Finishon(A,C)
holding(A)pickup(A)
handempty
stack(A,C)
Situation-Space Planners
n Progression– Forward chaining from initial state to goal
state
n Regression– Backward chaining from goal state to initial
state
Progression Situation Space
n Like a state-space search exceptSTRIPS operators specified instead aset of next-move functions
n Use any search method you like (e.g.BFS, DFS, A*)
n PROBLEM:– huge search space to explore, so usually
very inefficient
AAAACCCCBBBB
INITIAL STATE
GOAL STATE
BBBB
AAAACCCC
Progression Situation-Space
Algorithm:1. Start from initial state2. Find all operators whose
preconditions are true inthe initial state
3. Compute effects ofoperators to generatesuccessor states
4. Repeat steps 2-3, until anew state satisfies thegoal conditions
Important Points
n There are 2 approaches tosolving planning problems:– situation-space planners
– plan-space planners
n Progression is one type ofsituation-space planners
Regression Situation-Space
n Usually more efficient than progression– progression: many operators are
applicable at each state
– regression: only a small number ofoperators are applicable for achieving agiven goal
n PROBLEM:– cannot always find a plan even if one
exists!
AAAACCCCBBBB
INITIAL STATE
GOAL STATE
BBBB
AAAACCCC
Regression Situation-Space
Algorithm:1. Start with goal node
corresponding to goal tobe achieved
2. Choose an operator thatwill add one of the goals
3. Replace that goal withthe operator’spreconditions
4. Repeat steps 2-3 untilyou have reached theinitial state
Important Points
n Regression is the secondtype of situation-spaceplanner
n It is more efficient thanprogression
Where Situation-Space fails…
n If the order of solving a set of goals failsbecause solving a later goal undoes anearlier goal
n Does not allow for interleaving of stepsin any solution it finds
“Sussman Anomaly”
n Solving on(A,B) first will be undonewhen solving the second goal on(B,C)and vice versa.
AAAACCCC
BBBBINITIAL STATE GOAL STATE
BBBBAAAA
CCCC
Plan-Space Planners
n Use when ordering of sub-goals matters
n Make commitments only as necessaryn Least Commitment planning:
– never making a choice unless required todo so
• Advantage: don’t have to backtrack later!
Important Points
n Use situation spaceplanners when goals arenot interleaved
n Use plan space plannerswhen goals are interleaved– the ordering of goals affects
the outcome
Definition of a plan
n A plan is formally defined as a data structureconsisting of the following 4 components:– A set of plan steps– A set of step ordering constraints
– A set of variable binding constraints– A set of causal links
Plan(STEPS:{S1:Op(ACTION: Start),
S2:Op(ACTION: Finish,
PRECOND: On(c, table) ∧ On(b,c) ∧ On(a,b) } ,
ORDERINGS: {S1 < S2},
BINDINGS: {},
LINKS: {})
Representation for Plans
Partial Order Plans:n can represent plans
in which some stepsare ordered withrespect to eachother and othersteps are unordered
Total Order Plans:n plans consist of a
simple list of steps
Partial vs. Total Order Plans
Start
LeftSock
RightSock
LeftShoe
RightShoe
Finish
Start
Finish
RightSock
LeftSock
LeftShoe
RightShoe
Partial Order Plan: Total Order Plan:
Start
Finish
LeftSock
RightSock
RightShoe
LeftShoe
Start
Finish
LeftSock
RightSock
LeftShoe
RightShoe
Start
Finish
RightSock
RightShoe
LeftSock
LeftShoe
Start
Finish
RightSock
LeftSock
RightShoe
LeftShoe
Start
Finish
LeftSock
LeftShoe
RightSock
RightShoe
Important Points
n Partial-ordering constraintsand uninstantiatedvariables allow us to followa least-commitmentapproach
Chapter 11 - Planning
Section 11.5
Partial-Order PlanningExample
Partial-Order Planning Example
n Return to shopping problem:– Buy milk, bananas, a drill, and then return
back home
n Start with the definitions of the initialand final states
n Also give the actions involved in theexample
State Definitions
n Initial StateOp(ACTION: Start,
EFFECT: At(Home) ∧ Sells(HWS,Drill) ∧
Sells(SM, Milk) ∧ Sells(SM,Bananas))
n Goal StateOp(ACTION: Finish,
PRECOND: Have(Drill) ∧ Have(Milk) ∧
Have(Bananas) ∧ At(Home))
Action Definitions
n ActionsOp(ACTION: Go(there),
PRECOND: At(here),
EFFECT: At(there) ∧ ¬ At(here))
Op(ACTION: Buy(x),
PRECOND: At(store) ∧ Sells(store, x),
EFFECT: Have(x))
Initial Plan
n Bold arrows are causal links
n Thin arrows are ordering constraints
Figure 11.6 From Artificial Intelligence: A Modern Approach
Extending the Plan
n Since there is no other way to achieve the Have(x)preconditions of the goal state, planner mustextend plan by adding actions that will achievethem
n Extend plan by adding Buy actions
Figure 11.7a From Artificial Intelligence: A Modern Approach
Causal Links Protect Conditions
n Causal link between Buy(Drill) andFinish means it was added to achievethe Finish precondition Have(Drill)
n If a new step comes that deletesHave(Drill) condition the planner willmake sure it won’t go betweenBuy(Drill) and Finish.
Achieving Preconditions
n Now planner achieves the Sells preconditions bylinking them to the initial state by causal links
n Since this is the only operator that achieves the Sellsprecondition, the planner must choose this one
Figure 11.17b From Artificial Intelligence: A Modern Approach
How Well Are We Doing?
n Large improvement over the problem-solving approach– Planner was able to choose the right
actions without considering all of the otheralternatives
– Don’t need to worry about ordering ofactions because the POP will do that later
Adding the Go Actions
n Planner must now extend the plan by adding Goactions to achieve At condition of Buy action
n This will get us to the HWS and the SM
Figure 11.8 From Artificial Intelligence: A Modern Approach
Problem with the Go Actions I
n If planner links both Go actions to the initial state,both actions will interact with each other
n Problem: agent can’t be at two places at once
Figure 11.9 From Artificial Intelligence: A Modern Approach
Problem with Go Actions II
n If the agent takes one link, then theprecondition At(Home) for the other linkwill be negated
n This is a threat, and must be resolvedbefore continuing
Problem with Go Actions III
n We realize that neither promotion nordemotion can solve this threat
n No matter which of the two is chosenfirst, At(Home) precondition of the otheris deleted
n When this occurs, the planner must giveup on partial plan and back up to aprevious choice
Solution to Go Actions
n Instead of linking both Go actions to initial state, theplanner decides to go from Home to the HWS, thenfrom the HWS to the SM
n This is done by linking Go(HWS) to Go(SM)
Modified Figure 11.11 From Artificial Intelligence: A Modern Approach
Another Threat
n Go(SM) step threatens the At(HWS) precondition ofthe Buy(Drill) step which is protected
n Might go from HWS to the SM and forget to buy thedrill!
n Solution: promotion– constrain Go(SM) to come after the Buy(Drill) step
– add an ordering constraint from Buy(Drill) to Go(SM)
Modified Figure 11.11 From Artificial Intelligence: A Modern Approach
Final Step I
n Only At(Home) precondition of goal stateleft to achieve
n Now planner must extend plan by addingGo(Home) step to achieve this
n Try to achieve At(x) by linking At(Home) tothe initial state, this will threaten At(Home)precondition of At(HWS) step
n There is no way to resolve this threat, soplanner must back up and try again
Final Step II
n Now planner tries to link At(x) to theGo(HWS) step, then this will also be athreat
n Threatens At(HWS) step of the Go(SM)step
n Again, can’t resolve this, so plannermust backtrack and try another path
Final Step III
n It now tries to link to Go(SM) step
n Another threat:– Threatens At(SM) preconditions of the
Buy(Milk) and Buy(Bananas) steps
n But this can be solved with promotion– Constrain the Go(Home) step to come after
the Buy(Milk) and Buy(Bananas) steps
n Now we’re done!
Final Plan
Figure 11.11 From Artificial Intelligence: A Modern Approach
Advantages of POP
n POP can take a problem that would takemany search states for problem-solvingapproach and solve it in only a few steps
n Least commitment nature of planner means itonly needs to search where subplans interact
n Causal links allow planner to know when tostop a bad plan without wasting timeexpanding irrelevant parts of the plan
Summary
n POP starts with a minimal plan and adds to it until allpreconditions have been satisfied
n POP is a regression planner
n POP can take a problem that would take manysearch states for problem-solving approach and solveit in only a few steps
n Causal links protect conditions
n If threat occurs, promote/demote threatening steps
n POP can be extended to allow partially-instantiatedoperators– need to worry about possible threats