Informed search algorithms

Similar documents
Informed search algorithms

Introduction to Artificial Intelligence. Informed Search

COMP9414/ 9814/ 3411: Artificial Intelligence. 5. Informed Search. Russell & Norvig, Chapter 3. UNSW c Alan Blair,

Informed search algorithms. Chapter 4, Sections 1 2 1

CS:4420 Artificial Intelligence

Artificial Intelligence: Search Part 2: Heuristic search

Informed Search and Exploration

PROBLEM SOLVING AND SEARCH IN ARTIFICIAL INTELLIGENCE

Outline. Informed search algorithms. Best-first search. Review: Tree search. A search Heuristics. Chapter 4, Sections 1 2 4

Informed Search and Exploration

Informed search algorithms

Overview. Path Cost Function. Real Life Problems. COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Planning, Execution & Learning 1. Heuristic Search Planning

Artificial Intelligence. Informed search methods

Artificial Intelligence, CS, Nanjing University Spring, 2018, Yang Yu. Lecture 3: Search 2.

Robot Programming with Lisp

COMP219: Artificial Intelligence. Lecture 10: Heuristic Search

Artificial Intelligence

Problem solving and search

Informed Search Algorithms

Informed Search Algorithms. Chapter 4

COSC343: Artificial Intelligence

Informed Search and Exploration

Outline. Best-first search

TDT4136 Logic and Reasoning Systems

Problem solving and search

Outline. Best-first search

Princess Nora University Faculty of Computer & Information Systems ARTIFICIAL INTELLIGENCE (CS 370D) Computer Science Department

Chapter 3: Informed Search and Exploration. Dr. Daisy Tang

Lecture 4: Informed/Heuristic Search

CS 771 Artificial Intelligence. Informed Search

Artificial Intelligence CS 6364

A.I.: Informed Search Algorithms. Chapter III: Part Deux

Introduction to Artificial Intelligence (G51IAI)

Informed search algorithms

Informed search algorithms

Informed Search. Dr. Richard J. Povinelli. Copyright Richard J. Povinelli Page 1

Lecture Plan. Best-first search Greedy search A* search Designing heuristics. Hill-climbing. 1 Informed search strategies. Informed strategies

CS414-Artificial Intelligence

Solving Problems by Searching

Artificial Intelligence

Informed search algorithms. Chapter 4

Informed search. Soleymani. CE417: Introduction to Artificial Intelligence Sharif University of Technology Spring 2016

Informed Search and Exploration for Agents

Solving Problems using Search

Informed search methods

Informed/Heuristic Search

Artificial Intelligence

Problem solving and search

4. Solving Problems by Searching

CSE 473. Chapter 4 Informed Search. CSE AI Faculty. Last Time. Blind Search BFS UC-BFS DFS DLS Iterative Deepening Bidirectional Search

CS486/686 Lecture Slides (c) 2015 P.Poupart

Foundations of Artificial Intelligence

Outline for today s lecture. Informed Search. Informed Search II. Review: Properties of greedy best-first search. Review: Greedy best-first search:

Graphs vs trees up front; use grid too; discuss for BFS, DFS, IDS, UCS Cut back on A* optimality detail; a bit more on importance of heuristics,

Informed Search and Exploration

Informed search algorithms

CS486/686 Lecture Slides (c) 2014 P.Poupart

CS 380: Artificial Intelligence Lecture #4

Artificial Intelligence

Solving problems by searching

S A E RC R H C I H NG N G IN N S T S A T T A E E G R G A R PH P S

Week 3: Path Search. COMP9414/ 9814/ 3411: Artificial Intelligence. Motivation. Example: Romania. Romania Street Map. Russell & Norvig, Chapter 3.

Informed Search. Best-first search. Greedy best-first search. Intelligent Systems and HCI D7023E. Romania with step costs in km

Ar#ficial)Intelligence!!

Solving Problems by Searching. Artificial Intelligence Santa Clara University 2016

ARTIFICIAL INTELLIGENCE. Informed search

Mustafa Jarrar: Lecture Notes on Artificial Intelligence Birzeit University, Chapter 3 Informed Searching. Mustafa Jarrar. University of Birzeit

Problem Solving and Search. Geraint A. Wiggins Professor of Computational Creativity Department of Computer Science Vrije Universiteit Brussel

Artificial Intelligence Informed search. Peter Antal

Summary. Search CSL302 - ARTIFICIAL INTELLIGENCE 1

