Artificial Intelligence University Politehnica of Bucharest 2008 2009
Artificial Intelligence University Politehnica of Bucharest 2008 -2009 Adina Magda Florea http: //turing. cs. pub. ro/aifils_08
Lecture No. 9 Automatic planning (AP) n n n AP – features Linear planning in STRIPS Nonlinear planning in TWEAK Hierarchical planning Contingency planning 2
1. AP - features Common sense reasoning: n Frame problem, qualification problem, ramification problem Decomposing problems into sub-problems Planning n linear n non-linear n hierarchical n contingency 3
AP - features - cont n n Representing knowledge in planning problems Representing the states during search 4
2. Linear planning in STRIPS n Plan operators - Action (name + params) - Preconditions (LP) - Additions (LA) - Eliminations (LE) 5
2. 1 STRIPS representation n Plan operators STACK(x, y), UNSTACK(x, y), PICKUP(x), PUTDOWN(x) n n Predicates: ON(x, y), ONTABLE(x), CLEAR(x), HOLD(x), ARMEMTY Axioms: 6
STRIPS representation - cont n Plan operators LP: LE: CLEAR(y)HOLD(x) LA: ON(x, y)ARMEMPTY LP: LE: LA: PICKUP(x) LE: LA: PUTDOWN (x) LE: LA: LP: 7
2. 2 Plan execution 8
2. 3 STRIPS - functionning ARMEMPTY Stack 1 Stack 2 9
STRIPS - functionning - cont /* for goal ON(C, A) */ /* preconditions of STAC(C, A)*/ 10
2. 4 Algorithm of STRIPS n n S – variable – the current description of state; Stack – stack of satisfied goals on the current search path; Goals – list of unsatisfied goal on the current search path Structure Operator with fields: Action, Preconditions, Add. List si Delete. List (Operator. Preconditions) 11
2. 4 Algorithm of STRIPS Algorithm: Linear Planning in STRIPS Satisfy. Goals (Goals, S, Stack) 1. for every Goal in Goals do 1. 1. New. State Achieve. Goal(Goal, S, Stack) 1. 2. if New. State = FAIL then return FAIL 2. if all goals in Goals are satisfied in state New. State then return New. State 3. else return FAIL end. 12
Algorithm of STRIPS - cont Achieve. Goal (Goal, S, Stack) 1. if Goal is marked as satisfied in state S then return S 2. if Goal belongs to Stack then return FAIL 3. Valid. Operators {O | O can satisfy goal Goal} 4. for every operator O in Valid. Operators do 4. 1. New. State Apply. Operator(O, S, Stack {Goal}) 4. 2. if New. State <> FAIL then 4. 2. 1. 4. 2. 2. 5. return FAIL end. Mark goal Goal as satisfied in state New. State return New. State 13
Algorithm of STRIPS - cont Apply. Operator (Operator, State, Stack) 1. New. State Satisfy. Goals(Operator. Preconditions, State, Stack) 2. if New. State <> FAIL then 2. 1. Add Operator. Action to plan 2. 2. New. State – Operator. Delete. List 2. 3. return New. State Operator. Add. List 3. then return FAIL end. 14
2. 5 Sussman's anomaly ARMEMPTY Stack 1 Stack 2 15
Sussman's anomaly - cont Stack 1 16
3. Nonlinear planning - TWEAK n n n Constraints posting (temporal, unification/codesignation) Level of plan representation; Level of plan modification to obtain a plan that solves the problem 17
3. 1 TWEAK representation Actiune Action Preconditii: Preconditions Postconditii: Postconditions Actiune: Action Preconditii: Preconditions Postconditii: Postconditions PICKUP(x) 18
3. 2 Plan synthesis Operations for plan modification: (1) adding steps; (2) promotion; (3) simple binding; (4) separation; (5) removing destructivity - insert S 3 (existing or new) between S 1 and S 2 (S 1 a threat for S 2). 19
Plan synthesis - cont ARMEMPTY ARMEMTY 20
Plan synthesis - cont *ARMEMTY HOLD(A) HOLD(B) 1. 2. 3. 4. 5. 6. UNSTACK (C, A) PUTDOWN (C) PICKUP (B) STACK (B, C) PICKUP (A) STACK (A, B) } 21
3. 3 Algorithm in TWEAK Algoritm: Nonlinear planning in TWEAK 1. Initialize Plan {} 2. Initialize S with the set of formulas defining the goal state 3. while S <> {} do 3. 1. Pick a formula F and remove it from S 3. 2. if F is not satisfied in the current state then 3. 2. 1. Choose a plan modifying operation 3. 2. 2. Apply operation and add its effect to Plan 22
Algorithm in TWEAK - cont 3. 3. Verify for every step in Plan if the preconditions are satisfied 3. 4. for every unsatisfied condition of a step in Plan do Add precondition to S 4. Generate the total order of the elements in Plan based on individual order relations 5. if Plan is a partial plan then 5. 1. Instantiate the variables in Plan 5. 2. Arbitrarily transform the partial order in Plan in a total order end. 23
3. 4 A formal model for planning n n n A formula is true in a state S if it unifies with a formula in state S A plan step asserts a formula F in state S if F unifies with a postcondition of the plan step A plan step invalidates a formula F in state S if F unifies with a negated postcondition of the plan step A plan step may be executed only if all its preconditions are true in S After the execution of a plan step in a state S, all asserted formulas are added to S and all invalidated formulas are removed from S 24
A formal model for planning - cont Necessary truth criterion A formula P is necessarily true in a state S if and only if the following 2 conditions are met: (1) there is a state T equal to/or necessarily before state S in which P is necessarily asserted (added); (2) for every step C possibly to be executed before S and for every formula Q which can unify with P and is invalidated (made false) by C, there is a step W necessarily between C and S which asserts R, R being a formula for which R and P unifies whenever P and Q unifies. 25
A formal model for planning - cont Necessary truth criterion 26
4. Hierarchical planning Plans on different levels of abstraction n Abstract plans Scrie lucrare n Abstract operations Biblio …. . Editeaza continut Org. idei Gaseste editor Edit. text Edit. figuri Verifica erori 27
5. Contingency planning Start Finish On(Tire 1) Flat(Tire 1) Inflated(Spare) Flat(Tire 1) Intact(Tire 1) On(Tire 1) Inflated(Tire 1) Inflate(Tire 1) Intact(Tire 1) 28
Contingency planning - cont Start Finish On(Tire 1) Flat(Tire 1) Inflated(Spare) Flat(Tire 1) Intact(Tire 1) On(Tire 1) Inflated(Tire 1) Inflate(Tire 1) Intact(Tire 1) Check(Tire 1) ~Intact(Tire 1) Finish Remove(Tire 1) Put. On(Spare) ~Intact(Tire 1) On(Spare) Inflated(Spare) ~Intact(Tire 1) 29
- Slides: 29