Chap 11: Planning Administrivia: Please pick up homework 6 if you haven't already. Solutions to midterm will be available after class. 1.A simple planning agent Planning agent: like problem solving agent, constructs plans & executes them. Special cases: Infeasible goals (choose a new one) Already satisfied goals 2.From Problem Solving to Planning Basic elements of a problem-solver: 1.representation of actions (generation of successor states) 2.representation of states: complete description of initial state and all others, 3.representation of goals: only have test & heuristic fncs 4.representation of plans: only consider unbroken sequence of actions starting from start or goal state. Limitations of problem-solver: 1.Heuristic fnc can only choose among states to decide which is closer to goal, cannot eliminate actions from consideration. 2.Force to only consider starting from start state. Advantages of planner: 1.Make direct connection between states & actions (states & goals described by sets of sentences, actions by preconds and effects.) 2.Planner free to add actions wherever needed, instead of @ init state (By making obvious & important choices first, reduce backtracking.) 3.Solve by "divide-and-conquer feasible when 1.subgoals are independent 2.don't have to worry about some common resource like time or money 3.Planning in Situation Calculus Representation planning problems in situation calculus: 1.Initial state 2.Goal State 3.Operators Potential Problems: 1.exponential worst case time (esp w/only local info) 2.potential in-efficient plans To make feasible: 1.Restrict the lang. 2.Use special-purpose algorithm (planner instead of thm prover) 4.Basic Representation for Planning (STRIPS: STanford Research Institute Problem Solver) Representation for states: Conjunction of fnc-free ground literals (constants and negated constants) Not necessarily complete info. Maybe use "negation as failure". Representation for goals: Conjuction of literals. May contain vars (existentially quantified). May use implicit rep of states (keep track of changes) 'cuz most state info stays same. Representation actions: description (name), preconds, effects("add","delete" lists) Situation vars? Operator Schema: the class of ops that an action represents. Op is applicable if is some way to instantiate vars for preconds. Situation space = space of possible situations (what's a situation?) Progression = searching forward: init situation to goal sit. Regression = searching backward: goal situation to init sit. STRIPS is an example. Desirable 'cuz typical problems have goal state w/few conjuncts, but init state has many applicable ops. Could search thru plan space: Refinement: add constraints to a partial plan Modification: (anything that's not refinement), e.g. debugging plans. Principle of least commitment: Only make decisions about things currently care about (saves backtrack) Decisions that have to be made: (1) Orderings of steps (some = partial order, all = total order) (2) Instatiation of vars (all = fully instantiated plan) Parts of a plan: set of steps set of ordering constraints set of var. binding constraints. set of causal links: Si -c-> Sj "Si achieves c for Sj". Record purpose of steps in a plan (purpose of Si is to achieve precond c of Sj.) Initial plan: Two (null) steps: Start & finish w/constraint (StartStart has no preconds, effect is to add init state. Finish has goal as precond, no effects. Partial order allows planner to ignore orderings that don't matter Potential exponential savings. Solutions is partial order, why? That's the natural output of the planner. Gives the executor some freedom to parallelize. Gives us freedom to combine plan w/others later on. Complete plan = every precond achieved. Consistent plan = no contradictions in ordering or var. bindings. 5.A Partial Order Planning Example Dark arcs = causal links lite arcs = ordering constraints. Have to "Protect" causal links from "Threats" that mite "Clobber" achieved preconditions. Demotion: put clobberer before step that set precond. Promotion: put clobberer after step that needs set precond. 6.Partial Order Planning Algorithm 7.Planning w/Partially Instantiated Ops Ways to deal w/threat: 1.Resolve now w/an equality constraint. 2.Resolve now w/an inequality constraint. 3.Resolve later Planning versus search Planning is often better than search in situations where the problem can be broken down into subgoals which are nearly independent. Examples: Tying your shoes Shopping Solving blocksworld problems Planning algorithms usually use a variant of FOL (or a subset) to represent states, goals and the preconditions and effects of actions. This makes it easy to represent states where not everything is known-- whole sets of states. This, in turn, makes it possible to find a plan by making the most obvious or important decisions first. So even though planners may use a variant of FOL, they are more powerful than using the situation calculus and a resolution theorem prover. Finally, since divide-and-conquer is usually faster than trying to solve the whole problem at once, the independence of different parts of the world makes planning more efficient than general search. Representations for planning: STRIPS Let's consider a blocksworld problem. Block B is on the table (T) and block C is on block A. The goal is A on B on C. (Refer to slide of problem.) States are represented by conjunctions of function-free ground literals. Goals in the STRIPS language are represented by conjunctions of function-free literals. So the initial state would be: On(B,T), On(A,T), On(C,A), Clear(C), Clear(B), ... The goal state might be: On(A,B), On(B,C), On(C,x) The variables in the goal are assumed to be existentially quantified, and a goal given to a planner asks for a sequence of actions that makes the goal true if executed. Actions in STRIPS are represented by operators. They consist of three parts: action description--a name for the action precondition--a conjunction of positive literals that must be true before the operator can be applied effect--a conjunction of literals that describes what changes when the operator is applied (See slides for examples of the two operators needed for the blocksworld problem.) For now we restrict the precondition to be a conjunction of positive literals and the effect to a conjunction of literals. The variables are all assumed to be universally quatified. These restrictions are relaxed in chapter 12. An operator o is applicable in state s if there is some way to instantiate the variables in o so that every one of its preconditions is true in s. In the resulting state, all the positive literals in Effect(o) hold, as do all the literals that held in s except for those negative literals in Effect(o). Plans in STRIPS are represented by a data structure with four components: A set of plan steps. Each step is an operator. A set of ordering constraints. These say which steps must occur prior to another step: S3 < S2 means that step S3 must occur some time before S2. A set of variable binding constraints. These tell how variables must be bound, either to a constant or another variable. A set of causal links. These record which steps in the plan are necessary to achieve the precondition for some other step(s). There are two special operators called Start and Finish. Plans always start out like this: Plan( STEPS:{ S1: Op(ACTION:Start, PRE:{}, EFFECT:initial state), S2: Op(ACTION:Finish, PRE:goal, EFFECT:{})}, ORDERINGS: {S1 < S2}, BINDINGS: {}, LINKS: {} ) We will represent causal links by blue arrows. We will show orderings using black arrows. (See set of slides for solution to the blocksworld problem.) The final plan for this problem might be: Plan( STEPS:{ S1: Op(ACTION:Start, PRE:{}, EFFECT:initial state), S2: Op(ACTION:Finish, PRE:goal, EFFECT:{}), S3: Op(ACTION:MoveToTable(b,A), PRE:..., EFFECT:...), S4: Op(ACTION:Move(A,x,B), PRE:..., EFFECT:...), S5: Op(ACTION:Move(B,x',C), PRE:..., EFFECT:...), ORDERINGS: {S1 < S3, S1 < S2, S3 < S4, S4 < S2, S5 < S2}, BINDINGS: {x=T, x'=T, b=C}, LINKS: {...} )