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.
3
Specifying a search problem?
What are states (nodes in graph)?What are the operators (arcs between
nodes)?Initial state?Goal testMetric (e.g., distance to goal)
E.g., Eight Puzzle
1 2 3
7 8
4 5 67 2 3
8 5
4 1 6
SearchTypes of Search
Blind Heuristic & optimization Adversary Search
Analysis Completeness Time complexity Space Complexity Guaranteed to find best solution? Guaranteed to find the closest solution?
5
Search Strategies
Blind Search Generate & test Depth first search Breadth first search Iterative deepening search Iterative broadening search
Heuristic searchOptimizing search
O(b^d)
O(d)
Not for infinite spaces
Depth First Search
a
b
c d
e
f g h
Maintain stack of nodes to visitEvaluation
Complete?
Time Complexity?
Space Complexity?
Yes
O(b^d)
O(b^d)
Breadth First Search
a
b c
d e f g h
Maintain queue of nodes to visitEvaluation
Complete?
Time Complexity?
Space Complexity?
Yes
O(b^d)
O(d)
Iterative Deepening Search
a b
c d
e
f
g h
DFS with limit; incrementally grow limitEvaluation
Complete?
Time Complexity?
Space Complexity?
j
i
k L
9
Search Strategies
Blind Search Heuristic Search
Best-first Beam Hill climbing Simulated annealing
Optimizing Search
Heuristic Search
A heuristic (metric) is: Function from a state to a real number
Low number means state is close to goalHigh number means state is far from the goal
Designing a good heuristic is very important!
(And hard)
More on this in a bit...
No
O(b^d)
O(b^d)
Idea Breadth first but use priority queue instead of a
queueEvaluation
Complete?
Time Complexity?
Space Complexity?
Best First Search
a b
c d
e
f
g h j
i
k L
No
O(b^d)
O(b + N)
Beam Search
Idea Best first but only keep N best items on priority
queueEvaluation
Complete?
Time Complexity?
Space Complexity?
a b
c d
e
f
g h j
i
k L
No - suffers from plateau, local maxima, ridges
O(b^d) but only in pathological cases
O(b)
Hill Climbing
Idea Always choose best child; no backtracking
Evaluation Complete?
Time Complexity?
Space Complexity?
a b
c d
e
f
g h j
i
k L
Simulated Annealing
Objective: avoid local minimaTechnique:
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
15
Search Strategies
Blind SearchHeuristic SearchOptimizing Search
A* IDA* SMA*
Objective is to find the very best solution.
A* Search
Idea Best first search with admissible heuristic Plus keep checking until all possibilities look worse
Evaluation Finds optimal solution?
Time Complexity?
Space Complexity?
Yes
O(b^d)
O(b^d)
Underestimates cost ofany solution which can reached from node
{
Admissible Heuristics
f(x) = g(x) + h(x)g: cost so farh: underestimate of remaining costs
a
b
c
d
e
f12
8
15
10
8
14 20
7 2 3
8 5
4 1 6
For eight puzzle?
Importance of Heuristics
D IDS A*(h1) A*(h2) 2 10 6 6 4 112 13 12 6 680 20 18 8 6384 39 2510 47127 93 3912 364404 227 7314 3473941 539 11318 3056 36324 39135 1641
h1 = number of tiles in wrong placeh2 = sum of distances of tiles from
correct loc
7 2 3
8 5
4 1 6
Iterative Deepening A*
Like iterative deepening depth first, but...Depth bound modified to be an f-cost
limitContour lines bounding search
a
b
c
d
e
fF=15
F=21
SMA*
Problem is f-cost bound increases slowlyMust do iterative search again and againStoring little state between each iteration
Just one number: next highest contour levelSMA*
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
c d
e
f
g h j
i
k L
c f
g h
c f
h
c f
g
c f
g h
max
max
max
min
min
1 -1
1-1 1 1
-1 -1
-1
Alpha-beta Pruning
a b
c d
e
f
g h j
i
k L
c f c f c f c f
max
max
min
min
max