A* Search Introduction to AI. What is an A* Search? A greedy search method minimizes the cost to the goal by using an heuristic function, h(n). It works.

Slides:



Advertisements
Similar presentations
Lights Out Issues Questions? Comment from me.
Advertisements

Informed Search Algorithms
Notes Dijstra’s Algorithm Corrected syllabus.
Informed search algorithms
1 Search Problems (read Chapters 3 and 4 of Russell and Norvig) Many (perhaps most) AI problems can be considered search problems. This can be modeled.
Problem Solving: Informed Search Algorithms Edmondo Trentin, DIISM.
Informed Search Methods Copyright, 1996 © Dale Carnegie & Associates, Inc. Chapter 4 Spring 2004.
Solving Problem by Searching
G5AIAI Introduction to AI
G5BAIM Artificial Intelligence Methods Graham Kendall Blind Searches.
AI Principles, Semester 2, Week 1, Lecture 3, Search Examples of problems which are solved by search Setting the scene: your Romanian holiday search problem.
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
Informed search.
Introduction to Artificial Intelligence A* Search Ruth Bergman Fall 2002.
Artificial Intelligence
Cooperating Intelligent Systems Informed search Chapter 4, AIMA.
Oregon State University – CS430 Intro to AI (c) 2003 Thomas G. Dietterich and Devika Subramanian1 Search-Based Agents  Appropriate in Static Environments.
Introduction to Artificial Intelligence Problem Solving Ruth Bergman Fall 2002.
Introduction to Artificial Intelligence A* Search Ruth Bergman Fall 2004.
Informed Search Methods How can we make use of other knowledge about the problem to improve searching strategy? Map example: Heuristic: Expand those nodes.
Problem Solving and Search in AI Heuristic Search
CSC344: AI for Games Lecture 4: Informed search
Rutgers CS440, Fall 2003 Heuristic search Reading: AIMA 2 nd ed., Ch
Artificial Intelligence Problem solving by searching CSC 361 Prof. Mohamed Batouche Computer Science Department CCIS – King Saud University Riyadh, Saudi.
Dr.Abeer Mahmoud ARTIFICIAL INTELLIGENCE (CS 461D) Dr. Abeer Mahmoud Computer science Department Princess Nora University Faculty of Computer & Information.
1 CS 2710, ISSP 2610 Chapter 4, Part 1 Heuristic Search.
2013/10/17 Informed search A* algorithm. Outline 2 Informed = use problem-specific knowledge Which search strategies? Best-first search and its variants.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Informed Search Methods. Informed Search  Uninformed searches  easy  but very inefficient in most cases of huge search tree  Informed searches  uses.
Advanced Artificial Intelligence Lecture 2: Search.
CSC3203: AI for Games Informed search (1) Patrick Olivier
CMSC 671 Fall 2010 Thu 9/9/10 Uninformed Search (summary) Informed Search Functional Programming (revisited) Prof. Laura Zavala,
Informed Search I (Beginning of AIMA Chapter 4.1)
Artificial Intelligence Problem solving by searching.
Introduction to Artificial Intelligence (G51IAI) Dr Rong Qu Blind Searches.
1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
Pengantar Kecerdasan Buatan 4 - Informed Search and Exploration AIMA Ch. 3.5 – 3.6.
Heuristic Search Foundations of Artificial Intelligence.
Introduction to Artificial Intelligence (G51IAI)
G5AIAI Introduction to AI Graham Kendall Heuristic Searches.
Informed Search 1.
Search Methodologies Fall 2013 Comp3710 Artificial Intelligence Computing Science Thompson Rivers University.
Romania with step costs in km
Romania. Romania Problem Initial state: Arad Goal state: Bucharest Operators: From any node, you can visit any connected node. Operator cost, the.
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
Uninformed Search ECE457 Applied Artificial Intelligence Spring 2008 Lecture #2.
Chapter 3.5 Heuristic Search. Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Artificial Intelligence (CS 370D)
Department of Computer Science
Heuristic Search Introduction to Artificial Intelligence
Introduction to Artificial Intelligence
Artificial Intelligence Problem solving by searching CSC 361
Chap 4: Searching Techniques Artificial Intelligence Dr.Hassan Al-Tarawneh.
HW #1 Due 29/9/2008 Write Java Applet to solve Goats and Cabbage “Missionaries and cannibals” problem with the following search algorithms: Breadth first.
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
Lecture 1B: Search.
CS 4100 Artificial Intelligence
COMP 8620 Advanced Topics in AI
Informed search algorithms
Informed search algorithms
Lecture 8 Heuristic search Motivational video Assignment 2
Artificial Intelligence
Chap 4: Searching Techniques
Artificial Intelligence
Artificial Intelligence: Theory and Practice Ch. 3. Search
Informed Search.
Presentation transcript:

