1 / 12

A Search

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

Mia_John
Télécharger la présentation

A Search

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. A* Search G5AIAI Introduction to AI

    2. What is an A* Search? A greedy search method minimises 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) minimises 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.

    3. 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 or 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.

    4. 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.

    5. 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 G5AIAI 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 146 + 380 = 526. It should read 291 + 380 = 671. Fortunately, this error makes no difference to the way the algorithm operates.

    7. 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 hSLD(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.

    8. Straight Line Distances to Bucharest

    10. 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.

    12. 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 has shown to be a problem in previous examinations. Take time to study the G5BAIM exams set in previous years. (these papers, with suggested answers, are available through the course web site and WebCT). If you look at question 1 of the 1997/8 paper you will see that the first time we reached the goal state it was the lowest cost node, so the search terminated. This was also true of question 1 in the 1998/9 G5BAIM paper. However, if you look at the first question of the 1999/2000 G5BAIM paper, you will see a similar scenario to the Arad to Bucharest problem. That is, the first time we reached the goal state there was still a lower cost node that had not been expanded. This caught out many (many, many) people in the exam.

More Related