Informed search algorithms. (Based on slides by Oren Etzioni, Stuart Russell)

CS:4420 Artificial Intelligence

Informed Search. Topics. Review: Tree Search. What is Informed Search? Best-First Search

Chapter4. Tree Search (Reviewed, Fig. 3.9) Best-First Search. Search Strategies. Best-First Search (cont.-2) Best-First Search (cont.

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Artificial Intelligence. Sina Institute, University of Birzeit

Automated Planning & Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence

CS 4700: Foundations of Artificial Intelligence

Artificial Intelligence: Search Part 1: Uninformed graph search

EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS

Informed search algorithms. Chapter 4

Informed search strategies (Section ) Source: Fotolia

Searching and NetLogo

Artificial Intelligence

Outline for today s lecture. Informed Search I. One issue: How to search backwards? Very briefly: Bidirectional search. Outline for today s lecture

Dr. Mustafa Jarrar. Chapter 4 Informed Searching. Sina Institute, University of Birzeit

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on Artificial Intelligence,

TDDC17. Intuitions behind heuristic search. Recall Uniform-Cost Search. Best-First Search. f(n) =... + h(n) g(n) = cost of path from root node to n

Foundations of Artificial Intelligence

Part I. Instructor: Dr. Wei Ding. Uninformed Search Strategies can find solutions to problems by. Informed Search Strategies

Foundations of Artificial Intelligence

AGENTS AND ENVIRONMENTS. What is AI in reality?

Artificial Intelligence

Informed Search. CS 486/686 University of Waterloo May 10. cs486/686 Lecture Slides 2005 (c) K. Larson and P. Poupart

COMP9414: Artificial Intelligence Informed Search

16.1 Introduction. Foundations of Artificial Intelligence Introduction Greedy Best-first Search 16.3 A Weighted A. 16.

Informed Search A* Algorithm

Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu. Blind Searches

Transcription:

Artificial Intelligence Topic 4 Informed search algorithms Best-first search Greedy search A search Admissible heuristics Memory-bounded search IDA SMA Reading: Russell and Norvig, Chapter 4, Sections 1 3 c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 66

1. Informed (or best-first) search Recall uninformed search: select nodes for expansion on basis of distance from start uses only information contained in the graph no indication of distance to go! Informed search: select nodes on basis of some estimate of distance to goal! requires additional information evaluation function, or heuristic rules choose best (most promising) alternative best-first search. Implementation: QueueingFn = insert successors in decreasing order of desirability Examples: greedy search A search c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 67

2. Greedy search Assume we have an estimate of the distance to the goal. For example, in our travelling to Bucharest problem, we may know straight-line distances to Bucharest... Arad 118 75 Oradea 71 Neamt Zerind 151 140 Sibiu 99 Fagaras 80 Timisoara Rimnicu Vilcea 111 Lugoj 70 Mehadia 75 Dobreta 120 Craiova Pitesti 211 97 146 101 85 138 Bucharest 90 Giurgiu 87 Iasi 92 142 98 Urziceni Vaslui Hirsova 86 Eforie Straight line distance to Bucharest Arad 366 Bucharest 0 Craiova 160 Dobreta 242 Eforie 161 Fagaras 178 Giurgiu 77 Hirsova 151 Iasi 226 Lugoj 244 Mehadia 241 Neamt 234 Oradea 380 Pitesti 98 Rimnicu Vilcea 193 Sibiu 253 Timisoara 329 Urziceni 80 Vaslui 199 Zerind 374 Greedy search always chooses to visit the candidate node with the smallest estimate that which appears to be closest to goal Evaluation function h(n) (heuristic) = estimate of cost from n to goal E.g., h SLD (n) = straight-line distance from n to Bucharest c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 68

2. Greedy search Arad 366 Zerind Sibiu Timisoara 374 253 329 Arad Rimnicu Oradea Fagaras Vilcea 366 380 178 193 Sibiu Bucharest 253 0 c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 69

2. Greedy search Complete? No, in general. e.g. can get stuck in loops. Example: Iasi to Fagaras... Iasi Neamt Iasi Neamt Complete in finite space with repeated-state checking Time? O(b m ), but a good heuristic can give dramatic improvement Space? O(b m ) keeps all nodes in memory Optimal? No c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 70

2.1 Means-ends Analysis Example of greedy search. (Used in SOAR problem solver.) Heuristic: Pick operations that reduce as much as possible the difference between the intermediate state and goal state. eg. Missionaries and cannibals <{MMMCCCB},{}> <{MMCC},{MCB}> <{MMMC},{CCB}> <{MMMCC},{CB}> <[MMMCCB},{C}> <{MMM},{CCCB}> <{MMMCB},{CC}> <{MC},{MMCCB}> <{MMCCB},{MC}> <{CC},{MMMCB}> <{CCCB},{MMM}> <{C},{MMMCCB}> <{CCB},{MMMC}> <{MCB},{MMCC}> <{},{MMMCCCB}> Indicates best choice in all states except for {MC},{MMCCB} and {MMCCB},{MC} c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 71

3. A search Greedy search minimises estimated cost to goal, and thereby (hopefully) reduces search cost, but is neither optimal nor complete. Uniform-cost search minimises path cost so far and is optimal and complete, but is costly. Can we get the best of both worlds...? Yes! Just add the two together to get estimate of total path length of solution as our evaluation function... Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach n h(n) = estimated cost to goal from n f(n) = estimated total cost of path through n to goal c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 72

3. A search Arad 366 75 140 118 Zerind Sibiu Timisoara 449 393 447 140 99 151 80 Arad Rimnicu Oradea Fagaras Vilcea 646 526 417 413 99 211 146 97 80 Sibiu Bucharest Craiova Pitesti Sibiu 591 450 526 415 553 97 138 101 Rimnicu Vilcea Craiova Bucharest 607 615 418 c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 73

3. A search A heuristic h is admissible iff h(n) h (n) for all n where h (n) is the true cost from n. i.e. h(n) never overestimates e.g., h SLD (n) never overestimates the actual road distance Can prove: if h(n) is admissible, f(n) provides a complete and optimal search! called A search. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 74

3.1 Optimality of A Theorem: A search is optimal Proof Suppose some suboptimal goal G 2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G 1. Start n G G 2 f(g 2 ) = g(g 2 ) since h(g 2 ) = 0 > g(g 1 ) since G 2 is suboptimal g(n) + h(n) since h is admissible = f(n) Since f(g 2 ) > f(n), A will not select G 2 for expansion c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 75

3.2 Monotonicity and the pathmax equation To get a more intuitive view, we consider the f-values along any path. For many admissible heuristics, f-values increase monotonically (see Romania problem). For some admissible heuristics, f may be nonmonotonic ie it may decrease at some points. e.g., suppose n is a successor of n n g=5 h=4 f=9 1 But f = 8 is redundant! n g =6 h =2 f =8 f(n) = 9 true cost of a path through n is 9 true cost of a path through n is 9 Pathmax modification to A : f(n ) = max(g(n ) + h(n ),f(n)) With pathmax, f is always increases monotonically c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 76

3.3 Contours Lemma: A (with pathmax) expands nodes in order of increasing f value Gradually adds f-contours of nodes (cf. breadth-first/uniformcost adds layers or circles A stretches towards goal) O Z N A 380 400 S F I V T R L P D M C 420 G B U H E If f is cost of optimal solution path: A expands all nodes with f(n) < f A expands some nodes with f(n) = f Can see intuitively that A is complete and optimal. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 77

3.4 Properties of A Complete Yes, unless there are infinitely many nodes with f f(g) Time Exponential in [relative error in h length of soln.] Space Keeps all nodes in memory (see below) Optimal Yes cannot expand f i+1 until f i is finished Among optimal algorithms of this type A is optimally efficient! ie. no other algorithm is guaranteed to expand fewer nodes. Proof Any algorithm that does not expand all nodes in each contour may miss an optimal solution. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 78

4. Admissible heuristics Straight line distance is an obvious heuristic for distance planning. What about other problems? This section examine heuristics in more detail. E.g., two heuristics for the 8-puzzle: 5 4 51 42 3 6 1 8 68 84 7 3 2 7 6 25 Start State Goal State h 1 (n) = number of misplaced tiles h 2 (n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) h 1 (S) =?? h 2 (S) =?? Are both admissible? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 79

4.1 Measuring performance Quality of heuristic can be characterised by effective branching factor b. Assume: A expands N nodes solution depth d b is branching factor of uniform tree, depth d with N nodes: N = 1 + b + (b ) 2 + + (b ) d tends to remain fairly constant over problem instances can be determined empirically fairly good guide to heuristic performance a good heuristic would have b close to 1 c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 80

4.1 Measuring performance Example Effective branching factors for iterative deepening search and A with h1 and h2 (averaged over 100 randomly generated instances of 8-puzzle for each solution length): informed better than uninformed h2 better than h1 Is h2 always better than h1? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 81

4.2 Dominance Yes! We say h 2 dominates h 1 if h 2 (n) h 1 (n) for all n (both admissible). dominance better efficiency h 2 will expand fewer nodes on average than h 1 Proof A will expand all nodes n with f(n) < f. A will expand all nodes with h(n) < f g(n) But h 2 (n) h 1 (n) so all nodes expanded with h 2 will also be expanded with h 1 (h 1 may expand others as well). always better to use an (admissible) heuristic function with higher values c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 82

4.3 Inventing heuristics relaxed problems How can we come up with a heuristic? Can the computer do it automatically? A problem is relaxed by reducing restrictions on operators cost of exact solution of a relaxed problem is often a good heuristic for original problem Example if the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h 1 (n) gives the shortest solution if the rules are relaxed so that a tile can move to any adjacent square, then h 2 (n) gives the shortest solution Note: Must also ensure heuristic itself is not too expensive to calculate. Extreme case: perfect heuristic can be found by carrying out search on original problem. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 83

4.4 Automatic generation of heuristics If problem is defined in suitable formal language possible to construct relaxed problems automatically. may be eg. 8-puzzle operator description A is adjacent to B & B is blank can move from A to B Relaxed rules (eliminate preconditions) A is adjacent to B can move from A to B B is blank can move from A to B can move from A to B Absolver (Prieditis 1993) new heuristic for 8-puzzle better than any existing one first useful heuristic for Rubik s cube! c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 84

5. Memory-bounded Search Good heuristics improve search, but many problems are still too hard. Usually memory restrictions that impose a hard limit. (eg. recall estimates for breadth-first search ) Depth Nodes Time Memory 0 1 1 millisecond 100 bytes 2 111.1 seconds 11 kilobytes 4 11,111 11 seconds 1 megabyte 6 10 6 18 minutes 111 megabytes 8 10 8 31 hours 11 gigabytes 10 10 10 128 days 1 terabyte 12 10 12 35 years 111 terabytes 14 10 14 3500 years 11,111 terabytes This section algorithms designed to save memory. IDA SMA c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 85

5.1 Iterative Deepening A (IDA ) Recall uninformed search uniform-cost/breadth-first search + completeness, optimality exponential space usage depth-first + linear space usage incomplete, suboptimal Solution: iterative-deepening explores uniform-cost trees, or contours, using linear space. O Z A S F T R L P B M c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 86

5.1 Iterative Deepening A (IDA ) Can we do the same with A? O Z N A 380 400 S F I V T R L P D M C 420 G B U H E Contours more directed, but same technique applies! Modify depth-limited search to use f-cost limit, rather than depth limit IDA Complete? Yes (with admissible heuristic) Optimal? Yes (with admissible heuristic) Space? Linear in path length Time?? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 87

5.1 Iterative Deepening A (IDA ) Time complexity of IDA Depends on number of different values f can take on. small number of values, few iterations eg. 8-puzzle many values, many iterations eg. Romania example, each state has different heuristic only one extra town in each contour Worst case: A expands N nodes, IDA goes through N iterations 1 + 2 + + N O(N 2 ) (Recall N in turn is exponential in d relative error in h.) How does this compare with ID? c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 88

5.1 Iterative Deepening A (IDA ) A solution: increase f-cost limit by fixed amount ǫ in each iteration returns solutions at worst ǫ worse than optimal Called ǫ-admissible. IDA was first memory-bounded optimal heuristic algorithm and solved many practical problems. c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 89

5.2 Simplified memory-bounded A (SMA ) Uses all available memory. How does it work? Need to generate successor nodes but no memory left drop, or forget, least promising nodes. Keep record of best f-cost of forgotten nodes in ancestor. Only regenerate nodes if all more promising options are exhausted. Example (values of forgotten nodes in parentheses) c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 90

5.2 Simplified memory-bounded A (SMA ) c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 91

5.2 Simplified memory-bounded A (SMA ) Performance Complete if available memory is sufficient to store the shallowest solution path. Optimal if available memory is sufficient to store the shallowest solution path. Otherwise best solution given available memory. Summary Solves significantly more difficult problems than A. Performs well on highly-connected state spaces and real-valued heuristics on which A has difficulty. Susceptible to continual switching between candidate solution paths. ie. limit in memory can lead to intractible computation time c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 92

The End c CSSE. Includes material c S. Russell & P. Norvig 1995,2003 with permission. CITS4211 Informed search algorithms Slide 93