A* Search Introduction to AI

What is an A* Search? A greedy search method minimizes the cost to the goal by using an heuristic function, h(n). It works by taking the ‘biggest bite’ from the problem and expanding the node that is judged to be closest to the goal state. However, although greedy search can considerably cut the search time, it is neither optimal nor complete. By comparison Uniform Cost Search (UCS) minimizes the cost of the path so far, g(n). If you recall, UCS was implemented by expanding the node with the lowest path cost. As previous animations have shown, this search pattern is both optimal and complete, but can be very inefficient. It would be nice if we could combine both these search strategies to get the advantages of both. An A* search allows precisely this.

Implementation An A* searches allows us to combine the evaluation functions of any heuristic search and a uniform cost search so that f(n) = g(n) + h(n) As g(n) gives the path cost from the start node to node n and h(n) gives the estimated cost of the cheapest path from n to the goal, we now have f(n) = estimated cost of the cheapest solution through n Given the above, we can now implement A* search as follows. Function A*-SEARCH(problem) returns a solution of failure Return BEST-FIRST-SEARCH(problem, g + h) The good thing about this strategy is that it can be proved to be optimal and complete, given a simple restriction on the h function.

Admissible Heuristics The restriction we mentioned on the previous slide for the h function is simply this: The h function must never overestimate the cost to reach the goal. Such an h is called an admissible heuristic. Another way of describing admissible functions is to say they are optimistic, as they always think the cost to the goal is less than it actually is. If we have an admissible h function, this naturally transfers to the f function as f never overestimates the actual cost to the best solution through n.

Important Note The following example demonstrating the A* search pattern is taken from the course textbook (Artificial Intelligence : A Modern Approach, Russell and Norvig, Prentice Hall, 1995, pages 95-99) If you are reading this book alongside your notes (and this is strongly recommended) you may notice some minor differences. For example, whereas in the book the authors expand ‘back’ to cities they have just come from, we ignore this in order to make the animation a little clearer. Please note that this minor change does not affect the algorithm as travelling to a city and then travelling back to where you have just come from is not going to be included in the optimal solution. One other small point about the course textbook. Figure 4.4 on page 98 has a minor error (at least, it certainly does in the 1995 edition). The expansion of Sibiu to Oradea reads = 526. It should read = 671. Fortunately, this error makes no difference to the way the algorithm operates.

Study this map of Romania. Note the distances between cities and try and calculate the shortest route between Arad and Bucharest. Then press space to see the optimal route marked in red. Arad Bucharest Oradea Zerind Faragas Neamt Iasi Vaslui Hirsova Eforie Urziceni Giurgui Pitesti Sibiu Dobreta Craiova Rimnicu Mehadia Timisoara Lugoj Sibiu Rimnicu Pitesti Optimal route is ( ) = 418 miles The optimal route between the two cities takes us through Sibiu, Rimnicu and Pitesti. Press space to continue with the slideshow.

A* in action Having established the optimal path between the two towns of Arad and Bucharest we can now test the efficiency of the A* search pattern in finding the same goal state. Remember that the A* search pattern is the union of two evaluation functions. In the following demonstration the A* search pattern evaluates the cost of the path so far (UCS), together with an admissible heuristic function based on the shortest line distance (SLD) between between the initial state and the goal location, such that –h SLD (n) = straight line distance between n and the goal location. The following is table of the straight line distances between some of the major Romanian cities and and the goal state, Bucharest.

Straight Line Distances to Bucharest TownSLD Arad366 Bucharest0 Craiova160 Dobreta242 Eforie161 Fagaras178 Giurgiu77 Hirsova151 Iasi226 Lugoj244 TownSLD Mehadai241 Neamt234 Oradea380 Pitesti98 Rimnicu193 Sibiu253 Timisoara329 Urziceni80 Vaslui199 Zerind374 We can use straight line distances as an admissible heuristic as they will never overestimate the cost to the goal. This is because there is no shorter distance between two cities than the straight line distance. Press space to continue with the slideshow.

