Planning, page 1 CSI 4106, Winter 2005 Planning Points Elements of a planning problem Planning as resolution Conditional plans Actions as preconditions and effects Goal regression
Planning, page 2 CSI 4106, Winter 2005 Elements of a planning problem When is a problem a good application for planning? It can be decomposed into subproblems in such a way that solving each subproblem (in some order) solves the whole problem. It is conjunctive, that is, it can be expressed as a conjunction of conditions, each representing an elementary aspect if the world, the initial situation, the final situation. Each subproblem can be reduced to facts about domain objects, and relations among such objects.
Planning, page 3 CSI 4106, Winter 2005 Elements of a planning problem (2) States, state spaces. Actions with preconditions and postconditions. An action is a function from states to states. It makes local changes that affect few objects. Actions are generic, facts are specific. Actions are elementary: one-step plans. A design decision: granularity of actions. Conditional actions: If( C, A1, A2 ). Frame axioms and the Closed World Assumption. The timing of actions: is a real-time plan needed, or do we only need a sequence of actions with relative time?
Planning, page 4 CSI 4106, Winter 2005 Elements of a planning problem (3) A plan is a sequence of actions that lead from an initial state to a goal state. In a linear plan, the actions required to solve a subproblem precede the actions required to solve the next subproblem. In a non-linear plan, actions for subproblems may be (or even may have to be) interleaved. Optimality of plans: a simple criterion is the number of actions. A plan may be executed either “in batch mode” (after the whole plan has been created), or with every action performed immediately (with feedback for more planning).
Planning, page 5 CSI 4106, Winter 2005 Elements of a planning problem (4) A formal representation of plans may look, for example, like this: Do( Action 3, Do( Action 2, Do( Action 1, init ) ) ) where init denotes an initial state. There are two ways of implementing state changes (we must be able to undo such changes, because planning algorithms usually backtrack). Explicit changes in the knowledge base. Implicit changes, not in the knowledge base but only in the plan representation, recomputed as needed (this is costly, but undoing is easier).
Planning, page 6 CSI 4106, Winter 2005 Planning as resolution The blocks world (find its description in any textbook ) T( p, s ) means "predicate p is true in state s" Elementary conditions: On, OnTbl and Clear. Examples of actions: Stack, Unstack and NoOp. T( OnTbl( x ), s ) T( Clear( x ), s ) T( Clear( y ), s ) x ≠ y T( On( x, y ), Do( Stack( x, y ), s ) ) T( On( x, y ), s ) T( Clear( x ), s ) T( OnTbl( x ), Do( Unstack( x, y ), s ) ) T( Clear( y ), Do( Unstack( x, y ), s ) ) T( p, s ) T( p, Do( NoOp, s ) )
Planning, page 7 CSI 4106, Winter 2005 Planning as resolution (2) On means “sitting on another block”. OnTbl means “sitting on the table”. Some facts about this worlds are always true. For example: T( OnTbl( x ), s ) y T( On( x, y ), s)[=] Frame axioms — two examples: T( Clear( u ), s ) u ≠ y T( Clear( u ), Do( Stack( x, y ), s ) ) T( On( u, w ), s ) u ≠ x T( On( u, w ), Do( Unstack( x, y ), s ) )
Planning, page 8 CSI 4106, Winter 2005 Planning as resolution (3) An initial state T( Clear( C ), S 0 )T( On( C, A ), S 0 ) T( Clear( B ), S 0 ) T( OnTbl( A ), S 0 )T( OnTbl( B ), S 0 ) Another (possibly final) state T( Clear( A ), S 1 )T( On( A, B ), S 1 ) T( On( B, C ), S 1 )T( OnTbl( C ), S 1 ) A B C S1S1 AB C S0S0
Planning, page 9 CSI 4106, Winter 2005 Planning as resolution (4) We want to prove that T( OnTbl( A ), t ) given S 1. We assume that we can do it in one action , so that state t should look like Do( , S 1 ). If this is not possible, we will try Do( , Do( , S 1 ) ), Do( , Do( , Do( , S 1 ) ) ), and so on. Let’s negate the fact that we want proven. T( OnTbl( A ), Do( , S 1 ) ) Action could be Unstack. That is because one of the clauses in its clausal-form definition is this: T( On( x, y ), s ), T( Clear( x ), s ), T( OnTbl( x ), Do( Unstack( x, y ), s ) ) Plan construction by resolution (a very simple example)
Planning, page 10 CSI 4106, Winter 2005 Planning as resolution (5) T( OnTbl( A ), Do( , S 1 ) ) T( OnTbl( x ), Do( Unstack( x, y ), s ) ), T( On( x, y ), s ), T( Clear( x ), s ) This gives T( On( A, y ), S 1 ), T( Clear( A ), S 1 ) after assigning x A, s S 1, Unstack( A, y ). This is given: T( On( A, B ), S 1 ). We resolve and get T( Clear( A ), S 1 ) with y B. This too is given: T( Clear( A ), S 1 ). so we produce the empty resolvent: done. t Do( , S 1 ) = Do( Unstack( A, B ), S 1 ) Plan construction by resolution (continued)
Planning, page 11 CSI 4106, Winter 2005 Conditional plans Let T( Clear( A ), S 2 ) be the only given fact. We can find a plan for the goal T( OnTbl( A ), Do( , S 2 ) ) even though the problem is under-constrained. Axioms for conditional actions T( p, s ) T( q, Do( , s ) ) T( q, Do( If( p, , ), s ) ) ¬ T( p, s ) T( q, Do( , s ) ) T( q, Do( If( p, , ), s ) ) Again, we begin by assuming a one-step plan, but now it will be a conditional plan.
Planning, page 12 CSI 4106, Winter 2005 Conditional plans (2) ¬ T( OnTbl( A ), Do( , S 2 ) ) Assume If( p, , ). ¬ T( OnTbl( A ), Do( If( p, , ), S 2 ) ) The first axiom as a clause:[+] T( q, Do( If( p, , ), s ) ), ¬ T( p, s ), ¬ T( q, Do( , s ) ) Resolve with q OnTbl( A ), s S 2 and get ¬ T( p, S 2 ), ¬ T( OnTbl( A ), Do( , S 2 ) ) We need again that axiom for Unstack: T( OnTbl( x ), Do( Unstack( x, y ), s ) ), T( On( x, y ), s ), T( Clear( x ), s )
Planning, page 13 CSI 4106, Winter 2005 Conditional plans (3) ¬ T( p, S 2 ), ¬ T( OnTbl( A ), Do( , S 2 ) ) T( OnTbl( x ), Do( Unstack( x, y ), s ) ), T( On( x, y ), s ), T( Clear( x ), s ) With x A, Unstack( A, y ), s S 2 we get ¬ T( p, S 2 ), T( On( A, y ), S 2 ), T( Clear( A ), S 2 ) We resolve this with our only fact: ¬ T( p, S 2 ), T( On( A, y ), S 2 )... and this is it. We need something new to move on. One possibility is factoring: look for matching literals on the resolvent. Here we can assign p On( A, y ) and reduce the resolvent to T( On( A, y ), S 2 ).
Planning, page 14 CSI 4106, Winter 2005 Conditional plans (4) We can conclude the proof if we assume T( On( A, y ), S 2 ) Here, the conditional nature of the plan helps. We combine everything we have found so far. Our one-action plan looks like this: Do( If( On( A, y ), Unstack( A, y ), ), S 2 ) To also determine , we return to the point marked [+] and look at the second axiom for conditional actions: T( q, Do( If( p, , ), s ) ), T( p, s ), ¬ T( q, Do( , s ) ) ¬ T( OnTbl( A ), Do( , S 2 ) ) Resolve with q OnTbl( A ), s S 2 and get T( p, S 2 ), ¬ T( OnTbl( A ), Do( , S 2 ) )
Planning, page 15 CSI 4106, Winter 2005 Conditional plans (5) T( p, S 2 ), ¬ T( OnTbl( A ), Do( , S 2 ) ) The clausal form of action NoOp: ¬ T( p, s ), T( p, Do( NoOp, s ) ) Assign p OnTbl( A ), NoOp and get this: T( p, S 2 ), ¬ T( OnTbl( A ), S 2 ) It is time to recall that useful fact [=] about OnTbl: T( OnTbl( x ), s ) y T( On( x, y ), s) So, we can replace one side with the other: T( p, S 2 ), y T( On( A, y ), S 2 ) Skolemize ( is the Skolem constant): T( p, S 2 ), T( On( A, ), S 2 )
Planning, page 16 CSI 4106, Winter 2005 Conditional plans (6) T( p, S 2 ), T( On( A, ), S 2 ) We perform factorization, assigning p On( A, ): T( On( A, ), S 2 ) To conclude the second part of the proof, we assume T( On( A, ), S 2 ) Now, our one-action plan is either of these: Do( If( On( A, y ), Unstack( A, y ), ), S 2 ) Do( If( On( A, ), , NoOp ), S 2 ) We can finally put these partial plans together: Do( If( On( A, ), Unstack( A, ), NoOp ), S 2 )
Planning, page 17 CSI 4106, Winter 2005 Another representation of actions Preconditions of an action + facts added (made true) by this action + facts deleted (made false) by this action. Pre( Unstack( x, y ) )={ On( x, y ), Clear( x ) } Add( Unstack( x, y ) )={ OnTbl( x ), Clear( y ) } Del( Unstack( x, y ) )={ On( x, y ) } The Closed World Assumption serves as the frame axiom: facts not on the Add list and on the Del list are by default preserved. A state is represented as a set of facts, for example: { OnTbl( A ), OnTbl( B ) }
Planning, page 18 CSI 4106, Winter 2005 Goal regression Reduce one of the goals to its subgoal or subgoals. This means working backward from a state to a state by looking at the preconditions and effects of some action. Let Regr( q, ) be a state achieved by regression from q through (“undoing” the effects of ). cannot delete a fact that must be true in q: q Del( ) = Ø If has this property, we can define: Regr( q, ) = Pre( ) (q — Add( ) ) So: keep the preconditions of , undo the effects of .
Planning, page 19 CSI 4106, Winter 2005 Goal regression (2) Example If we begin with { OnTbl( A ), OnTbl( B ) } we can “recreate” { Clear( A ), On( A, B ), OnTbl( B ) } by regression through Unstack( A, B ). Protection violation Actions for a subproblem must not undo the effects of earlier actions for already solved subproblems.
Planning, page 20 CSI 4106, Winter 2005 A planning strategy for conjunctive problems Going left to right, make a plan for each conjunct and freeze the effects (put the added or preserved goals on a list of protected goals). This simple method is weak. It will not work even for the following trivial problem. S initial On( C, A ) OnTbl( A ) OnTbl( B ) S final On( C, A ) On( A, B ) On( C, A ) is true in S initial and must be protected. But: it must be temporarily destroyed to achieve On( A, B ). Goal protection makes planning impossible. Here, rearrangement helps: On( A, B ) On( C, A ) “works”. In general non-linear planning is necessary. One such a smarter planner is Warplan.Warplan