Lecture slides for Automated Planning Theory and Practice

  • Slides: 25
Download presentation
Lecture slides for Automated Planning: Theory and Practice Chapter 4 State-Space Planning Dana S.

Lecture slides for Automated Planning: Theory and Practice Chapter 4 State-Space Planning Dana S. Nau CMSC 722, AI Planning University of Maryland, Fall 2004 Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 1

Motivation Nearly all planning procedures are search procedures l Different planning procedures have different

Motivation Nearly all planning procedures are search procedures l Different planning procedures have different search spaces u Two examples: l State-space planning u Each node represents a state of the world » A plan is a path through the space l Plan-space planning u Each node is a set of partially-instantiated operators, plus some constraints » Impose more and more constraints, until we get a plan l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 2

Outline l State-space planning u Forward search u Backward search u Lifting u STRIPS

Outline l State-space planning u Forward search u Backward search u Lifting u STRIPS u Block-stacking Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 3

Forward Search take c 3 take c 2 move r 1 … … Dana

Forward Search take c 3 take c 2 move r 1 … … Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 4

Properties l l is sound u for any plan returned by any of its

Properties l l is sound u for any plan returned by any of its nondeterministic traces, this plan is guaranteed to be a solution Forward-search also is complete u if a solution exists then at least one of Forward-search’s nondeterministic traces will return a solution. Forward-search Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 5

Deterministic Implementations Some deterministic implementations s 1 a 1 s 4 of forward search:

Deterministic Implementations Some deterministic implementations s 1 a 1 s 4 of forward search: a 4 u breadth-first search s 0 sg s 2 a 2 u best-first search s 5 … a 5 u depth-first search a 3 s 3 u greedy search l Breadth-first and best-first search are sound and complete u But they usually aren’t practical because they require too much memory u Memory requirement is exponential in the length of the solution l In practice, more likely to use a depth-first search or greedy search u Worst-case memory requirement is linear in the length of the solution u Sound but not complete » But classical planning has only finitely many states » Thus, can make depth-first search complete by doing loop-checking l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 6

Branching Factor of Forward Search a 1 a 2 a 3 initial state …

Branching Factor of Forward Search a 1 a 2 a 3 initial state … a 50 a 3 goal Forward search can have a very large branching factor (see example) l Why this is bad: u Deterministic implementations can waste time trying lots of irrelevant actions l Need a good heuristic function and/or pruning procedure u See Section 4. 5 (Domain-Specific State-Space Planning) and Part III (Heuristics and Control Strategies) l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 7

Backward Search For forward search, we started at the initial state and computed state

Backward Search For forward search, we started at the initial state and computed state transitions u new state = (s, a) l For backward search, we start at the goal and compute inverse state transitions u new set of subgoals = -1(g, a) l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 8

Inverse State Transitions What do we mean by -1(g, a)? l First need to

Inverse State Transitions What do we mean by -1(g, a)? l First need to define relevance: u An action a is relevant for a goal g if » a makes at least one of g’s literals true • g effects(a) ≠ » a does not make any of g’s literals false • g+ effects–(a) = • g– effects+(a) = l If a is relevant for g, then u -1(g, a) = (g – effects(a)) precond(a) l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 9

g 4 a 4 g 1 g 2 s 0 g 5 a 1

g 4 a 4 g 1 g 2 s 0 g 5 a 1 a 2 a 5 g 3 g 0 a 3 Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 10

Efficiency of Backward Search a 1 a 2 a 3 … a 3 a

Efficiency of Backward Search a 1 a 2 a 3 … a 3 a 50 goal initial state Backward search’s branching factor is small in our example l There are cases where it can still be very large u Many more operator instances than needed l p(a, a) foo(x, y) precond: p(x, y) effects: q(x) foo(a, a) p(a, b) foo(a, b) p(a, c) foo(a, c) q(a) … Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 11

Lifting p(a, a) foo(x, y) precond: p(x, y) effects: q(x) foo(a, a) p(a, b)

Lifting p(a, a) foo(x, y) precond: p(x, y) effects: q(x) foo(a, a) p(a, b) foo(a, b) p(a, c) q(a) foo(a, c) … l Can reduce the branching factor if we partially instantiate the operators u this is called lifting foo(a, y) p(a, y) q(a) Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 12

Lifted Backward Search More complicated than Backward-search u Have to keep track of what

Lifted Backward Search More complicated than Backward-search u Have to keep track of what substitutions were performed l But it has a much smaller branching factor l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 13

The Search Space is Still Too Large l Lifted-backward-search generates a smaller search space

The Search Space is Still Too Large l Lifted-backward-search generates a smaller search space than Backward-search, but it still can be quite large u If some subproblems are independent and something else causes problems elsewhere, we’ll try all possible orderings before realizing there is no solution u More about this in Chapter 5 (Plan-Space Planning) a b b a a c b c goal b a Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 14

