planning: part 1 representation and state-space search comp151 march 30, 2007
Post on 21-Dec-2015
217 views
TRANSCRIPT
Example Planning Problem
Table
A
C
E
D
J
F
LG
K
I
H
B
Goal: Stack of blocks: FCGHJB (bottom to top)Possible Actions: move any single block which has nothing on top of it.
Example Planning ProblemGoal: Stack of blocks: FCGHJB (bottom to top)Possible Actions: move any single block which has nothing on top of it.
Considerations:Can this be decomposed into subproblems?Can we identify irrelevant/useless actions?Can we select better actions?
Analysis:12 blocks, 13 destinations (including table)156 potential movesn156 nodes in a search tree (n = # moves)
Planning: Chapter 11
• 11.1 The planning problem• 11.2 Planning with state-space search• 11.3 Partial-order planning• 11.4 Planning graphs• 11.5 Planning with propositional logic• 11.6 Analysis of planning approaches
Planning?
• Planning is the task of determining a sequence of actions that will achieve a goal.
• Domain independent heuristics and strategies must be based on a domain independent representation– General planning algorithms require a way to
represent states, actions and goals– STRIPS, ADL, PDDL are languages based on
propositional or first-order logic• Classical planning environment:
fully observable, deterministic, finite, static and discrete.
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.• Decomposability means that working on one subgoal does
not undo other subgoals
Problem Representation
• State– What is true about the (hypothesized) world?
• Goal– What must be true in the final state of the world?
• Actions– What can be done to change the world?– Preconditions and effects
• We’ll represent all these as logic predicates
Representing States and Goals
• States and goals are represented as aconjunction of positive, ground, function-free literals
• Propositional literals: Poor Unknown• FO-literals (grounded and function-free):
At(Plane1, Melbourne) At(Plane2, Sydney)• States:
– Closed world assumption: anything not explicitly true is false
• Goals:– A partially specified state– A goal is satisfied if state contains all literals in goal.
Representing Actions
• An action schema represents a parameterized actions– Action name and parameter list– Precondition
• conj. of function-free literals– Effect
• conj of function-free literals• add-list: predicates that will be true• delete-list: predicates that will be false
• Example:– Action(Fly(p,from, to),
PRECOND: At(p,from) Plane(p) Airport(from) Airport(to)EFFECT: ¬AT(p,from) At(p,to))
Applicability of Actions
• 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.
Effect of Actions
• Executing action a in state s results in state s’,where 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’
s: At(P1,JFK) At(P2,SFO) Plane(P1) Plane(P2) Airport(JFK) Airport(SFO)
EFFECT: ¬AT(p,from) At(p,to):
s’: At(P1,SFO) At(P2,SFO) Plane(P1) Plane(P2) Airport(JFK) Airport(SFO)
• STRIPS assumption: every literal NOT in the effect remains unchanged
avoids representational frame problem
Planning Languages
• STRIPS: Stanford Research Institute Problem Solver– important limit: function-free literals
• allows for propositional representation• function symbols lead to infinitely many states and actions
• ADL: Action Description Language– A number of extension to STRIP (next slide)
Action(Fly(p:Plane, from: Airport, to: Airport),PRECOND: At(p,from) (from to)EFFECT: ¬At(p,from) At(p,to))
• PDDL: Planning Domain Definition Language:– standardization effort – Includes sublanguages for STRIPS and ADL.
STRIPS ADL
Only positive literals in states Positive and negative literals in states
Closed world assumption Open world assumption
Effect P ^ ¬Q means add P and delete Q
Effect P ^ ¬Q means add P, ¬Q and delete ¬P , Q
Only ground literals in goals Quantified variables in goals
Goals are conjunctions Goals contain conjunction and disjunction
Effects are conjunctions Conditional effects are allowed (when P: E)
Equality predicate (x = y) built in
Variables can have types
air cargo transport: STRIPSInit(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), Load(C2,P2,JFK), Fly(P2,JFK,SFO), Unload(C1, P1, SFO), Unload(C2, P2, SFO)]
air cargo transport: ADLInit(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: Cargo, p: Plane, a: Airport)
PRECOND: At(c,a) At(p,a)EFFECT: ¬At(c,a) In(c,p))
Action(Unload(c : Cargo, p: Plane, a: Airport)PRECOND: In(c,p) At(p,a) EFFECT: At(c,a) ¬In(c,p))
Action(Fly(p: Plane, from: Airport, to: Airport)PRECOND: At(p,from) (from ≠ to) EFFECT: ¬ At(p,from) At(p,to))
[Load(C1,P1,SFO), Fly(P1,SFO,JFK), Load(C2,P2,JFK), Fly(P2,JFK,SFO), Unload(C1, P1, SFO), Unload(C2, P2, SFO)]
spare tire problem: ADLInit(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) )
Do we need to add negative facts in initial state?
blocks world: ADL
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) (b x) (b y) (x y) EFFECT: On(b,y) Clear(x) ¬ On(b,x) ¬ Clear(y))
Action(MoveToTable(b,x)PRECOND: On(b,x) Clear(b) Block(b) (b x) EFFECT: On(b,Table) Clear(x) ¬ On(b,x))
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– Determine what must have been true in the previous
state in order to achieve the current state
Progression algorithm
• Formulation as state-space search problem:– Initial state and goal test: obvious– Successor function: generate from applicable actions– Step cost = each action costs 1
• Any complete graph search algorithm is a complete planning algorithm.– E.g. A*
• Inherently inefficient: – (1) irrelevant actions lead to very broad search tree– (2) good heuristic required for efficient search
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.
Regression algorithm
• General process for predecessor construction– Give a goal description G– Let A be an action that is relevant and consistent– The predecessors are 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.
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 assumption:The cost of solving a conjunction of subgoals is approximated by the sum of
the costs of solving the subproblems independently.
Exercises
Define state, goal and actions using STRIPS or ADL• Sorting a deck of cards by suit and value• Changing your socks• Cleaning the kitchen:
– Cleaning stove or refrigerator will get floor dirty
– To clean oven: first apply oven cleaner, then remove cleaner
– Floor must be swept before it is washed
– Garbage must be taken out before floor can be swept
– Cleaning refrigerator generates garbage and messes up counters
– Washing counters or floor gets sink dirty