ai module 3
ai module 3
Informed
Search
Chapter 4
Adapted from slides by Some material adopted from notes
Tim Finin and by Charles R. Dyer, University of
Marie desJardins. Wisconsin-Madison
Outline
• Heuristic search
• Best-first search
– Greedy search
– Beam search
– A, A*
– Examples
• Memory-conserving variations of A*
• Heuristic functions
• Iterative improvement methods
– Hill climbing
– Simulated annealing
– Local beam search
– Genetic algorithms
• Online search
Heuristic
Webster's Revised Unabridged Dictionary (1913) (web1913)
Heuristic \Heu*ris"tic\, a. [Gr. ? to discover.] Serving to discover or find
out.
The Free On-line Dictionary of Computing (15Feb98)
heuristic 1. <programming> A rule of thumb, simplification or educated
guess that reduces or limits the search for solutions in domains that are
difficult and poorly understood. Unlike algorithms, heuristics do not
guarantee feasible solutions and are often used with no theoretical
guarantee. 2. <algorithm> approximation algorithm.
From WordNet (r) 1.6
heuristic adj 1: (computer science) relating to or using a heuristic rule 2:
of or relating to a general formulation that serves to guide investigation
[ant: algorithmic] n : a commonsense rule (or set of rules) intended to
increase the probability of solving some problem [syn: heuristic rule,
heuristic program]
Informed methods add
domain-specific information
• Add domain-specific information to select the best path
along which to continue searching
• Define a heuristic function, h(n), that estimates the
“goodness” of a node n.
• Specifically, h(n) = estimated cost (or distance) of minimal
cost path from n to a goal state.
• The heuristic function is an estimate, based on domain-
specific information that is computable from the current
state description, of how close we are to a goal
Heuristics
• All domain knowledge used in the search is encoded in the
heuristic function h.
• Heuristic search is an example of a “weak method” because
of the limited way that domain-specific information is used to
solve the problem.
• Examples:
– Missionaries and Cannibals: Number of people on starting river bank
– 8-puzzle: Number of tiles out of place
– 8-puzzle: Sum of distances each tile is from its goal position
• 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 dead-end from which a goal cannot
be reached
Weak vs. strong methods
• We use the term weak methods to refer to methods that are
extremely general and not tailored to a specific situation.
• Examples of weak methods include
– Means-ends analysis is a strategy in which we try to represent the
current situation and where we want to end up and then look for ways to
shrink the differences between the two.
– Space splitting is a strategy in which we try to list the possible solutions
to a problem and then try to rule out classes of these possibilities.
– Subgoaling means to split a large problem into several smaller ones that
can be solved one at a time.
• Called “weak” methods because they do not take advantage of
more powerful domain-specific heuristics
Best-first search
• Order nodes on the nodes list by increasing
value of an evaluation function, f(n), that
incorporates domain-specific information in
some way.
• This is a generic way of referring to the class
of informed methods.
Greedy search
• Use as an evaluation function f(n) = h(n),
sorting nodes by increasing values of f. a
• Selects node to expand believed to be
closest (hence “greedy”) to a goal node h=2 b g h=4
(i.e., select node with smallest f value)
• Not complete 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
• h*(n) is the (hypothetical) perfect heuristic.
• Since h(n) ≤ h*(n) for all n, h is admissible
• Optimal path = S B G with cost 9.
Greedy search
f(n) = h(n)
node expanded nodes list
{ S(8) }
S { C(3) B(4) A(8) }
C { G(0) B(4) A(8) }
G { B(4) A(8) }
Height Defined by
Evaluation Function
Hill-climbing search
• If there exists a successor s for the current state n such that
– h(s) < h(n)
– h(s) ≤ h(t) for all the successors t of n,
• then move from n to s. 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.
• Corresponds to Beam search with a beam width of 1 (i.e.,
the maximum size of the nodes list is 1).
• 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
f(n) = -(number of tiles out of place)
Exploring the Landscape
• Local Maxima: peaks that
aren’t the highest point in the local maximum
space
plateau
• Plateaus: the space has a
broad flat region that gives
the search algorithm no
direction (random walk)
ridge
• Ridges: flat like a plateau, but
with drop-offs to the sides; Image from: http://classes.yale.edu/fractals/CA/GA/Fitness/Fitness.html
1 2 5
move 7 4 f = -7
start up
8 6 3 goal
1 2 5 1 2 3
8 7 4 8 4 f=0
move
6 3 right 7 6 5
f = -6 1 2 5
8 7 4 f = -7
f = -(manhattan distance)
6 3
Gradient ascent / descent
• Competitive ratio = Path cost found* / Path cost that could be found**
* On average, or in an adversarial scenario (worst case)
** If the agent knew the nature of the space, and could use offline search