Heuristic Search

Search in Artificial Intelligence
Find the next move in chess, checkers.
Scheduling: finding a good class schedule.
Theorem proving: given a set of axioms and
inference rules, find a proof of a theorem.
Planning: find a sequence of actions to achieve
a goal for a robot.
Natural language understanding: find the best
parse of a sentence.
Dimensions of Search Problems
In its general form: find a desired object
among a set of objects.
Sometimes, you don’t even know if the object
exists or not.
In other cases, the goal is to find the best
object.
Blind vs. informed search.
Specifying a search problem?
What are states (nodes in graph)?
What are the operators (arcs between
nodes)?
Initial state?
Goal test
Metric (e.g., distance to goal)
E.g., Eight Puzzle
7 2
4 1
8 5
3
6
1 2
4 5
7 8
3
6
3
Search
Types of Search
Blind
Heuristic & optimization
Adversary Search
Analysis
Completeness
Time complexity
Space Complexity
Guaranteed to find best solution?
Guaranteed to find the closest solution?
Search Strategies
Blind Search
Generate & test
Depth first search
Breadth first search
Iterative deepening search
Iterative broadening search
Heuristic search
Optimizing search
5
Depth First Search
Maintain stack of nodes to visit
Evaluation
Complete?
Not for infinite spaces
Time Complexity?
a
O(b^d)
Space Complexity?
b
e
O(d)
c
d
f
g
h
Breadth First Search
Maintain queue of nodes to visit
Evaluation
Complete?
Yes
a
Time Complexity?
O(b^d)
b
Space Complexity?
c
O(b^d)
d
e
f
g
h
Iterative Deepening Search
DFS with limit; incrementally grow limit
Evaluation
Complete?
Yes
a b e
Time Complexity?
O(b^d)
c f
Space Complexity?
d i
O(d)
g
h
j
k
L
Search Strategies
 Blind Search
Heuristic Search
Best-first
Beam
Hill climbing
Simulated annealing
Optimizing Search
9
Heuristic Search
A heuristic (metric) is:
Function from a state to a real number
Low number means state is close to goal
High number means state is far from the goal
Best First Search
Idea
Breadth first but use priority queue instead of a
queue
Evaluation
a b e
Complete?
No
Time Complexity?
c f
d i
O(b^d)
Space Complexity? g
O(b^d)
h
j
k
L
Beam Search
Idea
Best first but only keep N best items on priority
queue
Evaluation
a b e
Complete?
No
Time Complexity?
c f
d i
O(b^d)
Space Complexity? g
O(b + N)
h
j
k
L
Hill Climbing
Idea
Always choose best child; no backtracking
Evaluation
Complete?
a b e
No - suffers from plateau, local maxima, ridges
Time Complexity?
O(b^d)
c f
d i
but only in pathological cases
Space Complexity?
O(b)
g
h
j
k
L
Simulated Annealing
Objective: avoid local minima
Technique:
For the most part use hill climbing
Occasionally take non-optimal step
Reduce probability(non-optimal) over time
Comparison to Hill Climbing
Completeness?
Speed?
Space Complexity?
temp
Search Strategies
 Blind Search
 Heuristic Search
Optimizing Search
A*
IDA*
SMA*
Objective is to find
the very best solution.
15
A* Search
Idea
{
Best first search with admissible heuristic
Plus keep checking until all possibilities look worse
Evaluation
Finds optimal solution?
Yes
Time Complexity?
O(b^d)
Space Complexity?
O(b^d)
Admissible Heuristics
f(x) = g(x) + h(x)
g: cost so far
h: underestimate of remaining costs
e
a
12
8
d
f
10
8
14
b
20
For eight puzzle?
7 2
4 1
15
c
8
5
3
6
Importance of Heuristics
7 2
4 1
8 5
3
6
h1 = number of tiles in wrong place
h2 = sum of distances of tiles from correct loc
D
2
4
6
8
10
12
14
18
24
IDS
10
112
680
6384
47127
364404
3473941
A*(h1)
6
13
20
39
93
227
539
3056
39135
A*(h2)
6
12
18
25
39
73
113
363
1641
Iterative Deepening A*
Like iterative deepening depth first, but...
Depth bound modified to be an f-cost limit
Contour lines bounding search
F=21
e
F=15
a
f
b
c
d
SMA*
Problem is f-cost bound increases slowly
Must do iterative search again and again
Storing little state between each iteration
Just one number: next highest contour level
SMA*
Uses all available memory to store state
Duplicates minimal work
Optimal in a number of nice ways
Adversary Search
Game playing: want to make the move for
which the opponent cannot respond well.
a b e
max
c f
min
g
max
min
max g 1
c f
d i
h
1
h -1
j
c f
-1
L
c f
1
1
h
k
-1
g
c f
-1 g
h -1
Alpha-beta Pruning
 max
a b e
min
c f
max
min
max
g
c f
h
c f
d i
j
k
c f
L
c f