University of Wisconsin - Madison | CS 540 Lecture Notes | C. R. Dyer |
h=3 /\ / \ h=2 h=4 | | | | h=1 h=1 | | | | h=1 goal | | h=1 | | goalAssuming all arc costs are 1, then Greedy Best-First search will find the left goal, which has a solution cost of 5, while the optimal solution is the path to the right goal, which has a cost of 3.
S ... Initial State S 8 /|\ /|\ 1/ 5 \8 / | \ / | \ / | \ A B C 8 A B 4 C 3 /|\ | / /|\ | / 3/ 7 9 4 /5 / | \ | / / | \|/ / | \|/ D E G .... Goal State D E G * * 0 Edge Costs Heuristic = Estimated Costs = h(n)Summary of g(n), h(n), f(n) = g(n) + h(n), as well as h*(n), the hypothetical perfect heuristic:
n g(n) h(n) f(n) h*(n) S 0 8 8 9 A 1 8 9 9 B 5 4 9 4 C 8 3 11 5 D 4 inf inf inf E 8 inf inf inf G 10/9/13 0 10/9/13 0 Notice that since h(n) <= h*(n) for all n, h is admissible Optimal path = S B G Cost of the optimal path = 9
Similarly, if we assume that tiles in the 8-puzzle are restricted to moving one square horizontally or vertically at a time, but we relax the assumption that only one tile can occur at a board position at a time, then each tile can be moved independently to its goal position, taking a number of steps equal to the Manhattan distance from its start position to its goal position. This leads to a heuristic which is the sum of the distances of the misplaced tiles to their goal positions. This heuristic is admissible.
^ | | y | f | / | / | / | / |/ +----------------> xConsider the state space to be the set of points in the x,y plane, and for each such point the height f is the value of the evaluation function for that state. This height function, f = f(x,y), defines a surface. The initial state corresponds to a point on this surface and the goal is to find a state where the height is a global maximum.
Hill-climbing (should be called Valley-Finding in this context where we are minimizing instead of maximizing a value) moves in the direction of steepest ascent since it moves to the successor (i.e., adjacent) node that increases f the most.
Notice that by considering the state space as a continuous space of points in the x,y plane, if the height surface is continuous (i.e., smooth so that derivatives are well-defined everywhere), then the direction of steepest ascent corresponds to the gradient direction = [df(x,y)/dx, df(x,y)/dy], and the search is called gradient ascent.
current = Initial-State(problem) for t = 1 to infinity do T = Schedule(t) ; T is the current temperature, which ; is monotonically decreasing with t if T=0 then return current ; halt when temperature = 0 next = Select-Random-Successor-State(current) deltaE = f(next) - f(current) ; If positive, next is ; better than current. ; Otherwise, next is ; worse than current. if deltaE > 0 then current = next ; always move to ; a better state else current = next with probability p = e^(deltaE / T) ; as T -> 0, p -> 0 ; as deltaE -> -infinity, p -> 0 end
Copyright © 1996-2003 by Charles R. Dyer. All rights reserved.