Problem Solving - public.asu.edu

Planning
Chapter 11
Copyright, 1996 © Dale Carnegie & Associates, Inc.
Acting logically
Problem-solving agents are able to plan
ahead before acting (Part II).
Knowledge-based agents can select
actions based on explicit, logical
representation of the current state and
the effects of actions (Part III).
We now build planning agents (Part IV).
CS 471/598 by H. Liu
2
A simple planning agent
An algorithm (Fig 11.1, page 338)
compared to the problem-solving agent in Fig 3.1
Percepts
State
Actions
Goal
Plan - a sequence of actions
must deal with no plan or plan is infeasible
CS 471/598 by H. Liu
3
From problem solving to
planning
They are different in representing goals, states,
and actions, and in ways of constructing action
sequences.
For a problem-solving agent,
Actions - generate successor state descriptions
State representations for successor generation,
heuristic eval function, and goal testing
Goals used in the goal test and the heuristic function
Plans - actions from the initial to the goal state
CS 471/598 by H. Liu
4
Example
Get milk and bananas and a drill
initial state: agent is at home without the above
operator set: all things agent can do
heuristic function: the things that haven’t yet been
acquired
Fig 11.2 - a small part of the first two levels of
the search space
CS 471/598 by H. Liu
5
Example (cont)
Problems with search agent
Too many actions and too many states to consider
Heuristic function can only choose among states and
can’t eliminate actions from consideration; so which
action should be taken?
Agent is forced to consider actions starting from the
initial state.
CS 471/598 by H. Liu
6
Solutions to the problems
Open up the representation of states, goals, actions
States and goals are represented by sets of sentences;
actions by logical descriptions of preconditions and effects
-> direct connections between states and actions.
Planner is free to add actions to the plan wherever
they are needed
So it can make obvious and important decisions first,
others later
Most parts of the world are independent of each
other -> so we can solve it independently
(Div&Conq)
CS 471/598 by H. Liu
7
Planning in situation
calculus
Initial state:
At(H,S0)^!Have(M,S0)^!Have(B,S0)^!Have(D,S0)
Goal state: there exists s,
At(H,s)^Have(M,s)^Have(B,s)^Have(D,s)
Operators: for all a, s
Have(M,Result(a,s)) <=> [(a=Buy(M)^At(SM,s) v
(Have(M,s)^a!=Drop(M))]
Definition of Result’(l,s) for sequence l
for all s Result’([],s) = s
for all a,p,s Result’([a|p],s)=Result’(p,Result(a,s))
CS 471/598 by H. Liu
8
A solution to the shopping
problem
In order to achieve
At(Home,Res’(p,S0))^Have(Milk,Res’(p,S0))^
Have(Bananas,Res’(p,S0))^Have(Drill,Res’(p,S0))
What’s the plan p?
Go(SupMar),Buy(Milk),Buy(Bananas),Go(Hardwere),Buy(Drill
),Go(Home)
What are the problems?
Inefficient (unguided search)
Irrelevant steps [Nothing|p] and [A,A’|p]
CS 471/598 by H. Liu
9
Basic representations
STRIPS language for efficient planning
States are conjunctions of function-free ground literals
At(Home)^!Have(Milk)^!Have(Bananas)^!Have(Drill)^...
Goals are conjunctions of literals, contain variables
At(Home)^Have(Milk)^…
At(x)^Sells(x,Milk)
Implicit representations of states in planning - only
changes are tracked.
Operators in SRIPS have three components: action,
precondition, and effect
CS 471/598 by H. Liu
10
STRIPS
A plan is a data structure of the following
plan steps (operators)
ordering constraints (Si  Sj)
variable binding constraints
causal links (Si c Sj)
An example (Fig 11.3) represents
Op(ACTION:Go(there),PRECOND:At(here)^Path(here,th
ere),EFFECT:At(there)^!At(here)
CS 471/598 by H. Liu
11
STRIPS (2)
Operator Schema - an operator with variables
Applicable operators - precond’s can be met
Progression vs. regression planners
Partial plans are incomplete plans
We can have refinement or modification
operators
A solution is a plan that can be executed to
achieve the goal
CS 471/598 by H. Liu
12
STRIPS (3)
An example: RightShoeOn^LeftShoeOn
Fig 11.4
Types of order: partial and total
Least commitment - one should only make necessary
choices
Partial order is of least commitment
Linearization: from partial to total order
Why not total order? Fig 11.5
CS 471/598 by H. Liu
13
A plan is complete if every precondition of every
step is achieved by some other step.
A step achieves a condition if the condition is one of
the effects of the step.
The need for promotion and demotion (Fig 11.10)
The causal link to protect a precond
A plan is consistent if there are no
contradictions in the ordering or binding
constraints.
Ordering is transitive
CS 471/598 by H. Liu
14
Partial-order planning (POP)
Revisit the shopping example
Initial state: Op(Action:Start,Effect:At(home)^Sells(HWS,Drill)^
Sells(SM,Milk),Sells(SM,Bananas))
We have Go and Buy actions
Op(Action:Go(there),Precond:At(here),Effect:At(there)^!At(here))
Op(Action:Buy(x),Precond:At(store)^Sells(store,x),Effect:Have(x))
Goal state: Op(Action:Finish,Precond:At(home)^Have(Drill)^
Have(Milk),Have(Bananas))
 Let’s plan ...
CS 471/598 by H. Liu
15
Partial-order planning
(Algorithm)
Algorithm - Fig 11.13
It’s nondeterministic
It starts with a minimal partial plan.
It satisfies one precond at a time.
POP is a regression planner.
POP is sound and complete.
CS 471/598 by H. Liu
16
Partially instantiated
operators
Dealing with variable binding constraints
Is !At(x) a threat to the condition At(Home)?
It’s a possible threat
Resolve now with an equality constraint, At(HWS)
Resolve now with an inequality constraint, x!=Home
Resolve later => partially instantiated opererators
Modified POP in Fig 11.14, p358
Full instantiation of operators before returning a
plan
CS 471/598 by H. Liu
17
More examples on planning
The blocks world
On(b,x), Move(b,x,y), Clear(x)
Op(Action:Move(b,x,y),
Precond:On(b,x)^Clear(b)^Clear(y),
Effect:On(b,y)^Clear(x)^!On(b,x)^!Clear(y))
What if y is a table? Clear(Table)?
Op(Action:MoveToTable(b,x),
Precond:On(b,x)^Clear(b),
Effect:On(b,Table)^Clear(x)^!On(b,x))
Shakey’s world
(Fig 11.15) -
the domain for STRIPS
CS 471/598 by H. Liu
18
Summary
Planning uses more flexible representations of
state, actions, goals, and plans
STRIPS - a specific language that connects states
to actions (action, precond, effect)
Search through the plan space - regression
Least commitment: partial ordering & instantiation
Causal links: protect rewriting & detect conflicts
early
CS 471/598 by H. Liu
19