Beruflich Dokumente
Kultur Dokumente
1
Informed Search Informed Search
Define a heuristic function, h(n) • h(n) ≥ 0 for all nodes n
– uses domain-specific information in some way • h(n) close to 0 means we think n is close to a goal state
• h(n) very big means we think n is far from a goal state
– is (easily) computable from the current state
description
• All domain knowledge used in the search is encoded in
– estimates the heuristic function, h
• the "goodness" of node n
• how close node n is to a goal • An example of a “weak method” for AI because of the
• the cost of minimal cost path from node n to a goal limited way that domain-specific information is
state used to solve a problem (i.e., entirely contained in one
function definition)
Best-First Search
• It combines the best features of BFS and DFS to Best-First Search
follow a single path at a time but switch whenever
some competing path looks more promising than
the current one. • Sort nodes in the Frontier list by increasing
– BFS values of an evaluation function, f(n), that
• No Dead End incorporates domain-specific information
– DFS
• Get solution without expanding all competing branches
• This is a generic way of referring to the class
• Best first search is a kind of Hill Climbing of informed search methods
– but in pure hill climbing, we move on one path and
reject other paths
– but in best first search, other paths are not ignored
2
Greedy Best-First Search Greedy Best-First Search
3 7 9 4 5 3 7 9 4 5
D E G D E G
h=∞ h=∞ h=0 h=∞ h=∞ h=0
3
Greedy Best-First Search Greedy Best-First Search
4
Greedy Best-First Search Beam Search
• Use an evaluation function f(n) = h(n) as in
Greedy Best-First search, and restrict the
S maximum size of the Frontier to a constant, k
h=5
• Not complete 2 2 • Only keep the k best nodes as candidates for
A B
• Not optimal/admissible h=3 h=4
expansion, and throw away the rest
Greedy search finds the left goal 1 2 • More space efficient than Greedy Best-First
(solution cost of 7) C D Search, but may throw away a node on a solution
h=3 h=1 path
Optimal solution is the path to the 1 1
• Not complete
right goal (solution cost of 5) E G
h=2 goal • Not optimal/admissible
3
G
goal
5
Algorithm A* Search Admissible Heuristics are Good for
• Use the same evaluation function used by Algorithm A,
Playing The Price is Right
except add the constraint that for all nodes n in the
search space, h(n) ≤ h*(n), where h*(n) is the actual
cost of the minimum-cost path from n to a goal
• Complete S
n g(n) h(n) f(n) h*(n)
h=8
• Optimal / Admissible S
A 1 5 8
B
C A B C
h=8 h=4 h=3
D
E 3 7 9 4 5
G D E G
h=∞ h=∞ h=0
6
Example Example
g(n) = actual cost to get to node n g(n) = actual cost to get to node n
from start from start
Example Example
g(n) = actual cost to get to node n g(n) = actual cost to get to node n
from start from start
7
Example Example
g(n) = actual cost to get to node n g(n) = actual cost to get to node n
from start from start
Example Example
h(n) = estimated cost to get to a goal h(n) = estimated cost to get to a goal
from node n from node n
8
Example Example
Example Example
h*(n) = true cost of minimum-cost path h*(n) = true cost of minimum-cost path
from n to a goal from n to a goal
9
Example Example
h*(n) = true cost of minimum-cost path h*(n) = true cost of minimum-cost path
from n to a goal from n to a goal
Example Example
10
Example Example: Find Path from S to G
7 4 8 7 8
11
Admissible Heuristic Functions, h Admissible Heuristic Functions, h
• 8-Puzzle example
Example
1 5 Goal 1 2 3 Which of the following are admissible heuristics?
State State
2 6 3 4 5 6
7 4 8 7 8 h(n) = h*(n)
12
A and A* Algorithm for
A* Revisiting States
General State-Space Graphs
• One more complication: A* might revisit a Frontier = {S} where S is the start node
state (in Frontier or Explored), and discover Explored ={}
a better path Loop do
if Frontier is empty then return failure
B pick node, n, with min f value from Frontier
1 2 if n is a goal node then return solution
h=1
foreach each child, n’, of n do
S D 999 G
if n’ is not in Explored or Frontier
h=1 h=1 h=0 then add n’ to Frontier
1 C 1
else if g(n’) ≥ g(m) then throw n’ away
h=900 else add n’ to Frontier and remove m
Remove n from Frontier and add n to Explored
• Solution: Put D back in the priority queue,
Note: m is the node in Frontier or
using the smaller g value (and path) Variant of algorithm in Fig. 3.14 Explored that is the same state as n’
Consistency Consistency
• A heuristic, h, is called consistent (aka monotonic) if,
for every node n and every successor n’ of n, the Is this h consistent?
estimated cost of reaching the goal from n is no
greater than the step cost of getting to n’ plus the B
1 2
estimated cost of reaching the goal from n’: h=1
c(n, n’) ≥ h(n) − h(n’) S D 999 G
h=1 h=1 h=0
or, equivalently: h(n) ≤ c(n, n’) + h(n’) 1 C 1
• Triangle inequality for heuristics h=900
• Implies values of f along any path are nondecreasing h(C)=900, h(D)=1, c(C, D) = 1
• When a node is expanded by A*, the optimal path to but h(C) ≰ c(C,D) + h(D) since
that node has been found
900 ≰ 1 + 1, so h is NOT consistent
• Consistency is a stronger condition than admissibility (but h is admissible)
13
A* Search Is h is admissible A* Search
and/or
consistent?
3 7 9 4 5 3 7 9 4 5
D E G D E G
h=∞ h=∞ h=0 h=∞ h=∞ h=0
A* Search A* Search
14
A* Search A* Search
Oradea
71 234
Neamt
374 Zerind 87 226
151
75
Iasi
Arad
140 253 176
366 Sibiu
92
99 Fagaras 199
118
Vaslui
80
Rimnicu Vilcea
Timisoara 193
329 100
111
244 Pitesti 211
142
Lugoj 97
70 80 151
98
Hirsova
241 Mehadia 146 101 85
Urziceni
75 138 86
Bucharest
Drobeta 120
90 161
242 Craiova
160 Giurgiu 77 Eforie
15
16
Thank You
17