Other Ways to Reduce the Search l Search-control strategies u I’ll say a lot

Other Ways to Reduce the Search l Search-control strategies u I’ll say a lot about this later » Part III of the book u For now, just two examples » STRIPS » Block stacking Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 15

STRIPS π the empty plan l do a modified backward search from g u

STRIPS π the empty plan l do a modified backward search from g u instead of -1(s, a), each new set of subgoals is just precond(a) u whenever you find an action that’s executable in the current state, then go forward on the current search path as far as possible, executing actions and appending them to π u repeat until all goals are satisfied l π = a 6, a 4 s = ( (s 0, a 6), a 4) g 6 satisfied in s 0 a 6 g 3 a 4 g 5 g 1 a 1 g 2 a 5 current search path g 3 g a 3 Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 16

Quick Review of Blocks World unstack(x, y) Pre: on(x, y), clear(x), handempty Eff: ~on(x,

Quick Review of Blocks World unstack(x, y) Pre: on(x, y), clear(x), handempty Eff: ~on(x, y), ~clear(x), ~handempty, holding(x), clear(y) stack(x, y) Pre: holding(x), clear(y) Eff: ~holding(x), ~clear(y), on(x, y), clear(x), handempty pickup(x) Pre: ontable(x), clear(x), handempty Eff: ~ontable(x), ~clear(x), ~handempty, holding(x) putdown(x) Pre: holding(x) Eff: ~holding(x), ontable(x), clear(? x), handempty c a b c a c b b Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 17

The Sussman Anomaly a c a b b Initial state l c goal On

The Sussman Anomaly a c a b b Initial state l c goal On this problem, STRIPS can’t produce an irredundant solution u Try it and see Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 18

The Register Assignment Problem l l State-variable formulation: Initial state: {value(r 1)=3, value(r 2)=5,

The Register Assignment Problem l l State-variable formulation: Initial state: {value(r 1)=3, value(r 2)=5, value(r 3)=0} Goal: {value(r 1)=5, value(r 2)=3} Operator: assign(r, v, r’, v’) precond: value(r)=v, value(r’)=v’ effects: value(r)=v’ STRIPS cannot solve this problem at all Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 19

How to Fix? l Several ways: u Do something other than state-space search »

How to Fix? l Several ways: u Do something other than state-space search » e. g. , Chapters 5– 8 u Use forward or backward state-space search, with domainspecific knowledge to prune the search space » Can solve both problems quite easily this way » Example: block stacking using forward search Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 20

Domain-Specific Knowledge A blocks-world planning problem P = (O, s 0, g) is solvable

Domain-Specific Knowledge A blocks-world planning problem P = (O, s 0, g) is solvable if s 0 and g satisfy some simple consistency conditions » g should not mention any blocks not mentioned in s 0 » a block cannot be on two other blocks at once » etc. • Can check these in time O(n log n) l If P is solvable, can easily construct a solution of length O(2 m), where m is the number of blocks u Move all blocks to the table, then build up stacks from the bottom » Can do this in time O(n) l With additional domain-specific knowledge can do even better … l Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 21

Additional Domain-Specific Knowledge l A block x needs to be moved if any of

Additional Domain-Specific Knowledge l A block x needs to be moved if any of the following is true: u s contains ontable(x) and g contains on(x, y) u s contains on(x, y) and g contains ontable(x) u s contains on(x, y) and g contains on(x, z) for some y≠z u s contains on(x, y) and y needs to be moved e c a b d d initial state goal Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 22

Domain-Specific Algorithm loop if there is a clear block x such that x needs

Domain-Specific Algorithm loop if there is a clear block x such that x needs to be moved and x can be moved to a place where it won’t need to be moved then move x to that place else if there is a clear block x such that x needs to be moved then move x to the table else if the goal is satisfied then return the plan a else return failure d b repeat e c c a b d initial state Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ goal 23

Easily Solves the Sussman Anomaly loop if there is a clear block x such

Easily Solves the Sussman Anomaly loop if there is a clear block x such that x needs to be moved and x can be moved to a place where it won’t need to be moved then move x to that place else if there is a clear block x such that x needs to be moved then move x to the table else if the goal is satisfied then return the plan else return failure a repeat c a b initial state Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ b c goal 24

Properties l The block-stacking algorithm: u Sound, complete, guaranteed to terminate u Runs in

Properties l The block-stacking algorithm: u Sound, complete, guaranteed to terminate u Runs in time O(n 3) » Can be modified to run in time O(n) u Often finds optimal (shortest) solutions u But sometimes only near-optimal (Exercise 4. 22 in the book) » Recall that PLAN LENGTH is NP-complete Dana Nau: Lecture slides for Automated Planning Licensed under the Creative Commons Attribution-Non. Commercial-Share. Alike License: http: //creativecommons. org/licenses/by-nc-sa/2. 0/ 25