artificialintelligence(künstlicheintelligenz)1 … · 2020-05-05 · 10 nov. 14....
TRANSCRIPT
1
Artificial Intelligence (Künstliche Intelligenz) 1Winter Semester 2019/20
– Lecture Notes –Part IV: Planning and Acting
Prof. Dr. Michael Kohlhase
Professur für Wissensrepräsentation und -verarbeitungInformatik, FAU Erlangen-Nürnberg
May 5, 2020
2
This document contains Part IV of the course notes for the Lecture “Künstliche Intelligenz 1” heldat FAU Erlangen-Nürnberg in the Winter Semesters 2017/18 ff.
This part covers the AI subfield of “planning”, i.e. seach problem solving with a structured repre-sentation language for environment state and actions – In planning, the focus is on the latter.
Other parts of the lecture notes can be found at http://kwarc.info/teaching/AI/notes-*.pdf.
Recorded Syllabus Winter Semester 2019/20:
# date until slide page1 Oct 15. admin, what is AI? AI components, AI exists!2 Oct 17. strong/narrow AI, KWARC topics3 Oct 22. PROLOG4 Oct 24. PROLOG, Complexity, Agents5 Oct 29. Rationality, Environments, Agent Types6 Oct 31. Problem solving, uninformed search7 Nov. 5. Uninformed Search, heuristics8 Nov. 7. Informed Search, A∗,local search9 Nov. 12. Games, minimax, evaluation functions10 Nov. 14. alphabeta search, MCTS11 Nov. 19. CSP, Waltz Algorithm, Constraint Types12 Nov. 21 CSP as Search, Inference13 Nov. 26 CS Propagation, AC, decomposition14 Nov. 28. Wumpus & Propositional Logic15 Dec. 3. Propositional Calculi16 Dec 5. Propositional Tableaux17 Dec 10. Killing the Wumpus, DPLL18 Dec. 12. DPLL Conflict Graphs19 Dec. 17. Kalah Tournament20 Dec. 19. DPLL clause learning, phase transitions, PL1 motivation21 Jan. 7. First Order Syntax/Semantics22 Jan. 9. First Order Natural Deeudction23 Jan. 14. Free Variable Tableaux, Unification24 Jan. 16. Unification, Prolog as Resolution, Abduction, Induction25 Jan. 21. Knowledge Representation, semantic networks26 Jan. 23. Descriptionn Logics, ALC27 Jan 28. ALC & Semantic Web28 Jan 30. Intro to Planning, STRIPS29 Feb 4. planning by heuristic search 587 3630 Feb. 6. delete relaxation, conclusion
Contents
17 Planning I: Framework 517.1 Planning: Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.2 Planning History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1117.3 STRIPS Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1717.4 PDDL Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2217.5 Planning Complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2517.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
18 Planning II: Algorithms 3118.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3118.2 How to Relax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3318.3 Delete Relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4018.4 The h+Heuristic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4618.5 Planning Algorithms: Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
19 Planning and Acting in the Real World 5519.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5519.2 Agent Architectures based on Belief States . . . . . . . . . . . . . . . . . . . . . . . 5719.3 Conformant Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5919.4 Conditional Planning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
3
4 CONTENTS
Chapter 17
Planning I: Framework
17.1 Planning: Introduction
Reminder: Classical Search Problems ?search?
� States: Card positions (e.g. position_Jspades=Qhearts).
� Actions: Card moves (e.g. move_Jspades_Qhearts_freecell4).
� Initial state: Start configuration.
� Goal states: All cards “home”.
� Solutions: Card moves solving this game.
©:Michael Kohlhase 523
Planning
� Ambition: Write one program that can solve all classical search problems.
� Reminder: (see ?search?)
� The blackbox description of a problem Π is an API (a programming inter-face) providing functionality allowing to construct the state space: InitialState(),
5
6 CHAPTER 17. PLANNING I: FRAMEWORK
GoalTest(s), . . .
� “Specifying the problem” = programming the API.
� The declarative description of Π comes in a problem description language.This allows to implement the API, and much more.
� “Specifying the problem” = writing a problem description.
� Here, “problem description language” = planning language.
©:Michael Kohlhase 524
How does a planning language describe a problem?
� A logical description of the possible states (vs. Blackbox: data structures).(E.g.: predicate Eq(., .).)
� A logical description of the initial state I (vs. data structures). (E.g.:Eq(x, 1).)
� A logical description of the goal condition G (vs. a goal-test function). (E.g.:Eq(x, 2).)
� A logical description of the set A of actions in terms of preconditions and effects(vs. functions returning applicable actions and successor states). (E.g.:“increment x: pre Eq(x, 1), eff Eq(x, 2) ∧ ¬Eq(x, 1)”.)
� Solution (plan) = sequence of actions from A, transforming I into a state thatsatisfies G. (E.g.: “increment x”.)
©:Michael Kohlhase 525
Planning Language Overview
� Disclaimer: Planning languages go way beyond classical search problems. Thereare variants for inaccessible, stochastic, dynamic, continuous, and multi-agentsettings.
� We focus on classical search for simplicity (and practical relevance).
� For a comprehensive overview, see [ghallab:etal:04].
©:Michael Kohlhase 526
Application: Natural Language Generation
17.1. PLANNING: INTRODUCTION 7
S:e
NP:r1 ↓ VP:e
sleeps
V:e
N:r1
rabbit
NP:r1the
N:r1white N:r1 *
S:e
VP:e
sleeps
V:e
rabbit
NP:r1
the N:r1
white
{sleep(e,r1)}
{white(r1)}{rabbit(r1)}
� Input: Tree-adjoining grammar, intended meaning.
� Output: Sentence expressing that meaning.
©:Michael Kohlhase 527
Application: Business Process Templates at SAP
Application: Business Process Templates at SAP
Create CQ
Check CQConsistency
Check CQCompleteness
Check CQ Approval Status
Decide CQ Approval
Submit CQ
Mark CQ as Accepted
Create Follow-Up for CQ
Archive CQ
Approval:Necessary
Approval: not
Necessary
I Input: SAP-scale model of behavior of activities on Business Objects, processendpoint.
I Output: Process template leading to this point.
Kohlhase: Künstliche Intelligenz 1 484 July 5, 2018
Application: Business Process Templates at SAP
Create CQ
Check CQConsistency
Check CQCompleteness
Check CQ Approval
Status
Decide CQ Approval
Submit CQ
Mark CQ as Accepted
Create Follow-Up for CQ
Archive CQ
Approval:Necessary
Approval: not
Necessary
I Input: SAP-scale model of behavior of activities on Business Objects, processendpoint.
I Output: Process template leading to this point.
Kohlhase: Künstliche Intelligenz 1 484 July 5, 2018
� Input: SAP-scale model of behavior of activities on Business Objects, processendpoint.
� Output: Process template leading to this point.
©:Michael Kohlhase 528
Application: Automatic Hacking
8 CHAPTER 17. PLANNING I: FRAMEWORK
RouterFirewall
DB Server
Workstation
DMZ
SENSITIVE USERS
Web Server Application Server
Internet
Attacker
RouterFirewall
DB Server
Workstation
DMZ
SENSITIVE USERS
Web Server Application Server
Internet
Attacker
RouterFirewall
DB Server
Workstation
DMZ
SENSITIVE USERS
Web Server Application Server
Internet
Attacker
RouterFirewall
DB Server
Workstation
DMZ
SENSITIVE USERS
Web Server Application Server
Internet
Attacker
� Input: Network configuration, location of sensible data.
17.1. PLANNING: INTRODUCTION 9
� Output: Sequence of exploits giving access to that data.
©:Michael Kohlhase 529
Reminder: General Problem Solving, Pros and Cons
� Powerful: In some applications, generality is absolutely necessary. (E.g. SAP)
� Quick: Rapid prototyping: 10s lines of problem description vs. 1000s lines ofC++ code. (E.g. language generation)
� Flexible: Adapt/maintain the description. (E.g. network security)
� Intelligent: Determines automatically how to solve a complex problem effec-tively! (The ultimate goal, no?!)
� Efficiency loss: Without any domain-specific knowledge about Chess, you don’tbeat Kasparov . . .
� Trade-off between “automatic and general” vs. “manual work but effective”.
Research Question: How to make fully automatic algorithms effective?
©:Michael Kohlhase 530
� ps. “Making Fully Automatic Algorithms Effective”
� Example 17.1.1
� n blocks, 1 hand.
� A single action either takes a block with the hand or puts a blockwe’re holding onto some other block/the table.
blocks states1 12 33 134 735 5016 40517 376338 394353
blocks states9 4596553
10 5894109111 82407314112 1247016223313 20297640121314 353501752440315 6557380318692116 1290434218669921
� Observation 17.1.2 State spaces typically are huge even for simple problems.
In other words: Even solving “simple problems” automatically (without help froma human) requires a form of intelligence.
�� With blind search, even the largest super-computer in the world won’t scalebeyond 20 blocks!
10 CHAPTER 17. PLANNING I: FRAMEWORK
©:Michael Kohlhase 531
Algorithmic Problems in Planning
� Definition 17.1.3 We speak of satisficing planning if
Input: A planning task Π.Output: A plan for Π, or “unsolvable” if no plan for Π exists.
and of optimal planning if
Input: A planning task Π.Output: An optimal plan for Π, or “unsolvable” if no plan for Π exists.
� The techniques successful for either one of these are almost disjoint. And sat-isficing planning is much more effective in practice.
� Definition 17.1.4 Programs solving these problems are called (optimal)planner, planning system, or planning tool.
©:Michael Kohlhase 532
Our Agenda for This Topic
� Now: Background, planning languages, complexity.
� Sets up the framework. Computational complexity is essential to distinguishdifferent algorithmic problems, and for the design of heuristic functions (seenext).
� Next: How to automatically generate a heuristic function, given planning lan-guage input?
� Focussing on heuristic search as the solution method, this is the main ques-tion that needs to be answered.
©:Michael Kohlhase 533
Our Agenda for This Chapter
1. The History of Planning: How did this come about?
� Gives you some background, and motivates our choice to focus on heuristicsearch.
2. The STRIPS Planning Formalism: Which concrete planning formalism will webe using?
� Lays the framework we’ll be looking at.
17.2. PLANNING HISTORY 11
3. The PDDL Language: What do the input files for off-the-shelf planning soft-ware look like?
� So you can actually play around with such software. (Exercises!)
4. Planning Complexity: How complex is planning?
� The price of generality is complexity, and here’s what that “price” is,exactly.
©:Michael Kohlhase 534
17.2 The History of Planning
Planning History: In the Beginning . . .
� In the beginning: Man invented Robots:
� “Planning” as in “the making of plans by an autonomous robot”.
� Shakey the Robot (Fulll video here)
� In a little more detail:
� [newell:simon:ct-63] introduced general problem solving.
� . . . not much happened (well not much we still speak of today) . . .
� Stanford Research Institute developed a robot named “Shakey”.
� They needed a “planning” component taking decisions.
� They took inspiration from general problem solving and theorem proving,and called the resulting algorithm “STRIPS”.
©:Michael Kohlhase 535
History of Planning Algorithms
� Compilation into Logics/Theorem Proving
� Popular when: Stone Age – 1990.
� Approach: From planning task description, generate PL1 formula ϕ that issatisfiable iff there exists a plan; use a theorem prover on ϕ.
� Keywords/cites: Situation calculus, frame problem, . . .
� Partial-Order Planning
� Popular when: 1990 – 1995.
� Approach: Starting at goal, extend partially ordered set of actions by insert-ing achievers for open sub-goals, or by adding ordering constraints to avoidconflicts.
12 CHAPTER 17. PLANNING I: FRAMEWORK
� Keywords/cites: UCPOP [penberthy:weld:kr-92], causal links, flaw-selection strategies, . . .
©:Michael Kohlhase 536
History of Planning Algorithms, ctd.
� GraphPlan
� Popular when: 1995 – 2000.
� Approach: In a forward phase, build a layered “planning graph” whose “timesteps” capture which pairs of actions can achieve which pairs of facts; in abackward phase, search this graph starting at goals and excluding optionsproved to not be feasible.
� Keywords/cites: [blum:furst:ijcai-95; blum:furst:ai-97; koehler:etal:ecp-97],action/fact mutexes, step-optimal plans, . . .
� Planning as SAT
� Popular when: 1996 – today.
� Approach: From planning task description, generate propositional CNF for-mula ϕk that is satisfiable iff there exists a plan with k steps; use a SATsolver on ϕk, for different values of k.
� Keywords/cites: [kautz:selman:ecai-92; kautz:selman:aaai-96; rintanen:etal:ai-06;rintanen:cp-10], SAT encoding schemes, BlackBox, . . .
©:Michael Kohlhase 537
History of Planning Algorithms, ctd.
� Planning as Heuristic Search:
� Popular when: 1999 – today.
� Approach: Devise a method R to simplify (“relax”) any planning task Π;given Π, solve R(Π) to generate a heuristic function h for informed search.
� Keywords/cites: [bonet:geffner:ecp-99; haslum:geffner:aips-00; bonet:geffner:ai-01;hoffmann:nebel:jair-01; edelkamp:ecp-01; gerevini:etal:jair-03; helmert:jair-06;helmert:etal:icaps-07; helmert:geffner:icaps-08; karpas:domshlak:ijcai-09;helmert:domshlak:icaps-09; richter:westphal:jair-10; nissim:etal:ijcai-11;katz:etal:icaps-12; keyder:etal:icaps-12; katz:etal:icaps-13; domshlak:etal:ai-15],critical path heuristics, ignoring delete lists, relaxed plans, landmark heuris-tics, abstractions, partial delete relaxation, . . .
©:Michael Kohlhase 538
The International Planning Competition (IPC)
17.2. PLANNING HISTORY 13
� Competition?: (http://ipc.icaps-conference.org/) Run competingplanners on a set of benchmarks devised by the IPC organizers. Give awards tothe most effective planners.
� 1998, 2000, 2002, 2004, 2006, 2008, 2011, 2014
� PDDL [pddl-handbook; fox:long:jair-03; hoffmann:edelkamp:jair-05;gerevini:etal:ai-09]
� ≈ 50 domains, � 1000 instances, 74 (!!) planners in 2011
� Optimal track vs. satisficing track
� Various others: uncertainty, learning, . . .
©:Michael Kohlhase 539
IPC 2000: Competitors
� BlackBox: Compilation to SAT [kautz:selman:ijcai-99].
� HSP: Heuristic search [bonet:geffner:ai-01].
� IPP: GraphPlan variant [koehler:etal:ecp-97].
� STAN: Heuristic search.
� GRT: Heuristic search.
� Mips: Heuristic search.
� FF: Heuristic search [hoffmann:nebel:jair-01].
� ... (13 altogether)
©:Michael Kohlhase 540
IPC 2000: Benchmark Domains
� Blocksworld: Move around blocks on a table (yeah, I know).
� Freecell: The card game.
� Logistics: Transport packages using trucks and airplanes.
� Miconic-ADL: A complex elevator-control problem (see slide 573).
� Schedule: A simple scheduling problem where objects must be processed withvarious machines.
©:Michael Kohlhase 541
IPC’00 Results, Fully Automatic Track (Logistics)
14 CHAPTER 17. PLANNING I: FRAMEWORK
©:Michael Kohlhase 542
IPC’00 Results, Fully Automatic Track (Blocksworld)
©:Michael Kohlhase 543
IPC’00 Results, Fully Automatic Track (FreeCell)
17.2. PLANNING HISTORY 15
©:Michael Kohlhase 544
IPC’00 Results, Fully Automatic Track (Miconic)
©:Michael Kohlhase 545
IPC’00 Results, Fully Automatic Track (Schedule)
16 CHAPTER 17. PLANNING I: FRAMEWORK
©:Michael Kohlhase 546
And Since Then?
� Winners (what turned out to be successful)
� IPC 2000: Winner FF, heuristic search.
� IPC 2002: Winner LPG, heuristic search.
� IPC 2004: Winner satisficing SGPlan, heuristic search; optimal SATPLAN,compilation to SAT.
� IPC 2006: Winner satisficing SGPlan, heuristic search; optimal SATPLAN,compilation to SAT.
� IPC 2008: Winner satisficing LAMA, heuristic search; optimal Gamer, sym-bolic search.
� IPC 2011: Winner satisficing LAMA, heuristic search; optimal Fast-Downward,heuristic search.
� IPC 2014: Winner satisficing Mercury, heuristic search; optimal Symba,symbolic search.
� This is a VERY short summary of the history of the IPC! There are manydifferent categories, and many different awards.
� For the rest of this chapter, we focus on planning as heuristic search.
©:Michael Kohlhase 547
Questionnaire
� Question: If planners x and y compete in IPC’YY, and x wins, is x “betterthan” y?
� Answer: Yes, but only on the IPC’YY benchmarks, and only according to the
17.3. STRIPS PLANNING 17
criteria used for determining a “winner”! On other domains and/or according toother criteria, you may well be better off with the “looser”.
� Generally: Assessing AI System suitability is complicated, over-simplification isdangerous. (But, of course, nevertheless is being done all the time)
©:Michael Kohlhase 548
Planning History, p.s.
B
C
A
A B
C
“The Sussman Anomaly”
©:Michael Kohlhase 549
17.3 The STRIPS Planning Formalism
“STRIPS” Planning
� Definition 17.3.1 STRIPS = Stanford Research Institute Problem Solver.
STRIPS is the simplest possible (reasonably expressive) logics-basedplanning language.
� STRIPS has only Boolean variables: propositional logic atoms.
� Its preconditions/effects/goals are as canonical as imaginable:
� Preconditions, goals: conjunctions of positive atoms.
� Effects: conjunctions of literals (positive or negated atoms).
� We use the common special-case notation for this simple formalism.
� I’ll outline some extensions beyond STRIPS later on, when we discuss PDDL.
� Historical note: STRIPS [fikes:nilsson:ai-71] was originally a planner (cf.Shakey), whose language actually wasn’t quite that simple.
©:Michael Kohlhase 550
18 CHAPTER 17. PLANNING I: FRAMEWORK
STRIPS Planning: Syntax
� Definition 17.3.2 A STRIPS planning task, short planning task, is a quadru-ple Π = 〈P,A, I,G〉 where:
� P is a finite set of facts (aka propositions).
� A is a finite set of actions; each a ∈ A is a triple a = 〈prea, adda, dela〉 ofsubsets of P referred to as the action’s precondition, add list, and deletelist respectively; we require that adda ∩dela = ∅.
� I ⊆P is the initial state.
� G⊆P is the goal.
We will often give each action a ∈ A a name (a string), and identify a withthat name.
� Note: We assume, for simplicity, that every action has cost 1. (Unit costs, cf.?search?)
©:Michael Kohlhase 551
“TSP” in Australia
� Example 17.3.3 (Salesman Travelling in Australia)
Strictly speaking, this is not actually aTSP problem instance; simplified/adaptedfor illustration.
©:Michael Kohlhase 552
STRIPS Encoding of “TSP”
� Example 17.3.4 (continuing)
17.3. STRIPS PLANNING 19
� Facts P : {at(x), vis(x) |x ∈ {Sy,Ad,Br,Pe,Da}}.� Initial state I: {at(Sy), vis(Sy)}.� Goal G:{at(Sy)}∪ {vis(x) |x ∈ {Sy,Ad,Br,Pe,Da}}.� Actions a ∈ A: drv(x, y) where x and y have a road.Precondition prea: {at(x)}.Add list adda: {at(y), vis(y)}.Delete list dela: {at(x)}.
� Plan: 〈drv(Sy,Br), drv(Br, Sy), drv(Sy,Ad), drv(Ad,Pe), drv(Pe,Ad),drv(Ad,Da), drv(Da,Ad), drv(Ad, Sy)〉.
©:Michael Kohlhase 553
STRIPS Planning: Semantics
� Definition 17.3.5 Let Π = 〈P,A, I,G〉 be a STRIPS planning task. Thestate space of Π is ΘΠ = (S,A, T, I, SG) where:
� The states (also world states) S := P(P ) are the subsets of P .
� A is Π’s action set.
� The transitions are T = {s a−→ apply(s, a) | prea⊆ s}.If prea⊆ s, then a is applicable in s and apply(s, a) := (s∪ adda)\dela.If prea 6 ⊆ s, then apply(s, a) is undefined.
� I is Π’s initial state.
� The goal states SG = {s ∈ S |G⊆ s} are those that satisfy Π’s goal.
An (optimal) plan for s ∈ S is an (optimal) solution for s in ΘΠ, i.e., a pathfrom s to some s′ ∈ SG. A solution for I is called a plan for Π. Π is solvableif a plan for Π exists.
For a = 〈a1, . . . , an〉, apply(s, a) := apply(s, apply(s, a2 . . . apply(s, an))) ifeach ai is applicable in the respective state; else, apply(s, a) is undefined.
� Note: This is exactly like the state spaces of ?search?, without a cost function.Solutions are defined as before (paths from I to a state in SG).
©:Michael Kohlhase 554
STRIPS Encoding of Simplified “TSP”
20 CHAPTER 17. PLANNING I: FRAMEWORK
� Facts P : {at(x), vis(x) |x ∈ {Sy,Ad,Br}}.
� Initial state I: {at(Sy), vis(Sy)}.
� Goal G: {vis(x) |x ∈ {Sy,Ad,Br}}. (Note: no “at(Sy)”)
� Actions a ∈ A: drv(x, y) where x y have a road.
� Precondition prea: {at(x)}.� Add list adda: {at(y), vis(y)}.� Delete list dela: {at(x)}.
©:Michael Kohlhase 555
Encoding of Simplified “TSP”: State Space
at(Sy)vis(Sy)
at(Br)vis(Sy)vis(Br)
at(Ad)vis(Sy)vis(Ad)
at(Sy)vis(Sy)vis(Br)
at(Sy)vis(Sy)vis(Ad)
at(Ad)vis(Sy)vis(Br)vis(Ad)
at(Br)vis(Sy)vis(Ad)vis(Br)
at(Sy)vis(Sy)vis(Ad)vis(Br)
drv(Sy,Br)
drv(Sy,Ad)
drv(Br,Sy)
drv(Ad,Sy)
drv(Sy,Ad)
drv(Sy,Br)
drv(Br,Sy)
drv(Ad,Sy)
� Question: Are there any solutions in this graph?
� Answer: Yes, two: drv(Sy,Br), drv(Br, Sy), drv(Sy,Ad) and drv(Sy,Ad), drv(Ad, Sy), drv(Sy,Br).
� Question: Is the graph above actually the state space?
� Answer: No, only the reachable part. E.g., ΘΠ also includes the states {vis(Sy)}and {at(Sy), at(Br)}.
©:Michael Kohlhase 556
17.3. STRIPS PLANNING 21
(Oh no it’s) The Blocksworld
Initial State Goal State
D
B
A
C
E
D
CBAE
� Facts: on(x, y), onTable(x), clear(x), holding(x), armEmpty.
� Initial state: {onTable(E), clear(E), . . ., onTable(C), on(D,C), clear(D), armEmpty}.
� Goal: {on(E,C), on(C,A), on(B,D)}.
� Actions: stack(x, y), unstack(x, y), putdown(x), pickup(x).
� stack(x, y)?
pre : {holding(x), clear(y)}add : {on(x, y), armEmpty}del : {holding(x), clear(y)}.
©:Michael Kohlhase 557
Questionnaire
� Question: Which are correct encodings (ones that are part of some correctoverall model) of the STRIPS Blocksworld pickup(x) action schema?
(A){onTable(x), clear(x), armEmpty}{holding(x)}{onTable(x)}
(B){onTable(x), clear(x), armEmpty}{holding(x)}{armEmpty}
(C){onTable(x), clear(x), armEmpty}{holding(x)}{onTable(x), armEmpty, clear(x)}
(D){onTable(x), clear(x), armEmpty}{holding(x)}{onTable(x), armEmpty}
Recall: an actions a represented by a tuple 〈prea, adda, dela〉 of lists of facts.
� Hint: The only differences between them are the delete lists
� Answer (A): No, must delete armEmpty
� Answer (B): No, must delete onTable(x).
� Answer (C) (D): Both yes: We can, but don’t have to, encode the single-armBlocksworld so that the block currently in the hand is not clear.For (C), stack(x, y) and putdown(x) need to add clear(x), so the encoding onthe previous slide does not work.
©:Michael Kohlhase 558
22 CHAPTER 17. PLANNING I: FRAMEWORK
Miconic-10: A Real-World Example
� VIP: Served first.
� D: Lift may only go down wheninside; similar for U.
� NA: Never-alone
� AT: Attendant.
� A, B: Never together in thesame elevator (!)
� P: Normal passenger :-)
DVIP
U
NA
AT
B
A
P
???
©:Michael Kohlhase 559
17.4 The PDDL Language
PDDL History
� PDDL =̂ Planning Domain Description Language
� A description language for planning in the STRIPS formalism and various ex-tensions.
� Used in the International Planning Competition (IPC).
� 1998: PDDL [pddl-handbook].
� 2000: “PDDL subset for the 2000 competition” [pddl-2000-subset].
� 2002: PDDL2.1, Levels 1-3 [fox:long:jair-03].
� 2004: PDDL2.2 [hoffmann:edelkamp:jair-05].
� 2006: PDDL3 [gerevini:etal:ai-09].
©:Michael Kohlhase 560
PDDL Quick Facts
� PDDL is not a propositional language
17.4. PDDL LANGUAGE 23
� Representation is lifted, using object variables to be instantiated from a finiteset of objects. (Similar to predicate logic)
� Action schemas parameterized by objects.
� Predicates to be instantiated with objects.
� A PDDL planning task comes in two pieces
� The domain file and the problem file.
� The problem file gives the objects, the initial state, and the goal state.
� The domain file gives the predicates and the operators; each benchmarkdomain has one domain file.
©:Michael Kohlhase 561
The Blocksworld in PDDL: Domain File
Initial State Goal State
D
B
A
C
E
D
CBAE
(define (domain blocksworld)(:predicates (clear ?x) (holding ?x) (on ?x ?y)
(on−table ?x) (arm−empty))(:action stack:parameters (?x ?y):precondition (and (clear ?y) (holding ?x)):effect (and (arm−empty) (on ?x ?y)
(not (clear ?y)) (not (holding ?x)))). . .)
©:Michael Kohlhase 562
The Blocksworld in PDDL: Problem File
Initial State Goal State
D
B
A
C
E
D
CBAE
(define (problem bw−abcde)(:domain blocksworld)(:objects a b c d e)(:init (on−table a) (clear a)(on−table b) (clear b)(on−table e) (clear e)(on−table c) (on d c) (clear d)
24 CHAPTER 17. PLANNING I: FRAMEWORK
(arm−empty))(:goal (and (on e c) (on c a) (on b d))))
©:Michael Kohlhase 563
Miconic-ADL “Stop” Action Schema in PDDL(:action stop:parameters (?f − floor):precondition (and (lift−at ?f)(imply(exists(?p − conflict−A)(or (and (not (served ?p))
(origin ?p ?f))(and (boarded ?p)
(not (destin ?p ?f)))))(forall(?q − conflict−B)(and (or (destin ?q ?f)
(not (boarded ?q)))(or (served ?q)
(not (origin ?q ?f))))))(imply (exists
(?p − conflict−B)(or (and (not (served ?p))
(origin ?p ?f))(and (boarded ?p)
(not (destin ?p ?f)))))(forall(?q − conflict−A)(and (or (destin ?q ?f)
(not (boarded ?q)))(or (served ?q)
(not (origin ?q ?f))))))
(imply(exists(?p − never−alone)(or (and (origin ?p ?f)
(not (served ?p)))(and (boarded ?p)
(not (destin ?p ?f)))))(exists(?q − attendant)(or (and (boarded ?q)
(not (destin ?q ?f)))(and (not (served ?q))
(origin ?q ?f)))))(forall(?p − going−nonstop)(imply (boarded ?p) (destin ?p ?f)))(or (forall
(?p − vip) (served ?p))(exists(?p − vip)(or (origin ?p ?f) (destin ?p ?f))))
(forall(?p − passenger)(imply(no−access ?p ?f) (not (boarded ?p)))))
)
©:Michael Kohlhase 564
Questionnaire
� Question: What is PDDL good for?
(A) Nothing.
(B) Free beer.
(C) Those AI planning guys.
(D) Being lazy at work.
� Answer (A): Nah, it’s definitely good for something (see remaining answers)
� Answer (B): Generally, no. Sometimes, yes: PDDL is needed for the IPC, andif you win the IPC you get price money (= free beer).
� Answer (C): Yep. (Iniitally, every system had its own language, so runningexperiments felt a lot like “Lost in Translation”.)
17.5. PLANNING COMPLEXITY 25
� Answer (D): Yep. You can be a busy bee, programming a solver yourself. Oryou can be lazy and just write the PDDL. (I think I said that before . . . )
©:Michael Kohlhase 565
17.5 Planning Complexity
Algorithmic Problems in Planning
� Definition 17.5.1 We speak of satisficing planning if
Input: A planning task Π.Output: A plan for Π, or “unsolvable” if no plan for Π exists.
and of optimal planning if
Input: A planning task Π.Output: An optimal plan for Π, or “unsolvable” if no plan for Π exists.
� The techniques successful for either one of these are almost disjoint. And sat-isficing planning is much more effective in practice.
� Definition 17.5.2 Programs solving these problems are called (optimal)planner, planning system, or planning tool.
©:Michael Kohlhase 566
Decision Problems in (STRIPS) Planning
� Definition 17.5.3 By PlanEx, we denote the problem of deciding, given aSTRIPS planning task Π, whether or not there exists a plan for Π.
� PlanEx corresponds to satisficing planning.
� Definition 17.5.4 By PlanLen, we denote the problem of deciding, givena STRIPS planning task Π and an integer B, whether or not there exists aplan for Π of length at most B.
� PlanLen corresponds to optimal planning.
� Definition 17.5.5 By PolyPlanLen, we denote the problem of deciding,given a STRIPS planning task Π and an integer B bounded by a polynomialin the size of Π, whether or not there exists a plan for Π of length at mostB.
� PolyPlanLen corresponds to optimal planning with “small” plans.
� Example of a planning domain with exponentially long plans?
� Towers of Hanoi.
26 CHAPTER 17. PLANNING I: FRAMEWORK
©:Michael Kohlhase 567
Complexity of PlanEx (after [bylander:ai-94])
� Lemma 17.5.6 PlanEx is PSPACE-hard. (At least as hard as any otherproblem contained in PSPACE)
� Proof: Given a Turing machine with space bounded by polynomial p(|w|), we canin polynomial time (in the size of the machine) generate an equivalent STRIPSplanning task. Say the possible symbols in tape cells are x1, . . . , xm and theinternal states are s1, . . . , sn, accepting state sacc.
P.1 The contents of the tape cells: in(1, x1), . . . , in(p(|w|), x1), . . . , in(1, xm), . . . , in(p(|w|), xm).
P.2 The position of the R/W head: at(1), . . . , at(p(|w|)).P.3 The internal state of the machine: state(s1), . . . , state(sn).
P.4 Transitions rules 7→ STRIPS actions; accepting state 7→ STRIPS goal {state(sacc)};initial state obvious.
P.5 This reduction to STRIPS runs in polynomial-time because we need onlypolynomially many facts.
©:Michael Kohlhase 568
Complexity of PlanEx, ctd. [bylander:ai-94]
� Lemma 17.5.7 PlanEx is in PSPACE (At most as hard as any otherproblem contained in PSPACE)
� Proof: As PSPACE = NPSPACE we show that PlanEx is in NPSPACE
P.1 1. s := I; l := 0;2. Guess an applicable action a, compute the outcome state s′, set l :=
l + 1;3. If s′ contains the goal then succeed;4. If l ≥ 2|P | then fail else goto 2;
� Remembering the actual action sequence would take exponential space in caseof exponentially long plans (cf. slide 567). But, to decide PlanEx, we only needto remember its length.
� Corollary 17.5.8 (Complexity of PlanEx) PlanEx is PSPACE-complete.(Immediate from previous two lemmta)
©:Michael Kohlhase 569
Complexity of PlanLen (after [bylander:ai-94])
17.5. PLANNING COMPLEXITY 27
� PlanLen isn’t any easier than PlanEx
� Corollary 17.5.9 PlanLen is PSPACE-complete.
� Proof:
P.1 (Membership) Same as before but failing at l ≥ B.
P.2 (Hardness) Setting B := 2|P |, PlanLen answers PlanEx: If a plan exists,then there exists a plan that traverses each possible state at most once.
� PolyPlanLen is easier than PlanEx:
� Theorem 17.5.10 PolyPlanLen is NP-complete.
� Proof:
P.1 (Membership) Guess B actions and check whether they form a plan. Thisruns in polynomial time because B is polynomially bounded.
P.2 (Hardness) E.g., by reduction from SAT.
� Bounding plan length does not help in the general case as we can set the boundto a trivial (exponential) upper bound on plan length. If we restrict plan lengthto be “short” (polynomial), planning becomes easier.
©:Michael Kohlhase 570
The Blocksworld is Hard?
Initial State Goal State
D
B
A
C
E
D
CBAE
©:Michael Kohlhase 571
The Blocksworld is Hard!
P
RAE
S
V
M
K
Y
G
O
T
J
Z
X
H
N
I
U
W
B
Q
L
F
D
C
Goal State
I
ODN
Z
X
C
V
B
M
A
S
F
G
H
H
J
K
L
Q
W
E
R
T
Y
U
Initial State
28 CHAPTER 17. PLANNING I: FRAMEWORK
©:Michael Kohlhase 572
Miconic-10: A Real-World Example
� VIP: Served first.
� D: Lift may only go down wheninside; similar for U.
� NA: Never-alone
� AT: Attendant.
� A, B: Never together in thesame elevator (!)
� P: Normal passenger :-)
DVIP
U
NA
AT
B
A
P
???
©:Michael Kohlhase 573
17.6 Conclusion
Summary
� General problem solving attempts to develop solvers that perform well across alarge class of problems.
� Planning, as considered here, is a form of general problem solving dedicated tothe class of classical search problems. (Actually, we also address inaccessible,stochastic, dynamic, continuous, and multi-agent settings.)
� Heuristic search planning has dominated the International Planning Competition(IPC). We focus on it here.
� STRIPS is the simplest possible, while reasonably expressive, language for ourpurposes. It uses Boolean variables (facts), and defines actions in terms ofprecondition, add list, and delete list.
� PDDL is the de-facto standard language for describing planning problems.
� Plan existence (bounded or not) is PSPACE-complete to decide for STRIPS. Ifwe bound plans polynomially, we get down to NP-completeness.
©:Michael Kohlhase 574
17.6. CONCLUSION 29
Reading:
• Chapters 10: Classical Planning and 11: Planning and Acting in the Real World in [RusNor:AIMA09]
Content: Although the book is named “A Modern Approach”, the planning section waswritten long before the IPC was even dreamt of, before PDDL was conceived, and severalyears before heuristic search hit the scene. As such, what we have right now is the attemptof two outsiders trying in vain to catch up with the dramatic changes in planning since 1995.
Chapter 10 is Ok as a background read. Some issues are, imho, misrepresented, and it’s farfrom being an up-to-date account. But it’s Ok to get some additional intuitions in wordsdifferent from my own.
Chapter 11 is useful in our context here because we don’t cover any of it. If you’re interestedin extended/alternative planning paradigms, do read it.
• A good source for modern information (some of which we covered in the lecture) is JörgEverythingYou Always Wanted to Know About Planning (But Were Afraid to Ask) [hoffmann:ki-11]which is available online at http://fai.cs.uni-saarland.de/hoffmann/papers/ki11.pdf
30 CHAPTER 17. PLANNING I: FRAMEWORK
Chapter 18
Planning II: Algorithms
18.1 Introduction
Reminder: Our Agenda for This Topic
� Chapter 17 Background, planning languages, complexity.
� Sets up the framework. Computational complexity is essential to distinguishdifferent algorithmic problems, and for the design of heuristic functions (seenext).
This Chapter: How to automatically generate a heuristic function, given planninglanguage input?
� � Focussing on heuristic search as the solution method, this is the main ques-tion that needs to be answered.
©:Michael Kohlhase 575
Reminder: Search
� Starting at initial state, produce all successor states step by step:
Reminder: Search
I Starting at initial state, produce all successor states step by step:
03/23
General Search
From the initial state, produce all successive states step by step search tree.
(3,3,1)
(2,3,0) (3,2,0) (2,2,0) (1,3,0) (3,1,0)
(3,3,1)(a) initial state
(b) after expansion
of (3,2,0)
of (3,3,1)
(c) after expansion (3,3,1)
(2,3,0) (3,2,0) (2,2,0) (1,3,0) (3,1,0)
(3,3,1)
In planning, this is referred to as forward search, or forward state-space search.
Kohlhase: Künstliche Intelligenz 1 532 July 5, 2018
31
32 CHAPTER 18. PLANNING II: ALGORITHMS
In planning, this is referred to as forward search, or forward state-space search.
©:Michael Kohlhase 576
Search in the State Space?Search in the State Space?
I Use heuristic function to guide the search towards the goal!
Kohlhase: Künstliche Intelligenz 1 533 July 5, 2018
� Use heuristic function to guide the search towards the goal!
©:Michael Kohlhase 577
Reminder: Informed Search
goalinit
costesti
mate h
cost estimate h
cost estimate h
cost estimate h
� Heuristic function h estimates the cost of an optimal path from a state s to thegoal; search prefers to expand states s with small h(s).
� Live Demo vs. Breadth-First Search:
http://qiao.github.io/PathFinding.js/visual/
©:Michael Kohlhase 578
18.2. HOW TO RELAX 33
Reminder: Heuristic Functions
� Definition 18.1.1 Let Π be a planning task with states S. A heuristicfunction, short heuristic, for Π is a function h : S → N∪{∞} so that h(s) = 0whenever s is a goal state.
� Exactly like our definition from ?search?. Except, because we assume unit costshere, we use N instead of R+.
� Definition 18.1.2 Let Π be a planning task with states S. The perfectheuristic h∗ assigns every s ∈ S the length of a shortest path from s to a goalstate, or ∞ if no such path exists. A heuristic function h for Π is admissibleif, for all s ∈ S, we have h(s) ≤ h∗(s).
� Exactly like our definition from ?search?, except for path length instead of pathcost (cf. above).
� In all cases, we attempt to approximate h∗(s), the length of an optimal plan fors. Some algorithms guarantee to lower-bound h∗(s).
©:Michael Kohlhase 579
Our (Refined) Agenda for This Chapter
� How to Relax: How to relax a problem?
� Basic principle for generating heuristic functions.
� The Delete Relaxation: How to relax a planning problem?
� The delete relaxation is the most successful method for the automatic gen-eration of heuristic functions. It is a key ingredient to almost all IPC winnersof the last decade. It relaxes STRIPS planning tasks by ignoring the deletelists.
� The h+ Heuristic: What is the resulting heuristic function?
� h+ is the “ideal” delete relaxation heuristic.
� Approximating h+: How to actually compute a heuristic?
� Turns out that, in practice, we must approximate h+.
©:Michael Kohlhase 580
18.2 How to Relax in Planning
We will now instantiate our general knowledge about heuristic search to the planning domain. Asalways, the main problem is to find good heuristics. We will follow the intuitions of our discussionin the chapter on informed search and consider full solutions to relaxed problems as a source forheuristics.
34 CHAPTER 18. PLANNING II: ALGORITHMS
Reminder: Heuristic Functions from Relaxed Problems
� Problem Π: Find a route from Saarbruecken To Edinburgh.
©:Michael Kohlhase 581
Reminder: Heuristic Functions from Relaxed Problems
� Relaxed Problem Π′: Throw away the map.
©:Michael Kohlhase 582
Reminder: Heuristic Functions from Relaxed Problems
18.2. HOW TO RELAX 35
� Heuristic function h: Straight line distance.
©:Michael Kohlhase 583
Relaxation in Route-Finding
� Problem class P: Route finding.
� Perfect heuristic h∗P for P: Length of a shortest route.
� Simpler problem class P ′: Route finding on an empty map.
� Perfect heuristic h∗P′ for P ′: Straight-line distance.
� Transformation R:Throw away the map.
©:Michael Kohlhase 584
How to Relax in Planning? (A Reminder!)
� Example 18.2.1 (Logistics)
36 CHAPTER 18. PLANNING II: ALGORITHMS
� Facts P : {truck(x) |x ∈ {A,B,C,D}}∪ {pack(x) |x ∈ {A,B,C,D, T}}.� Initial state I: {truck(A), pack(C)}.� Goal G: {truck(A), pack(D)}.� Actions A: (Notated as “precondition ⇒ adds, ¬ deletes”)
� drive(x, y), where x and y have a road: “truck(x)⇒ truck(y),¬truck(x)”.� load(x): “truck(x), pack(x)⇒ pack(T ),¬pack(x)”.� unload(x): “truck(x),pack(T )⇒ pack(x),¬pack(T )”.
� Example 18.2.2 (“Only-Adds” Relaxation) Drop the preconditions anddeletes.
� “drive(x, y): ⇒ truck(y)”;
� “load(x): ⇒ pack(T )”;
� “unload(x): ⇒ pack(x)”.
� Heuristic value for I is?
� hR(I) = 1: A plan for the relaxed task is 〈unload(D)〉.
©:Michael Kohlhase 585
We will start with a very simple relaxation, which could be termed “positive thinking”: we do notconsider preconditions of actions and leave out the delete lists as well.
How to Relax During Search: Overview
� Attention: Search uses the real (un-relaxed) Π. The relaxation is applied (e.g.,in Only-Adds, the simplified actions are used) only within the call to h(s)!!!
Problem Π Solution to ΠHeuristic Searh on Π
R h∗P′
state s
R(Πs)
h(s) = h∗P′(R(Πs))
� Here, Πs is Π with initial state replaced by s, i.e., Π = 〈P,A, I,G〉 changedto Πs := 〈P,A, s,G〉: The task of finding a plan for search state s.
� A common student mistake is to instead apply the relaxation once to thewhole problem, then doing the whole search “within the relaxation”.
� The next slide illustrates the correct search process in detail.
©:Michael Kohlhase 586
18.2. HOW TO RELAX 37
How to Relax During Search: Only-Adds
38 CHAPTER 18. PLANNING II: ALGORITHMS
18.2. HOW TO RELAX 39
Real problem:� Initial state I: AC; goal G: AD.
� Actions A: pre, add, del.
� drXY, loX, ulX.
Relaxed problem:� State s: AC; goal G: AD.
� Actions A: add.
� hR(s) =1: 〈ulD〉.Real problem:� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� ACdrAB−−−−→ BC.
Relaxed problem:� State s: BC; goal G: AD.
� Actions A: add.
� hR(s) =2: 〈drBA, ulD〉.Real problem:� State s: CC; goal G: AD.
� Actions A: pre, add, del.
� BCdrBC−−−−→ CC.
Relaxed problem:� State s: CC; goal G: AD.
� Actions A: add.
� hR(s) =2: 〈drBA, ulD〉.Real problem:� State s: AC; goal G: AD.
� Actions A: pre, add, del.
� BCdrBA−−−−→ AC.
Real problem:� State s: AC; goal G: AD.
� Actions A: pre, add, del.
� Duplicate state, prune.
Real problem:� State s: DC; goal G: AD.
� Actions A: pre, add, del.
� CCdrCD−−−−→ DC.
Relaxed problem:� State s: DC; goal G: AD.
� Actions A: add.
� hR(s) =2: 〈drBA, ulD〉.Real problem:� State s: CT ; goal G: AD.
� Actions A: pre, add, del.
� CCloC−−→ CT .
Relaxed problem:� State s: CT ; goal G: AD.
� Actions A: add.
� hR(s) =2: 〈drBA, ulD〉.Real problem:� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� CCdrCB−−−−→ BC.
Real problem:� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� Duplicate state, prune.
Real problem:� State s: CT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: BT , DT , CC.
Real problem:� State s: BT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: AT , BB, CT .
Real problem:� State s: AT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: AA, BT .
Real problem:� State s: AA; goal G: AD.
� Actions A: pre, add, del.
� Successors: BA, AT .
Real problem:� State s: BA; goal G: AD.
� Actions A: pre, add, del.
� Successors: CA, AA.
40 CHAPTER 18. PLANNING II: ALGORITHMS
� Greedy best-first search: (tie-breaking: alphabetic)
We are here
ACAC
1
BCBC
2drAB
CCCC
2drBC
ACAC
D
drBA
DCDC
2
drCD
CTCT
2loC
BCBC
D
drCB
BT
2
drCB
DT
2drCD
CC
D
ulC
AT
1
drBA
BB
2
ulB
CT
DdrBC
AA
1ulA
BT
D
drAB BA
2drAB
AT
D
loA CA
2drBC
AA
D
drBA
©:Michael Kohlhase 587
Only-Adds is a “Native” Relaxation
� Definition 18.2.3 (Native Relaxations) Confusing special case where P ′⊆P.
P
P ′⊆P
N∪{∞}
R
h∗P
h∗P′
� Problem class P: STRIPS planning tasks.
� Perfect heuristic h∗P for P: Length h∗ of a shortest plan.
� Transformation R: Drop the preconditions and delete lists.
� Simpler problem class P ′ is a special case of P, P ′⊆P: STRIPS planningtasks with empty preconditions and delete lists.
� Perfect heuristic for P ′: Shortest plan for only-adds STRIPS task.
©:Michael Kohlhase 588
18.3 The Delete Relaxation
We turn to a more realistic relaxation, where we only disregard the delete list.
How the Delete Relaxation Changes the World
18.3. DELETE RELAXATION 41
� Relaxation mapping R saying that:
“When the world changes, its previous state remains true as well.”Real world: (before)
Realworld: (after)
Relaxed world: (before)
Relaxedworld: (after)
Real world: (before)
Real world: (after)
Relaxed world: (before)
42 CHAPTER 18. PLANNING II: ALGORITHMS
Relaxed world: (after)
Real world:
Relaxed world:
©:Michael Kohlhase 589
The Delete Relaxation
� Definition 18.3.1 (Delete Relaxation) Let Π = 〈P,A, I,G〉 be a plan-ning task. The delete-relaxation of Π is the task Π+ = 〈P,A+, I, G〉 whereA+ := {a+ | a ∈ A} with prea+ = prea, adda+ = adda, and dela+ = ∅.
18.3. DELETE RELAXATION 43
� In other words, the class of simpler problems P ′ is the set of all STRIPS planningtasks with empty delete lists, and the relaxation mappingR drops the delete lists.
� Definition 18.3.2 (Relaxed Plan) Let Π = 〈P,A, I,G〉 be a planningtask, and let s be a state. A relaxed plan for s is a plan for 〈P,A, s,G〉+. Arelaxed plan for I is called a relaxed plan for Π.
� A relaxed plan for s is an action sequence that solves s when pretending thatall delete lists are empty.
� Also called “delete-relaxed plan”: “relaxation” is often used to mean “delete-relaxation” by default.
©:Michael Kohlhase 590
A Relaxed Plan for “TSP” in Australia
1. Initial state: {at(Sy), vis(Sy)}.
2. Apply drv(Sy,Br)+: {at(Br), vis(Br), at(Sy), vis(Sy)}.
3. Apply drv(Sy,Ad)+: {at(Ad), vis(Ad), at(Br), vis(Br), at(Sy), vis(Sy)}.
4. Apply drv(Ad,Pe)+: {at(Pe), vis(Pe), at(Ad), vis(Ad), at(Br), vis(Br), at(Sy), vis(Sy)}.
5. Apply drv(Ad,Da)+: {at(Da), vis(Da), at(Pe), vis(Pe), at(Ad), vis(Ad), at(Br), vis(Br), at(Sy), vis(Sy)}.
©:Michael Kohlhase 591
A Relaxed Plan for “Logistics”
� Facts P : {truck(x) |x ∈ {A,B,C,D}}∪ {pack(x) |x ∈ {A,B,C,D, T}}.
� Initial state I: {truck(A), pack(C)}.
� Goal G: {truck(A), pack(D)}.
� Relaxed actions A+: (Notated as “precondition ⇒ adds”)
� drive(x, y)+: “truck(x)⇒ truck(y)”.
44 CHAPTER 18. PLANNING II: ALGORITHMS
� load(x)+: “truck(x), pack(x)⇒ pack(T )”.
� unload(x)+: “truck(x), pack(T )⇒ pack(x)”.
Relaxed plan:
〈drive(A,B)+, drive(B,C)
+, load(C)
+, drive(C,D)
+, unload(D)
+〉
� We don’t need to drive the truck back, because “it is still at A”.
©:Michael Kohlhase 592
PlanEx+
� Definition 18.3.3 (Relaxed Plan Existence Problem) ByPlanEx+, wedenote the problem of deciding, given a planning task Π = 〈P,A, I,G〉,whether or not there exists a relaxed plan for Π.
� This is easier than PlanEx for general STRIPS!
� Proposition 18.3.4 (PlanEx+ is Easy) PlanEx+ is a member of P.
� Proof: The following algorithm decides PlanEx+
P.1
var F := Iwhile G 6⊆ F do
F ′ := F ∪⋃
a∈A:prea⊆Fadda
if F ′ = F then return ‘‘unsolvable’’ endif (∗)F := F ′
endwhilereturn ‘‘solvable’’
P.2 The algorithm terminates after at most |P | iterations, and thus runs inpolynomial time.
P.3 Correctness: See slide 596
©:Michael Kohlhase 593
Deciding PlanEx+ in “TSP” in Australia
Iterations on F :
18.3. DELETE RELAXATION 45
1. {at(Sy), vis(Sy)}
2. ∪ {at(Ad), vis(Ad), at(Br), vis(Br)}
3. ∪ {at(Da), vis(Da), at(Pe), vis(Pe)}
©:Michael Kohlhase 594
Deciding PlanEx+ in “Logistics”
� Example 18.3.5 (The solvable Case)
Iterations on F :
1. {truck(A), pack(C)}
2. ∪{truck(B)}
3. ∪{truck(C)}
4. ∪{truck(D),pack(T )}
5.∪{pack(A), pack(B), pack(D)}
� Example 18.3.6 (The unsolvable Case)
Iterations on F :
1. {truck(A), pack(C)}
2. ∪{truck(B)}
3. ∪{truck(C)}
4. ∪{pack(T )}
5. ∪{pack(A), pack(B)}
6. ∪∅
©:Michael Kohlhase 595
PlanEx+ Algorithm: ProofProof: To show: The algorithm returns “solvable” iff there is a relaxed plan for Π.
P.1 Denote by Fi the content of F after the ith iteration of the while-loop,
P.2 All a ∈ A0 are applicable in I, all a ∈ A1 are applicable in apply(I, A+0 ), and
so forth.
P.3 Thus Fi = apply(I, 〈A+0 , . . ., A
+i−1〉). (Within each A+
j , we can sequence theactions in any order.)
46 CHAPTER 18. PLANNING II: ALGORITHMS
P.4.1 Direction “⇒”: If “solvable” is returned after iteration n then G ⊆ Fn =apply(I, 〈A+
0 , . . ., A+n−1〉) so 〈A+
0 , . . ., A+n−1〉 can be sequenced to a relaxed
plan which shows the claim.
P.4.2 Direction “⇐”::
P.4.2.1 Let 〈a+0 , . . ., a
+n−1〉 be a relaxed plan, hence G⊆ apply(I, 〈a+
0 , . . . , a+n−1〉).
P.4.2.2 Assume, for the moment, that we drop line (*) from the algorithm. It isthen easy to see that ai ∈ Ai and apply(I, 〈a+
0 , . . . , a+i−1〉)⊆Fi, for all i.
P.4.2.3 We get G⊆ apply(I, 〈a+0 , . . . , a
+n−1〉) ⊆ Fn, and the algorithm returns
“solvable” as desired.
P.4.2.4 Assume to the contrary of the claim that, in an iteration i < n, (*) fires.Then G 6 ⊆F and F = F ′. But, with F = F ′, F = Fj for all j > i, and weget G 6 ⊆Fn in contradiction.
©:Michael Kohlhase 596
18.4 The h+Heuristic
Hold on a Sec – Where are we?
�
P
P ′⊆P
N∪{∞}
R
h∗P
h∗P′
� P: STRIPS planning tasks; h∗P : Length h∗ of a shortest plan.
� P ′⊆P: STRIPS planning tasks with empty delete lists.
� R: Drop the delete lists.
� Heuristic function: Length of a shortest relaxed plan (h∗ ◦R).
� PlanEx+ is not actually what we’re looking for. PlanEx+ =̂ relaxed planexistence; we want relaxed plan length h∗ ◦R.
©:Michael Kohlhase 597
h+: The Ideal Delete Relaxation Heuristic
� Definition 18.4.1 (Optimal Relaxed Plan) Let Π = 〈P,A, I,G〉 be aplanning task, and let s be a state. A optimal relaxed plan for s is an
18.4. THE H+HEURISTIC 47
optimal plan for 〈P,A, s,G〉+.
� Same as slide 590, just adding the word “optimal”.
� Here’s what we’re looking for:
� Definition 18.4.2 Let Π = 〈P,A, I,G〉 be a planning task with states S.The ideal delete-relaxation heuristic h+ for Π is the function h+ : S →N∪{∞} where h+(s) is the length of an optimal relaxed plan for s if arelaxed plan for s exists, and h+(s) =∞ otherwise.
� In other words, h+ = h∗ ◦R, cf. previous slide.
©:Michael Kohlhase 598
h+ is Admissible
� Lemma 18.4.3 Let Π = 〈P,A, I,G〉 be a planning task, and let s be astate. If 〈a1, . . ., an〉 is a plan for 〈P,A, s,G〉, then 〈a+
1 , . . ., a+n 〉 is a plan for
〈P,A, s,G〉+.
� Proof Sketch: Show by induction over 0 ≤ i ≤ n thatapply(s, 〈a1, . . ., ai〉)⊆ apply(s, 〈a+
1 , . . ., a+i 〉).
� If we ignore deletes, the states along the plan can only get bigger.
� Theorem 18.4.4 h+ is Admissible.
� Proof:
P.1 Let Π = 〈P,A, I,G〉 be a planning task with states S, and let s ∈ S.
P.2 h+(s) is defined as optimal plan length in 〈P,A, s,G〉+.P.3 With the lemma above, any plan for 〈P,A, s,G〉 also constitutes a plan for
〈P,A, s,G〉+.P.4 Thus optimal plan length in 〈P,A, s,G〉+ can only be shorter than that in
〈P,A, s,G〉, and the claim follows.
©:Michael Kohlhase 599
How to Relax During Search: Ignoring Deletes
48 CHAPTER 18. PLANNING II: ALGORITHMS
18.4. THE H+HEURISTIC 49
Real problem:
� Initial state I: AC; goal G:AD.
� Actions A: pre, add, del.
� drXY, loX, ulX.
Relaxed problem:
� State s: AC; goal G: AD.
� Actions A: pre, add.
� h+(s) =5: e.g.〈drAB, drBC, drCD, loC, ulD〉.
Real problem:
� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� ACdrAB−−−−→ BC.
Relaxed problem:
� State s: BC; goal G: AD.
� Actions A: pre, add.
� h+(s) =5: e.g.〈drBA, drBC, drCD, loC, ulD〉.
Real problem:
� State s: CC; goal G: AD.
� Actions A: pre, add, del.
� BCdrBC−−−−→ CC.
Relaxed problem:
� State s: CC; goal G: AD.
� Actions A: pre, add.
� h+(s) =5: e.g.〈drCB, drBA, drCD, loC, ulD〉.
Real problem:
� State s: AC; goal G: AD.
� Actions A: pre, add, del.
� BCdrBA−−−−→ AC.
Real problem:
� State s: AC; goal G: AD.
� Actions A: pre, add, del.
� Duplicate state, prune.
Real problem:
� State s: DC; goal G: AD.
� Actions A: pre, add, del.
� CCdrCD−−−−→ DC.
Relaxed problem:
� State s: DC; goal G: AD.
� Actions A: pre, add.
� h+(s) =5: e.g.〈drDC, drCB, drBA, loC, ulD〉.
Real problem:
� State s: CT ; goal G: AD.
� Actions A: pre, add, del.
� CCloC−−→ CT .
Relaxed problem:
� State s: CT ; goal G: AD.
� Actions A: pre, add.
� h+(s) =4: e.g.〈drCB, drBA, drCD, ulD〉.
Real problem:
� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� CCdrCB−−−−→ BC.
Real problem:
� State s: BC; goal G: AD.
� Actions A: pre, add, del.
� Duplicate state, prune.
Real problem:
� State s: CT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: BT , DT , CC.
Real problem:
� State s: BT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: AT , BB, CT .
Real problem:
� State s: AT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: AA, BT .
Real problem:
� State s: DT ; goal G: AD.
� Actions A: pre, add, del.
� Successors: DD, CT .
Real problem:
� State s: DD; goal G: AD.
� Actions A: pre, add, del.
� Successors: CD, DT .
Real problem:
� State s: CD; goal G: AD.
� Actions A: pre, add, del.
� Successors: BD, DD.
Real problem:
� State s: BD; goal G: AD.
� Actions A: pre, add, del.
� Successors: AD, CD.
Real problem:
� State s: AD; goal G: AD.
� Actions A: pre, add, del.
� Goal state!
50 CHAPTER 18. PLANNING II: ALGORITHMS
Greedy best-first search: (tie-breaking: alphabetic)
We are here
ACAC
5
BCBC
5drAB
CCCC
5drBC
ACAC
D
drBA
DCDC
5
drCD
CTCT
4loC
BCBC
D
drCB
BT
4
drCB
DT
4drCD
CC
D
ulC
AT
4
drBA
BB
5
ulB
CT
DdrBC
AA
5ulA
BT
D
drAB
DD
3ulD
CT
D
drDC CD
2drDC
DT
D
loD BD
1drCB
DD
D
drCD AD
0drBA
CD
D
drBC
©:Michael Kohlhase 600
On the “Accuracy” of h+
� Reminder: Heuristics based on ignoring deletes are the key ingredient to almostall IPC winners of the last decade.
�Why? A heuristic function is useful if its estimates are “accurate”.
� How to measure this?
� Known method 1: Error relative to h∗, i.e., bounds on |h∗(s)− h(s)|.� Known method 2: Properties of the search space surface: Local minimaetc.
� For h+, method 2 is the road to success:
� In many benchmarks, under h+, local minima provably do not exist! [hoffmann:jair-05]
©:Michael Kohlhase 601
A Brief Glimpse of h+ Search Space Surfaces
� Graphs =̂ state spaces, vertical height =̂ h+:
18.4. THE H+HEURISTIC 51
“Gripper” “Logistics”
On the side: In Russel/Norvig the text reads as if these illustrations referred tocomputing the heuristic, rather than to finding a plan.
©:Michael Kohlhase 602
� h+ in (the Real) TSP
52 CHAPTER 18. PLANNING II: ALGORITHMS
h+ =̂ Minimum Spanning Tree ©:Michael Kohlhase 603
Of course there are also bad cases. Here is one.
18.5. PLANNING ALGORITHMS: CONCLUSION 53
h+ in the Blocksworld
�
CD
B
C
B
AA
Initial State Goal State
� Optimal plan: 〈putdown(A), unstack(B,D), stack(B,C), pickup(A), stack(A,B)〉.
� Optimal relaxed plan: 〈stack(A,B), unstack(B,D), stack(B,C)〉.
� Observation: What can we say about the “search space surface” at the initialstate here?
� The initial state lies on a local minimum under h+, together with the successorstate s where we stacked A onto B. All direct other neighbors of these twostates have a strictly higher h+ value.
©:Michael Kohlhase 604
18.5 Planning Algorithms: Conclusion
Summary
� Heuristic search on classical search problems relies on a function h mappingstates s to an estimate h(s) of their goal distance. Such functions h are derivedby solving relaxed problems.
� In planning, the relaxed problems are generated and solved automatically. Thereare four known families of suitable relaxation methods: abstractions, landmarks,critical paths, and ignoring deletes (aka delete relaxation).
� The delete relaxation consists in dropping the deletes from STRIPS planningtasks. A relaxed plan is a plan for such a relaxed task. h+(s) is the length of anoptimal relaxed plan for state s. h+ is NP-hard to compute.
� hFF approximates h+ by computing some, not necessarily optimal, relaxed plan.That is done by a forward pass (building a relaxed planning graph), followed bya backward pass (extracting a relaxed plan).
©:Michael Kohlhase 605
Topics We Didn’t Cover Here
� Abstractions, Landmarks, Critical-Path Heuristics, Cost Partitionings, Compil-ability between Heuristic Functions, Planning Competitions:
54 CHAPTER 18. PLANNING II: ALGORITHMS
� Tractable fragments: Planning sub-classes that can be solved in polynomialtime. Often identifed by properties of the “causal graph” and “domain transitiongraphs”.
� Planning as SAT: Compile length-k bounded plan existence into satisfiability ofa CNF formula ϕ. Extensive literature on how to obtain small ϕ, how to scheduledifferent valuethm ss of k, how to modify the underlying SAT solver.
� Compilations: Formal framework for determining whether planning formalismX is (or is not) at least as expressive as planning formalism Y .
� Admissible pruning/decomposition methods: Partial-order reduction, symmetryreduction, simulation-based dominance pruning, factored planning, decoupledsearch.
� Hand-tailored planning: Automatic planning is the extreme case where the com-puter is given no domain knowledge other than “physics”. We can instead allowthe user to provide search control knowledge, trading off modeling effort againstsearch performance.
� Numeric planning, temporal planning, planning under uncertainty: . . .
©:Michael Kohlhase 606
Reading (RN: Same As Previous Chapter):
• Chapters 10: Classical Planning and 11: Planning and Acting in the Real World [RusNor:AIMA09]
Content: Although the book is named “A Modern Approach”, the planning section waswritten long before the IPC was even dreamt of, before PDDL was conceived, and severalyears before heuristic search hit the scene. As such, what we have right now is the attemptof two outsiders trying in vain to catch up with the dramatic changes in planning since 1995.
Chapter 10 is Ok as a background read. Some issues are, imho, misrepresented, and it’s farfrom being an up-to-date account. But it’s Ok to get some additional intuitions in wordsdifferent from my own.
Chapter 11 is annoyingly named (I’ve seen lots of classical planning in the “real world”),but is useful in our context here because we don’t cover any of it. If you’re interested inextended/alternative planning paradigms, do read it.
Chapter 19
Planning and Acting in the RealWorld
Outline
� The real world (things go wrong)
� Agents and Belief States
� Conditional planning
� Monitoring and replanning
©:Michael Kohlhase 607
19.1 Introduction
The real world
� Example 19.1.1 We have a flat tire – what to do?
55
56 CHAPTER 19. PLANNING AND ACTING IN THE REAL WORLD
©:Michael Kohlhase 608
Things go wrong
� Example 19.1.2 (Incomplete information)
� Unknown preconditions, e.g., Intact(Spare)?
� Disjunctive effects, e.g., Inflate(x) causes Inflated(x)∨SlowHiss(x)∨Burst(x) ∨BrokenPump ∨ . . .
� Example 19.1.3 (Incorrect information)
� Current state incorrect, e.g., spare NOT intact
� Missing/incorrect postconditions in operators
� Definition 19.1.4 With the qualification problem in planning is that wecan never finish listing all the required preconditions and possible conditionaloutcomes of actions
©:Michael Kohlhase 609
What can we do if things (can) go wrong?
� One Solution: Sensorless planning: devise a plan that works regardless of stateor outcome.
� Problem: Such plans may not exist!
� Another Solution: Conditional plans:
� Plan to obtain information, (observation actions)
� Subplan for each contingency.
� Example 19.1.5 (A conditional Plan) (AAA =̂ ADAC)
[Check(T1), if Intact(T1) then Inflate(T1) else CallAAA]
� Problem: Expensive because it plans for many unlikely cases
19.2. AGENT ARCHITECTURES BASED ON BELIEF STATES 57
� Still another Solution: Execution monitoring/replanning
� Assume normal states, outcomes,
� Check progress during execution, replan if necessary.
� Problem: Unanticipated outcomes may lead to failure (e.g., no AAA card)
� Observation 19.1.6 We really need a combination; plan for likely/seriouseventualities, deal with others when they arise, as they must eventually.
©:Michael Kohlhase 610
19.2 Agent Architectures based on Belief States
We are now ready to proceed environments which can only partially observe and where are ouractions are non-deterministic. Both sources of uncertainty conspire to allow us only partial knowl-edge about the world, so that we can only optimize “expected utility” instead of “actual utility” ofour actions.
World Models for Uncertainty
� Problem: We do not know with certainty what state the world is in!
� Idea: Just keep track of all the possible states it could be in.
� Definition 19.2.1 A model-based agent has a world model consisting of
� a belief state that has information about the possible states the worldmay be in, and
� a transition model that updates the belief state based on sensor informa-tion and actions.
Idea: The agent environment determines what the world model can be.
�� In a fully observable, deterministic environment,
� we can observe the initial state and subsequent states are given by the actionsalone.
� thus the belief state is a singleton set (we call its member the world state)and the transition model is a function from states and actions to states: atransition function.
©:Michael Kohlhase 611
That is exactly what we have been doing in the last semester: we have been studying methodsthat build on descriptions of the “actual” world, and have been concentrating on the progressionfrom atomic to factored and ultimately structured representations. Tellingly, we spoke of “worldstates” instead of “belief states”; we have now justified this practice in the brave new belief-basedworld models by the (re-) definition of “world states” above. To fortify our intiutions, let us recapthe methods from last sememster from a belief-state-model perspective.
58 CHAPTER 19. PLANNING AND ACTING IN THE REAL WORLD
World Models by Agent Type
� Note: All of these considerations only give requirements to the world model.What we can do with it depends on representation and inference.
� Search-based Agents: In a fully observable, deterministic environmentworld state =̂ “current state”no inference.
� CSP-based Agents: In a fully observable, deterministic environmentworld state =̂ constraint networkinference =̂ constraint propagation.
� Logic-based Agents: In a fully observable, deterministic environmentworld state =̂ logical formulainference =̂ e.g. DPLL or resolution.
� Planning Agents: In a fully observable, deterministic, environmentworld state =̂ PL0, transition model =̂ Strips,inference =̂ state/plan space search.
©:Michael Kohlhase 612
Let us now see what happens when we lift the restrictions of total observability and determinism.
World Models for Complex Environments
� In a fully observable, but stochastic environment,
� the belief state must deal with a set of possible states
� generalize the transition function to a transition relation
� Note: this even applies to online problem solving, where we can just perceivethe state. (e.g. when we want to optimize utility)
� In a deterministic, but partially observable environment,
� the belief state must deal with a set of possible states.
� we can use transition functions.
� We need a sensor model, which predicts the influence of percepts on thebelief state – during update.
� In a stochastic partially observable environment,
� mix the ideas from the last two. (sensor model + transition relation)
©:Michael Kohlhase 613
19.3. CONFORMANT PLANNING 59
Preview: New World Models (Belief) ; new Agent Types
� Probabilistic Agents: In a partially observable, belief state =̂ Bayesian networks,inference =̂ probabilistic inference.
� Decision-Theoretic Agents: In a partially observable, stochastic, belief state +transition model =̂ Decision networks, inference =̂ MEU.
©:Michael Kohlhase 614
19.3 Conformant Planning
Conformant/Sensorless Planning
� Definition 19.3.1 Conformant or sensorless planning tries to find plansthat work without any sensing (not even the initial state)
.
� Example 19.3.2 (Sensorless Vacuum Cleaner World)
States integer dirt and robot locationsActions left, right, suck, noOpGoal test notdirty?
� Observation 19.3.3 In a sensorless world we do not know the initial state.(orany state after)
� Observation 19.3.4 sensorless planning must search in the space of beliefstates (sets of possible actual states).
� Example 19.3.5 (Searching the Belief State Space)
� Start in {1, 2, 3, 4, 5, 6, 7, 8}� Solution: [right, suck, left, suck] right → {2, 4, 6, 8}
suck → {4, 8}left → {3, 7}suck → {7}
©:Michael Kohlhase 615
Search in the Belief State Space: Let’s Do the Math
� Recap: We describe an agent problem P := 〈S,A, T , I,G〉 via its states S,actions A, and transition model T : A×S → P(A), goal states G, and initialstate I.
60 CHAPTER 19. PLANNING AND ACTING IN THE REAL WORLD
� Problem: What is the corresponding sensorless problem?
� Let’ think: Let P := 〈S,A, T , I,G〉 be a (physical) problem
� States Sb: The belief states are the 2|S| subsets of S.� The Initial state Ib is just S (no information)
� Goal states Gb := {S ∈ Sb |S⊆G} (all possible states are goal states)
� Actions Ab: we just take A. (that’s the point!)
� Transition model T b : Ab×Sb → P(Ab): i.e. what is T b(a, S) for a ∈ Aand S⊆S? This is slightly tricky as a need not be applicable to all s ∈ S.
1. if actions are harmless to the environment, take T b(a, S) :=⋃
s∈S T (a, s).2. if not, better take T b(a, S) :=
⋂s∈S T (a, s). (the safe bet)
� Observation 19.3.6 In belief-state space the problem is always fully observ-able!
©:Michael Kohlhase 616
Let us see if we can understand the options for T b(a, S) a bit better. The first question is when wewant an action a to be appliccable to a belief state S⊆S, i.e. when should T b(a, S) be non-empty.In the first case, ab would be appilcable iff a is applicable to some s ∈ S, in the second case if ais applicable to all s ∈ S. So we only want to choose the first case if actions are harmless.
The second question we ask ourselves is what should be the results of appllying a to S⊆S? 1EdN:1
State Space vs. Belief State Space
� Example 19.3.7 (State/Belief State Space in the Vacuum World)In the vaccuum world all actions are always applicable (1./2. equal)
1EdNote: MK: contiune
19.4. CONDITIONAL PLANNING 61
©:Michael Kohlhase 617
Evaluating Conformant Planning
� We can build belief-space problem formulations automatically,
� but they are exponentially bigger in theory, in practice they are often similar;
� e.g. 12 reachable belief states out of 28 = 256 for vacuum example.
� belief state are HUGE; e.g. initial belief state for the 10 × 10 vacuum worldcontains 100 · 2100 ≈ 1032 physical states ; use compact description
� all for initial state or not leftmost column after Left.
©:Michael Kohlhase 618
19.4 Conditional Planning
Conditional planning
� If the world is nondeterministic or partially observable then percepts usuallyprovide information, i.e., split up the belief state
62 CHAPTER 19. PLANNING AND ACTING IN THE REAL WORLD
©:Michael Kohlhase 619
Conditional planning contd.
� Definition 19.4.1 Conditional plans check (any consequence of KB +) per-cepte.g. [. . . , if C then PlanA else PlanB , . . .]Execution: check C against current KB, execute “then” or “else”
� Note: Need some plan for every possible percept
� Observation 19.4.2 (cf. game playing) some response for every opponentmove
� Observation 19.4.3 (cf. backward chaining) some rule such that everypremise satisfied
� Idea: Use an AND–OR tree search (very similar to backward chainingalgorithm)
©:Michael Kohlhase 620
Conditional And/Or Search (Algorithm)
� Definition 19.4.4 An algorithm for or searching AND–OR graphs gener-ated by nondeterministic environments.function AND−OR−GRAPH−SEARCH(prob) returns a conditional plan, or fail
OR−SEARCH(prob.INITIAL−STATE, prob [ ])
function OR−SEARCH(state,prob,path) returns a conditional plan, or failif prob.GOAL−TEST(state) then return the empty planif state is on path then return failfor each action in prob.ACTIONS(state) doplan := AND−SEARCH(RESULTS(state,action),prob,[state | path])if plan 6= fail then return [action | plan]
return fail
function AND−SEARCH(states,prob,path) returns a conditional plan, or failfor each si in states dopi := OR−SEARCH(si,prob,path)if pi = fail then return failreturn [if s1 then p1 else if s2 then p2 else . . .. if sn−1 then pn−1 else pn]
Cycle Handling: If a state has been seen before ; fail
19.4. CONDITIONAL PLANNING 63
� � does not mean there is no solution, but
� if there is a non-cyclic solution, then it is reachable by an earlier incarnation
©:Michael Kohlhase 621
The Erratic Vacuum Cleaner
� Example 19.4.5 (The erratic vacuum world) the Suck action works asfollows:
� in a dirty square clean the square and sometimes cleans up dirt in anadjacent square
� in a clean square the action sometimes deposits dirt on the carpet.
�
Solution: [Suck, if State = 5 then [Right, Suck] else []]
©:Michael Kohlhase 622
The Slippery Vacuum Cleaner (try, try, try, . . . try again)
� Example 19.4.6 (The slippery vacuum world) Moving sometimes fails
64 CHAPTER 19. PLANNING AND ACTING IN THE REAL WORLD
Solution: [L1 : Left, if AtR then L1 else [if CleanL then ∅ else Suck]] or[while AtR do [Left], if CleanL then ∅ else Suck]“Infinite loop” but will eventually work unless action always fails
�
©:Michael Kohlhase 623