Professional Documents
Culture Documents
Informed search
Chapter 4, AIMA
Romania Romania
Romania problem
Initial state: Arad
Find the minimum
distance path to
Bucharest.
1
Informed search Example heuristic function h(n)
Searching for the goal and knowing something
about in which direction it is.
Map
374
253
329
2
Romania problem: GBFS Romania problem: GBFS
Initial state: Arad Initial state: Arad
Find the minimum Find the minimum
distance path to distance path to
Bucharest. Bucharest.
380
366
176 253
193
= g(n) + h(n)
The straight-line distance = g(n) + h(n)
The straight-line distance
never overestimates the never overestimates the
true distance; it is an true distance; it is an
admissible heuristic. admissible heuristic.
A* on the Romania problem. A* on the Romania problem.
The final path cost = 418 km The final path cost = 418 km
This is the optimal solution. This is the optimal solution.
3
= g(n) + h(n)
The straight-line distance = g(n) + h(n)
The straight-line distance
never overestimates the never overestimates the
true distance; it is an true distance; it is an
admissible heuristic. admissible heuristic.
A* on the Romania problem. A* on the Romania problem.
The final path cost = 418 km The final path cost = 418 km
This is the optimal solution. This is the optimal solution.
distance path to
ti m
optimal path.
A Optimal path cost = C
Op
ti m
ti m
al
pa
pa
th
f ( A) = g ( A) + h( A) = g ( A) > C f ( A) = g ( A) + h( A) = g ( A) > C
f ( B ) = g ( B ) + h( B ) C f ( B ) = g ( B ) + h( B ) C
h(n) is admissive heuristic No suboptimal goal node will be selected before the optimal goal node
4
A* graph search with consistent
Is A* graph-search optimal?
heuristic is optimal
Previous proof works only for tree-search Theorem:
For graph-search we add the requirement If the consistency condition on h(n) is
of consistency (monotonicity): satisfied, then when A* expands a node n,
m it has already found an optimal path to n.
h ( n ) c ( n, m ) + h ( m )
h(m)
c(n,m)
n h(n) goal
This follows from the fact that consistency
means that f(n) is nondecreasing along a
c(n,m) = step cost for going from node n to path in the graph
node m (n comes before m) f ( m ) = g ( m ) + h ( m ) = g ( n ) + c ( n, m ) + h ( m ) g ( n ) + h ( n ) = f ( n )
if m comes after n along a path
Proof Proof
A* has reached node m along the A* has reached node m along the
alternative path B. alternative path B.
Path A is the optimal path to node m. Path A is the optimal path to node m.
A A
gA(m) gB(m) gA(m) gB(m)
B Node n precedes m along the optimal B Node n precedes m along the optimal
n path A. n path A.
fA(n) fA(m) fA(n) fA(m)
O
O
pt
pt
im
im
al
al
p
p
at
at
m m
Both n and m are on the fringe and Both n and m are on the fringe and
h
Proof A*
f B ( m) = g B ( m) + h( m) g A ( n) + h( n) = f A ( n ) Optimal
h(n) c A ( n, m) + h(m)
Complete
A
Optimally efficient
g B (m) g A (n) + c A (n, m) = g A (m)
B (no algorithm expands fewer nodes)
n Memory requirement exponential...(bad)
O
gA(m) gB(m)
al
p at
m
A* expands all nodes with f(n) < C
h
5
Romania problem: A* Romania problem: A*
Initial state: Arad Initial state: Arad Never tested nodes
Find the minimum Find the minimum
distance path to distance path to
Bucharest. Bucharest.
7 6 5
Best of these is SMA* Goal state
Both are admissive
A* on 8-puzzle, h1 heuristic
1 6 4
misplaced tiles. Goal reached
in node #13
7 5
h1 = 5, h2 = 5
Assignment: Expand the first
three levels of the search
1 2 3 tree using A* and the
8 4
heuristic h1.
7 6 5
Goal state
6
Domination Local search
It is obvious from the definitions that In many problems, one does not care
h1(n) h2(n). about the path only the goal state is of
We say that h2 dominates h1.
interest.
Use local searches that only keep track of
h1 (n) h2 (n) true path cost to node n the last state (saves memory).
Simulated annealing
Current node = ni.
Grab a neighbor node ni+1 and move there
if there is improvement or if the decrease
is small in relation to the temperature.
Accept the move with probability p
p = min[1, exp( f / T )]
Heuristic: Number of pairs of queens that threat each other. (This is a common and useful algorithm)
Best moves are marked.
Yields Boltzmann statistics
f (t + 1) = f (t ) + f (t )
7
Local beam search Genetic algorithms
Start with k random states Start with k random states
Expand all k states and test their children Selective breeding by mating the best
states. states (with mutation)
Keep the k best children states
Repeat until goal state is found