1 / 30

State Space

State Space. Heuristic Search. Three Algorithms. Backtrack Depth First Breadth First All work if we have well-defined: Goal state Start state State transition rules But could take a long time. Heuristic. An informed guess that guides search through a state space

mali
Download Presentation

State Space

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. State Space Heuristic Search

  2. Three Algorithms • Backtrack • Depth First • Breadth First All work if we have well-defined: • Goal state • Start state • State transition rules But could take a long time

  3. Heuristic • An informed guess that guides search through a state space • Can result in a suboptimal solution

  4. Blocks World: A Stack of Blocks Start Goal A D B C C B D A Two rules: clear(X)  on(X, table) clear(X) ^ clear(Y)  on(X,Y)

  5. All Three Algorithms will find a solution Partial Look At Search Space A B C D B C DA C BC B A D AD Etc.

  6. Heuristic 1 • For each block that is resting where it should, subtract 1 • For each block that is not resting where it should, add 1

  7. Hill Climbing • At every level, generate all children • Continue down path with lowest score Define three functions: f(n) = g(n) + h(n) Where: h(n) is the heuristic estimate for n--guides the search g(n) is path length from start to current node—ensures that we choose node closest to root when more than 1 have same h value

  8. Problem: heuristic is local Given C and CB B DA A D At level n The f(n) of each structure is the same f(n) = g(n) = (1+1-1-1) = g(n) But which is actually better

  9. The vertical structure must be undone entirely C B B A A A D C DCB ABCD B C D ACD B AD D C B A For a total of 6 moves

  10. But CB C D DA B C AD B A 2 moves

  11. Task Design a global heuristic that takes the entire structure into account • Subtract 1 for each block that has correct support structure • Add 1 for each block in an incorrect support structure

  12. f(n) = g(n) + (3+2+1+0) =g(n) + 6 C B A goal D D C B A CB f(n) = g(n) + (1 + 0 -1+ 0) = g(n) DA So the heuristic correctly chose the second structure

  13. Leads to a New Algorithm: Best First The Road Not Taken Best first • Keeps nodes on open in a priority queue ordered by h(n) so that if it goes down a bad path that at first looks good, it can retry a new path • Contains algorithm for generating h(n) • Nodes could contain backward pointers so that path back to root can be recovered

  14. list best_first(Start) { open = [start], closed = []; while (!open.isEmpty()) { cs = open.serve(); if (cs == goal) return path; generate children of cs; for each child { case: { child is on open; //node has been reached by a shorter path if (g(child) < g(child) on open) g(child on open) = g(child); break; child is on closed; if (g(child < g(child on closed)) { //node has been reached by a shorter path and is more attractive remove state from closed; open.enqueue(child); } break; default: { f(child) = g(child) + h(child);//child has been examined yet open.enqueue(child); } } } closed.enqueue(cs);//all cs’ children have been examined. open.reorder);//reorder queue because case statement may have affected ordering } return([]); //failure }

  15. State Space of a Hypothetical Search Next Slide • Goal: P • States with attached evaluations are those generated by best-first • States expanded by best-first are indicated in bold • Just before evaluating O, closed contains HCBA • Just before evaluating O, open contains OPGEFD

  16. Admissibility • A search algorithm is admissible if it finds the optimal path whenever one exists • BF is admissible • DF is not admissible • Suppose on the previous slide Node S were replaced by a P • The optimal path is ACHP • But DF discovers ABEKP

  17. Algorithm A Uses • Best First • f(n) = g(n) + h(n)

  18. f* f*(n) = g*(n) + h*(n) Where • g*(n) is the cost of the shortest path from start to n • h*(n) is the cost of the shortest path from n to goal So, f*(n) is the actual cost of the optimal path

  19. Consider g*(n) • g(n) – actual cost to n • g*(n) – shortest path from start to n So g(n) >= g*(n) When g*(n) = g(n), the search has discovered the optimal path to n

  20. Consider h*(n) • We can’t know it unless exhaustive search is possible and we’ve already searched the state space • But we can know sometimes if a given h-1(n) is bounded above by some h-2(n)

  21. 8-puzzle Example 283 123 164 -> 8 4 7 5 765 h-1(n)  number of tiles not in goal position = 5 (1,2,6,8, B) H-2(n)  number of moves required to move them to goal (T1 = 1, T2 = 1, T6 = 1, T8 = 2, TB = 1) = 6 So h-1(n) <= h-2(n)

  22. h-2(n) cannot exceed h*(n) because each tile has to be moved a certain distance to reach goal no matter what. h-2(n) could equal h*(n) h-1(n) is certainly <= h-2(n) which requires moving each incorrect tile at least as far as h-1(n) So, h-1(n) <= h-2(n) <=h*(n)

  23. Leads to a Definition A* If algorithm A uses a heuristic that returns a value h(n) <= h*(n) for all n, then it is called A*

  24. Claim All A* algorithms are admissible Suppose: • h(n) = 0 and so <= h*(n) Search will be controlled by g(n) If g(n) = 0, search will be random If g(n) is the actual cost to n, f(n) becomes BF because the sole reason for examining a node is its distance from start. We already know that this terminates in an optimal solution

  25. h(n) = h*(n) Then the algorithm will go directly to the goal since h*(n) computes the shortest path to the goal Therefore, if our algorithm is between these two extremes, our search will always result in an optimal solution Call h(n) = 0, h’(n) So, for any h such that h’(n) <= h(n) <= h*(n) we will always find an optimal solution The closer our algorithm is to h’(n), the more extraneous nodes we’ll have to examine along the way

  26. Informedness For any two A* heuristics, h-a, h-b If h-a(n) <= h-b(n), h-b(n) is more informed.

  27. Comparison • h-a is BF • h-b is the # of tiles out of place • Since h-a is 0, h-b is better informed than h-a

  28. P. 149 Comparison of two solutions that discover the optimal path to the goal state: BF: h(n) = 0 h(n) = number of tiles out of place The better informed solution examines less extraneous information on its path to the goal

More Related