Planning Points Elements of a planning problem Planning
Planning Points Elements of a planning problem Planning as resolution Conditional plans Actions as preconditions and effects Goal regression CSI 4106, Winter 2005 Planning, page 1
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. CSI 4106, Winter 2005 Planning, page 2
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, A 1, A 2 ). • 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? CSI 4106, Winter 2005 Planning, page 3
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). CSI 4106, Winter 2005 Planning, page 4
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). CSI 4106, Winter 2005 Planning, page 5
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, On. Tbl and Clear. Examples of actions: Stack, Unstack and No. Op. T( On. Tbl( 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( On. Tbl( x ), Do( Unstack( x, y ), s ) ) T( Clear( y ), Do( Unstack( x, y ), s ) ) T( p, s ) T( p, Do( No. Op, s ) ) CSI 4106, Winter 2005 Planning, page 6
Planning as resolution (2) On means “sitting on another block”. On. Tbl means “sitting on the table”. Some facts about this worlds are always true. For example: T( On. Tbl( 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 ) ) CSI 4106, Winter 2005 Planning, page 7
Planning as resolution (3) An initial state T( Clear( C ), S 0 ) T( On( C, A ), S 0 ) T( Clear( B ), S 0 ) T( On. Tbl( A ), S 0 ) T( On. Tbl( 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( On. Tbl( C ), S 1 ) S 0 C A CSI 4106, Winter 2005 S 1 B A B C Planning, page 8
Plan construction by resolution (a very simple example) Planning as resolution (4) We want to prove that T( On. Tbl( 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( , S 1 ) ), Do( , S 1 ) ) ), and so on. Let’s negate the fact that we want proven. T( On. Tbl( 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( On. Tbl( x ), Do( Unstack( x, y ), s ) ) CSI 4106, Winter 2005 Planning, page 9
Plan construction by resolution (continued) Planning as resolution (5) T( On. Tbl( A ), Do( , S 1 ) ) T( On. Tbl( 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 ) CSI 4106, Winter 2005 Planning, page 10
Conditional plans Let T( Clear( A ), S 2 ) be the only given fact. We can find a plan for the goal T( On. Tbl( 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. CSI 4106, Winter 2005 Planning, page 11
Conditional plans (2) ¬ T( On. Tbl( A ), Do( , S 2 ) ) Assume If( p, , ). ¬ T( On. Tbl( 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 On. Tbl( A ), s S 2 and get ¬ T( p, S 2 ), ¬ T( On. Tbl( A ), Do( , S 2 ) ) We need again that axiom for Unstack: T( On. Tbl( x ), Do( Unstack( x, y ), s ) ), T( On( x, y ), s ), T( Clear( x ), s ) CSI 4106, Winter 2005 Planning, page 12
Conditional plans (3) ¬ T( p, S 2 ), ¬ T( On. Tbl( A ), Do( , S 2 ) ) T( On. Tbl( 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 ). CSI 4106, Winter 2005 Planning, page 13
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( On. Tbl( A ), Do( , S 2 ) ) Resolve with q On. Tbl( A ), s S 2 and get T( p, S 2 ), ¬ T( On. Tbl( A ), Do( , S 2 ) ) CSI 4106, Winter 2005 Planning, page 14
Conditional plans (5) T( p, S 2 ), ¬ T( On. Tbl( A ), Do( , S 2 ) ) The clausal form of action No. Op: ¬ T( p, s ), T( p, Do( No. Op, s ) ) Assign p On. Tbl( A ), No. Op and get this: T( p, S 2 ), ¬ T( On. Tbl( A ), S 2 ) It is time to recall that useful fact [=] about On. Tbl: T( On. Tbl( 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) CSI 4106, Winter 2005 Planning, page 15
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, ), , No. Op ), S 2 ) We can finally put these partial plans together: Do( If( On( A, ), Unstack( A, ), No. Op ), S 2 ) CSI 4106, Winter 2005 Planning, page 16
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 ) ) = { On. Tbl( 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: { On. Tbl( A ), On. Tbl( B ) } CSI 4106, Winter 2005 Planning, page 17
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 . CSI 4106, Winter 2005 Planning, page 18
Goal regression (2) Example If we begin with { On. Tbl( A ), On. Tbl( B ) } we can “recreate” { Clear( A ), On( A, B ), On. Tbl( 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. CSI 4106, Winter 2005 Planning, page 19
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. Sinitial On( C, A ) On. Tbl( B ) Sfinal On( C, A ) On( A, B ) On( C, A ) is true in Sinitial 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. CSI 4106, Winter 2005 Planning, page 20
- Slides: 20