Presentation is loading. Please wait.

Presentation is loading. Please wait.

Heuristic searching. State spaces zA state space consists of yA (possibly infinite) set of states xThe start state represents the initial problem xEach.

Similar presentations


Presentation on theme: "Heuristic searching. State spaces zA state space consists of yA (possibly infinite) set of states xThe start state represents the initial problem xEach."— Presentation transcript:

1 Heuristic searching

2 State spaces zA state space consists of yA (possibly infinite) set of states xThe start state represents the initial problem xEach state represents some configuration reachable from the start state xSome states may be goal states (solutions) yA set of operators xApplying an operator to a state transforms it to another state in the state space xNot all operators are applicable to all states

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

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

5 Example 3: Missionaries and cannibals z3 missionaries, 3 cannibals, 1 boat need to cross the Limpopo river zCannibals may never outnumber missionaries zInitial state is (3, 3, 1), representing the number of missionaries, cannibals, boats on the initial side zThe goal state is (0, 0, 0) zOperators are addition or subtraction of the vectors (1 0 1), (2 0 1), (0 1 1), (0 2 1), (1 1 1) zOperators apply if result is between (0 0 0) and (3 3 1)

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

7 The basic search algorithm zInitialize: put the start node into OPEN zwhile OPEN is not empty ytake a node N from OPEN yif N is a goal node, report success yput 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 zThe result is a breadth-first search zIf we find a path, it will be a shortest-possible path, because we look first near the start node zSpace 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 zThe result is a depth-first search zIf 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 zSet LIMIT to zero zdo forever yDo a depth-first search up to LIMIT levels deep yIf a goal is found, return success,  else add 1 to LIMIT zEach time through the loop we start all over! zIf we find a path, it will be shortest-possible path zOnly requires linear space, because it's all DFS zIncreased time requirements are only linear!

11 Heuristic searching zAll the previous searches have been blind yThey make no use of any knowledge of the problem yIf we know something about the problem, we can usually do much, much better zExample: 15-puzzle yFor each piece, figure out how many moves away it is from its goal position, if no other piece were in the way yThe total of these gives a measure of distance from goal yThis is a heuristic measure

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

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

14 The A* algorithm zSuppose:  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 zThen  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*? zMemory usage depends on the heuristic function  If h(N) = constant, A* = breadth-first yIf 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* zA* may require exponential storage zSolution: Iterative-deepening A* (IDA*) yJust like Iterative Deepening, but... ...instead of using g(N) to cut off searching... ...use f(N) zIDA* gives the same results as A* zSince IDA* is basically a depth-first search, storage requirements are linear in length of path

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

19 The End


Download ppt "Heuristic searching. State spaces zA state space consists of yA (possibly infinite) set of states xThe start state represents the initial problem xEach."

Similar presentations


Ads by Google