440 likes | 572 Views
s j. What is planning?. State Space Search: (Problem solving agent) Planning (Planning agent) – computes several steps of problem solving procedure before executing them. Plan: sequence of actions. op n. Initial State. s i. States Initial State Goal State Actions (Operators). op 1.
E N D
sj What is planning? • State Space Search: (Problem solving agent) • Planning (Planning agent) – computes several steps of problem solving procedure before executing them. Plan: sequence of actions. opn Initial State si States Initial State Goal State Actions (Operators) op1 op2 Goal State
Planning: example • Goal: Get a bunch of bananas, a cordless drill, and a quart of milk • Initial State: At Home No milk No cordless drill No bananas • Goal State: At Home milk cordless drill bananas Problem: Many actions and many states to consider; sequence of actions could become too long
Planning example, contd. … • Evaluation function • Determine possible next states by applying evaluation function. • Only select states closer to goal. • Problem: Too many states! • Goal and evaluation function are black boxes, therefore, cannot really eliminate a number of actions from consideration. • Note: Evaluation function is being applied after the fact
Planning Example Contd. • Forward search may not succeed. • Starting at initial state. • Forces agent’s hand. • Example: Since agent is at home, and the things he needs are not at home, he must go somewhere. But where? • Backward search may be better. • One way to have milk is to buy it. • Milk can be purchased at the grocery store. Therefore, …..
Planning: Key Ideas • Need representations for states, goals, and actions. • Planner can add actions to the plan in any order as needed. • Do not have to start at initial state and incrementally (sequentially) progress.
Planning: Key Ideas • Problem decomposition • Many parts of the world are independent of others. • Use divide and conquer. • Create sub-problems and solve them one by one. • Many planners assume subgoals can be solved independently. • Will this approach always work?
Planning: Classical Approach • Considers environments that are: • Fully observable • Deterministic • Finite • Static • Only change is via the agent’s actions • And are discrete in time, action, objects, and effects.
STRIPS • (STanford Research Institute Problem Solver) language • Relies on representing states, goals and actions. • Uses Closed World Assumption in state representation.
STRIPS • States: Conjunction of grounded function free predicates • States are always represented with positive literals (no negations). Initial State: • Goals: A partially specified State.
STRIPS • Actions: Represented by • Precondition: conjunction of function free positive literals that must be true before the action is applied. • Add list: A set of function free literals that will be added to the current state. • Delete List: A set of function free literals that will be deleted from the current state. • Effect: Conjunction of function free literals representing how the state changed when the action is applied. • Negations in Effect list represent items to be deleted.
STRIPS operators • Restricted Language Action: Buy(x) Precondition: At(p) Sells(p,x) Want(x) Add List: Have(x) Delete List: Want(x) Effect: Want(x) Have(x) • abstracts away many important details search algorithm to generate efficient plan.
STRIPS • STRIPS action consists of three parts • PC: preconditions • D: delete list (negative literals) • A: add list (positive literals) • Ef: Effect • After-action state description generated by deleting all literals in D from the before-action state description, and then add the literals in A. • Strips Assumption: All literals not mentioned in D carry over from the before-action to the after-action state (Effect). -- Important: Frame Problem.
B A C STRIPS applied to the Blocks World • State Description: • STRIPS operator: A C B Then, move(A,C,Fl) or move(A,C,B), etc.
B A C A C B STRIPS applied to the Blocks World move(B, A, Fl) Delete List Add List Effect Unchanged New State
A B C A B C A C B STRIPS Algorithm: Forward Search move(A,C,Fl) move(A,C,B) move(B, A, Fl)
STRIPS algorithm • Forward search (progression planning) with a divide-and conquer heuristic. • Solve conjunctive goal literals, one at a time. • Based on the General Problem Solver (GPS) developed by Newell, Shaw, and Simon in 1959 • Technique to solve goal literal called Means-end analysis.
B A C Apply STRIPS algorithm Initial State: Goal State: C B A No initial state description meets goal constructs. Divide and conquer: choose as initial goal. move(A,x,Fl) has On(A,Fl) in its add list. Call STRIPS recursively to achieve its preconditions: Make substitution C/x, which makes all but Clear(A) satisfied by initial state
C B A B A C Apply STRIPS algorithm Initial State: Goal State: Call STRIPS again (recursively) to solve Clear(A) Use operator move(y,A,u) Precondition: Continue this process and solve the problem.
A C B C B A A B C B A C Apply STRIPS Algorithm substitution C/x substitution Fl/z substitution B/y, Fl/u What sequence of operators solves problem? Can be extracted from problem trace
STRIPS algorithm STRIPS () -- is conjunctive goal formula Uses global data structure, S, consisting of a set of ground literals – initial state description. • Repeat (iterative main loop continues till state description = ) Termination in step 9 produces a substitution , such that some conjuncts (possibly none) of appear in S. Several substitutions can be tried in performing the test, so this is possible backtracking point. • g an element of , such that Sg. In means-end analysis terms g is regarded as “difference” that must be “reduced” to achieve the goal. (Backtracking point). • f STRIPS rule whose add list contains the literal, , that unifies with g using unifier s. f is an operator that is relevant to reducing the difference. More than one choice of f : backtracking point. • f’ fs. This is an instance of f after substitution s. f’ can contain variables (is not a ground instance). • p precondition formula for f’ (instantiated with the substitution s). • STRIPS(p). Recursive call with new sub-goal. • f’’ a ground instance of f’ applicable in S • S result of applying f’’ to S. • untilS= . (This test is always against the entire goal ).
C A B A B C STRIPS Planning can run into problems • Example: Sussman Anomaly Initial State: Goal condition: Question: Can STRIPS solve this problem? If not why not? Divide and conquer approach: First solve: then What happens? Problem of focusing narrowly on one conjunct at a time
C A B A B C B C A Sussman Anomaly
B A C C B C A A B Sussman Anomaly: Solve by changing goal order Again a previous goal is undone. Can this be avoided?
Sussman Anomaly (notes) • STRIPS can generate a plan for Sussman anomaly situations but has to undo a goal condition to satisfy the other goal condition. • There is no way STRIPS can avoid this, irrespective of which goal condition it starts of with first.
Backward Search • Search backwards from goal states. • Also known as regression planning. • Considers only relevant actions. • Asks: “What are the states from which applying a given action leads to the goal?” • What does this consideration imply about the search space? • Any action that does not undo a desired literal is consistent. • All actions must be consistent.
A B C Regression Planning • Regress goal conditions through STRIPS rules to produce subgoal conditions. • What about backward search with variables? Initial State:
A B C Regression Planning Initial State: • Why move A from floor to B? • So why make commitment? • Principle: Least Commitment Planning • Regress goal through partially instantiated operators • Makes backward search complicated, but avoids problems, such as Sussman Anomaly
On(C,FL) On(B,C) Clear(B) Clear(A) On(A,x) (x=B) (x=A) (x=C) On(C,FL) Clear(B) Clear(A) (y=B) (y=A) (y=C) On(A,x) On(B,y) (x=B) (x=A) (x=C) Regression Planning Move(B,z,C) On(C,FL) On(B,C) On(A,B) Goal State Move(B,y,C) Move(A,x,B) Substitution: FL/x, FL/y On(C,FL) Clear(B) Clear(A) Clear(C) On(A,FL) On(B,FL) On(C,FL) Clear(B) Clear(C) On(A,B) On(B,FL) Move(A,B,FL) Initial State
Total Order • Forward and backward searches discussed are Total Order searches. • Strictly linear sequence of actions from start to goal states. • Does not permit independent sub-goal problem solving. • Is this realistic for real world problems? • How do we deal with these issues?
Partial Order Planning • Partial Order Planning • Allows planning for multiple independent sub-goals. • The subplans are then combined to form a complete plan. • Allows one to solve obvious and important decisions first. • “Any planner that can place two actions into a plan without specifying which comes first is a partial order planner.”
Partial Order Planning Components • Each POP has four components • The plan action steps. • The ordering constraintsdetermine in what order steps are to be executed. • Ordering constraints that create cycles are not added to plans. • Fewer ordering constraints simplify plan construction.
Partial Order Planning Components • POP Components cntd. • A set of causal links indicates what assertions must be true between two actions. • “A achieves p for B.” • p must be true from the time A is completed and B starts. • The set of open preconditions contains all preconditions that have not yet been achieved by an action in the plan. • Planners attempt to empty the set while not introducing contradictions.
Consistency • A consistent plan contains no cycles in the ordering constraints and no conflicts with the causal links. • A solution is a consistent plan with an empty precondition set.
s0 s1 s2 Plan Spaces • Introduce the notion of plan space search Incomplete Plan Incomplete Plan State Space Search: STRIPS operators applied to set of formulas Incomplete Plan Plan Space Search: Plan transformation operators applied to partial plans
Plan Transformations • Potential plan transformations • Adding steps to the plan. • Reordering existing plan steps. • Changing a POP into a fully-ordered plan. • Changing the plan schema (with instantiated variables) into some instance of that schema. • Plan Transformations are considered actions in the search, NOT actions on the world.
move(A,x,B) Add an operator move(A,x,B) Reorder operators move(A,x,B) move(A,C,B) Plan Transformation Let’s see if this helps us solve problems like Sussman’s anomaly Instantiate an Operator
STRIPS rule: Graphical Representation on(x,z) clear(y) Add List move(x,y,z) Action/Operator on(x,y) clear(x) clear(z) Preconditions
Partial Order Planning (POP) Start with the start and finish rules Plan incomplete: apply plan transformation operators
Step 1: Add a rule no commitment from where A is being moved ? ? What next? (i) link the Clear(B)’s (ii) instantiate y to Fl so that on(A,y) can be connected to On(A,Fl) (iii) Try and satisfy Clear(A)
Step 2: Add a rule Next: solve this goal move(u,A,v) All instantiations performed, so preconditions of all rules Satisfied Implied ordering: b before a (b < a)
Step 3: Add a rule move(B,z,C) Instantiate z to Fl We know: b before a (b < a) What about c? Currently no commitment – plan is partially ordered
Step 4: Look for threat arcs Two threat arcs in this plan Order operators to avoid clobbering c <a and b < c Also, from graph it is clear that b < a Therefore, we can derive The total order: b < c < a
Advantages/Disadvantages • Advantage: • POP is able to decompose problems into subproblems. • Disadvantage: • POP does not directly represent states • It is harder to determine how close the POP is to achieving the goal.