1 / 19

Heuristic searching

Heuristic searching. State spaces. A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each state represents some configuration reachable from the start state Some states may be goal states (solutions) A set of operators

Télécharger la présentation

Heuristic searching

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. Heuristic searching

  2. State spaces • A state space consists of • A (possibly infinite) set of states • The start state represents the initial problem • Each state represents some configuration reachable from the start state • Some states may be goal states (solutions) • A set of operators • Applying an operator to a state transforms it to another state in the state space • Not all operators are applicable to all states

  3. Example 1: Maze • A maze can be represented as a state space • Each state represents "where you are" in the maze • The start state represents your starting position • The goal state represents the exit from the maze • Operators (for a rectangular maze) are: move north, move south, move east, move west • Each operator takes you to a new state (maze location) • Operators may not always apply, because of walls in the maze

  4. Example 2: The 15-puzzle • The start state is some (almost) random configuration of the tiles • The goal state is as shown • Operators are • Move empty space up • Move empty space down • Move empty space right • Move empty space left • Operators apply if not against edge

  5. Example 3: Missionaries and cannibals • 3 missionaries, 3 cannibals, 1 boat need to cross the Limpopo river • Cannibals may never outnumber missionaries • Initial state is (3, 3, 1), representing the number of missionaries, cannibals, boats on the initial side • The goal state is (0, 0, 0) • Operators are addition or subtraction of the vectors (1 0 1), (2 0 1), (0 1 1), (0 2 1), (1 1 1) • Operators apply if result is between (0 0 0) and (3 3 1)

  6. State-space searching • Most problems in AI can be cast as searches on a state space • The space can be tree-shaped or graph-shaped • If a graph, need some way to keep track of where you have been, so as to avoid loops • The state space is often very, very large • We can minimize the size of the search space by careful choice of operators • Exhaustive searches don't work--need heuristics

  7. The basic search algorithm • Initialize: put the start node into OPEN • while OPEN is not empty • take a node N from OPEN • if N is a goal node, report success • put the children of N onto OPEN • Report failure • How do we choose which node to take from OPEN?

  8. Breadth-first searching • If we take the node that has been in OPEN the longest, we have a queue • The result is a breadth-first search • If we find a path, it will be a shortest-possible path, because we look first near the start node • Space requirements are exponential, because the queue will hold all the nodes at one level before we begin searching the next level

  9. Depth-first searching • If we take the node that has been in OPEN the least amount of time, we have a stack • The result is a depth-first search • If we find a path, it may be arbitrarily long • Space requirements are linear in the length of the path we find, because the stack holds only b nodes from each level, where b is the branching factor

  10. Iterative deepening • Set LIMIT to zero • do forever • Do a depth-first search up to LIMIT levels deep • If a goal is found, return success, • else add 1 to LIMIT • Each time through the loop we start all over! • If we find a path, it will be shortest-possible path • Only requires linear space, because it's all DFS • Increased time requirements are only linear!

  11. Heuristic searching • All the previous searches have been blind • They make no use of any knowledge of the problem • If we know something about the problem, we can usually do much, much better • Example: 15-puzzle • For each piece, figure out how many moves away it is from its goal position, if no other piece were in the way • The total of these gives a measure of distance from goal • This is a heuristic measure

  12. Heuristics • A heuristic is a rule of thumb for deciding which way to choose • There is no general theory for finding heuristics, because every problem is different • Choice of heuristics depends on knowledge of the problem space • There are many well-known heuristics for chess • This is where the "I" in "AI" comes in

  13. Best-first searching • Use the same basic search algorithm • Choose from OPEN the "best" node, that is, the one that seems to be closest to a goal • Generally, even very poor heuristics are significantly better than blind search, but... • No guarantee that the best path will be found • No guarantee on the space requirements

  14. The A* algorithm • Suppose: • you keep track of the distance g(N) that each node N you visit is from the start state • you have some heuristic function, h(N), that estimates the distance between node N and a goal • Then • f(N) = g(N) + h(N) gives you the (partially estimated) distance from the start node to a goal node • The A* algorithm is: choose from OPEN the node N with the smallest value of f(N)

  15. The A* formula • g(N) is the (known) distance from start to N • h(N) is the (estimated) distance from N to a goal • f(N) is our best guess as to the distance from start to N

  16. How good is A*? • Memory usage depends on the heuristic function • If h(N) = constant, A* = breadth-first • If h(N) is a perfect estimator, A* goes straight to goal • ...but if h(N) were perfect, why search? • Quality of solution also depends on h(N) • It can be proved that, if h(N) is optimistic (never overestimates the distance to a goal), then A* will find a best solution (shortest path to a goal)

  17. IDA* • A* may require exponential storage • Solution: Iterative-deepening A* (IDA*) • Just like Iterative Deepening, but... • ...instead of using g(N) to cut off searching... • ...use f(N) • IDA* gives the same results as A* • Since IDA* is basically a depth-first search, storage requirements are linear in length of path

  18. Conclusion • Many (or most) problems in AI can be represented as state-space searches • The best searches combine a basic blind search technique with heuristic knowledge about the problem space • A* and its variations, especially IDA*, are the best heuristic search techniques known

  19. The End

More Related