Press space to see an A* search of the Romanian map featured in the previous slide. Note: Throughout the animation all nodes are labelled with f(n) = g(n) + h(n). However,we will be using the abbreviations f, g and h to make the notation simpler Oradea Zerind Fagaras Pitesti Sibiu Craiova Rimnicu Timisoara Bucharest Arad We begin with the initial state of Arad. The cost of reaching Arad from Arad (or g value) is 0 miles. The straight line distance from Arad to Bucharest (or h value) is 366 miles. This gives us a total value of ( f = g + h ) 366 miles. Press space to expand the initial state of Arad. F= F= 366 F= F= 449 F= F= 393 F= F= 447 Once Arad is expanded we look for the node with the lowest cost. Sibiu has the lowest value for f. (The cost to reach Sibiu from Arad is 140 miles, and the straight line distance from Sibiu to the goal state is 253 miles. This gives a total of 393 miles). Press space to move to this node and expand it. We now expand Sibiu (that is, we expand the node with the lowest value of f ). Press space to continue the search. F= F= 417 F= F= 671 F= F= 413 We now expand Rimnicu (that is, we expand the node with the lowest value of f ). Press space to continue the search. F= F= 415 F= F= 526 Once Rimnicu is expanded we look for the node with the lowest cost. As you can see, Pitesti has the lowest value for f. (The cost to reach Pitesti from Arad is 317 miles, and the straight line distance from Pitesti to the goal state is 98 miles. This gives a total of 415 miles). Press space to move to this node and expand it. We now expand Pitesti (that is, we expand the node with the lowest value of f ). Press space to continue the search. We have just expanded a node (Pitesti) that revealed Bucharest, but it has a cost of 418. If there is any other lower cost node (and in this case there is one cheaper node, Fagaras, with a cost of 417) then we need to expand it in case it leads to a better solution to Bucharest than the 418 solution we have already found. Press space to continue. F= F= 418 In actual fact, the algorithm will not really recognise that we have found Bucharest. It just keeps expanding the lowest cost nodes (based on f ) until it finds a goal state AND it has the lowest value of f. So, we must now move to Fagaras and expand it. Press space to continue. We now expand Fagaras (that is, we expand the node with the lowest value of f ). Press space to continue the search. Bucharest (2) F= F= 450 Once Fagaras is expanded we look for the lowest cost node. As you can see, we now have two Bucharest nodes. One of these nodes ( Arad – Sibiu – Rimnicu – Pitesti – Bucharest ) has an f value of 418. The other node (Arad – Sibiu – Fagaras – Bucharest (2) ) has an f value of 450. We therefore move to the first Bucharest node and expand it. Press space to continue Bucharest We have now arrived at Bucharest. As this is the lowest cost node AND the goal state we can terminate the search. If you look back over the slides you will see that the solution returned by the A* search pattern ( Arad – Sibiu – Rimnicu – Pitesti – Bucharest ), is in fact the optimal solution. Press space to continue with the slideshow.

Features of an A* Search A* is optimal and complete, but it is not all good news. It can be shown that the number of nodes that are searched is still exponential to the length of the search space for most problems. This has implications not only for the time taken to perform the search but also the space required. Of these two problems the search complexity is more serious. If you examine the animation on the previous slide you will notice an interesting phenomenon. Along any path from the root, the f-cost never decreases. This is no accident. It holds true for all admissible heuristics. A heuristic for which it holds is said to exhibit monotonicity. Because A* expands the leaf nodes of lowest f, we can see that an A* search fans out from the start node, adding nodes in concentric bands of increasing f-cost. These bands can be modelled as contours in the state space.

Oradea Zerind Fagaras Pitesti Sibiu Craiova Rimnicu Timisoara Bucharest Arad Map of Romania showing contours at f = 380, f = 400 and f = 420, with Arad as the start state. Note: Nodes inside a given contour have f-costs lower than the contour value. Press space to continue the slideshow

Take Note!! You will have noticed that finding our way from Arad to Bucharest was relatively easy. The only problem in working through the algorithm was that when we found our goal state the first time we ignored it as we had to expand an even lower cost node to see if it led to an even better solution. This idea is often missed by students and so often appears in examinations. END