AI Notes
AI Notes
CS-412
Week-05-Fall 2024
03/10/2024 12:47 pm
Informed (Heuristics) Searches
• Best-first search, Hill climbing, Beam search, A*
• New terms
• Heuristics
• Optimal solution
• Informedness
• Hill climbing problems
• Admissibility
• New parameters
• g(n) = estimated cost from initial state to state n
• h(n) = estimated cost (distance) from state n to closest goal
• h(n) is our heuristic
• Robot path planning, h(n) could be Euclidean distance
• 8 puzzle, h(n) could be #tiles out of place
• Search algorithms which use h(n) to guide search are heuristic
search algorithms
Informed (Heuristics) Searches
• Informed search strategy—one that uses domain-specific hints about
the location of goals—can find solutions more efficiently than an
uninformed strategy.
• The hints come in the form of a heuristic function,
denoted h(n):
Heuristic function h(n) = estimated cost of the cheapest path from the
state at node n to a goal state.
Best-First Search
• QueueingFn is sort-by-h
• Best-first search only as good as heuristic
• Example heuristic for 8 puzzle: Manhattan Distance
Example
Example
Example
Example
Example
Example
Example
Example
Example
Comparison of Search Techniques
DFS BFS UCS Best
Complete N Y Y N
Optimal N N Y N
Heuristic N N N Y
Time bm bd+1 bm bm
Space bm bd+1 bm bm
A*
• QueueingFn is sort-by-f
• f(n) = g(n) + h(n)
• Note that UCS and Best-first both improve search
• UCS keeps solution cost low
• Best-first helps find solution quickly
• A* combines these approaches
Power of f
• If heuristic function is wrong it either
• overestimates (guesses too high)
• underestimates (guesses too low)
• Overestimating is worse than underestimating
• A* returns optimal solution if h(n) is admissible
• heuristic function is admissible if never overestimates true cost to nearest
goal
• if search finds optimal solution using admissible heuristic, the search is
admissible
Example
Example
Example
Example
Example
Example
Example
Example
Optimality of A*
• Suppose a suboptimal goal G2 is on the open list
• Let n be unexpanded node on smallest-cost path to
optimal goal G1
global maxima
local maxima
Comparison of Search Techniques
DFS BFS UCS Best HC
Complete N Y Y N N
Optimal N N Y N N
Heuristic N N N Y Y
Time bm bd+1 bm bm mn
Space bm bd+1 bm bm b
Beam Search
• QueueingFn is sort-by-h
• Only keep best (lowest-h) n nodes on open list
• n is the “beam width”
• n = 1, Hill climbing
• n = infinity, Best first search
Example
Example
Example
Example
Example
Example
Example
Example
Example
Comparison of Search Techniques
DFS BFS UCS Best HC Beam
Complete N Y Y N N N
Optimal N N Y N N N
Heuristic N N N Y Y Y
Time bm bd+1 bm bm bm nm
Space bm bd+1 bm bm b bn