CH 04
CH 04
Search
chapter 4
Informed Methods Add
Domain-Specific Information
• Add domain-specific information to select what is the best
path to continue searching along
• Define a heuristic function, h(n), that estimates the
"goodness" of a node n with respect to reaching a goal.
• Specifically, h(n) = estimated cost (or distance) of minimal
cost path from n to a goal state.
• h(n) is about cost of the future search, g(n) past search
• h(n) is an estimate (rule of thumb), based on domain-
specific information that is computable from the current
state description. Heuristics do not guarantee feasible
solutions and are often without theoretical basis.
Heuristics
• Examples:
– Missionaries and Cannibals: Number of people on starting river
bank
– 8-puzzle: Number of tiles out of place (i.e., not in their goal
positions)
– 8-puzzle: Sum of Manhattan distances each tile is from its goal
position
– 8-queen: # of un-attacked positions – un-positioned queens
• In general:
– h(n) >= 0 for all nodes n
– h(n) = 0 implies that n is a goal node
– h(n) = infinity implies that n is a deadend from which a goal
cannot be reached
Best First Search
• Order nodes on the OPEN list by increasing
value of an evaluation function, f(n) , that
incorporates domain-specific information in
some way.
• Example of f(n):
– f(n) = g(n) (uniform-cost)
– f(n) = h(n) (greedy algorithm)
– f(n) = g(n) + h(n) (algorithm A)
• This is a generic way of referring to the class
of informed methods.
Greedy Search
• Evaluation function f(n) = h(n), sorting
open nodes by increasing values of f. a
• Selects node to expand believed to be
closest (hence it's "greedy") to a goal h=2 b g h=4
node (i.e., smallest f = h value)
• Not admissible, as in the example. h=1 c h h=1
1 A 8 5 B 4 8 C 3
3 9 h value
7 4 5 g value
4 D 8 E 9 G 0
goal state
Example
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 9 0 9 0
f(n) = h(n)
Solution space of P
h1(start) = 7
h2(start) = 18
h3(start) = 7
• Example: TSP. A legal tour is a (Hamiltonian) circuit
– It is a connected second degree graph (each node has
exactly two adjacent edges)
Removing the connectivity constraint leads to h1:
find the cheapest second degree graph from the
given graph
(with o(n^3) complexity)
Height Defined by
Evaluation Function
Hill Climbing Search
• If there exists a successor n’ for the current state n such that
– h(n’) < h(n)
– h(n’) <= h(t) for all the successors t of n,
• then move from n to n’. Otherwise, halt at n.
• Looks one step ahead to determine if any successor is better
than the current state; if there is, move to the best successor.
• Similar to Greedy search in that it uses h, but does not
allow backtracking or jumping to an alternative path since it
doesn’t “remember” where it has been.
• OPEN = {current-node}
• Not complete since the search will terminate at "local
minima," "plateaus," and "ridges."
Hill climbing example
2 8 3 1 2 3
start 1 6 4 h=4 goal 8 4 h=0
7 5 7 6 5
5 5 2
2 8 3 1 2 3
1 4 h=3 8 4 h=1
7 6 5 7 6 5
3 4
2 3 2 3
1 8 4 1 8 4 h=2
7 6 5 7 6 5
h=3 4