CS249-Uninformed-Search-2023
CS249-Uninformed-Search-2023
Search
Outline
§ Search Problems
§ Search trees and state space graphs
§ Uninformed search
§ Depth-first, Breadth-first, Uniform cost
§ Search graphs
§ Informed search
§ Greedy search, A* search
§ Heuristics, admissibility
§ Local search and optimization
§ Hill-climbing
§ Simulated annealing
§ Genetic algorithms
Disciplines which form the core of AI- inner circle
Fields which draw from these disciplines- outer circle.
Robotics
NLP
Search,
KR & Reasoning,
Expert
Machine Learning,
Systems
Planning
Computer
Vision
Search: Everywhere
C
B
A B C A
Table
Vision
§ A search needs to be carried out to find which point in the image of L
corresponds to which point in R. Naively carried out, this can become an
O(n2) process where n is the number of points in the retinal images.
R L
Two eye
system
World
Robot Path Planning
§ searching amongst the options of moving Left, Right, Up or Down.
Additionally, each movement has an associated cost representing the
relative difficulty of each movement. The search then will have to find the
optimal, i.e., the least cost path.
R O2
O1 Robot
Path
D
Natural Language Processing
§ search among many combinations of parts of speech on the way to
deciphering the meaning. This applies to every level of processing- syntax,
semantics, pragmatics and discourse.
If-conditions
the infection is primary-bacteremia
AND the site of the culture is one of the sterile sites
AND the suspected portal of entry is the gastrointestinal tract
THEN
there is suggestive evidence (0.7) that infection is bacteroid
(from MYCIN)
4 3 6 1 2 3
2 1 8 4 5 6
7 5 7 8
S G
8 2 8 2 7 8 2 7
3 4 7 3 4 6 3 4
5 1 6 5 1 5 1 6
I
Solution to the Search Problem
§ A solution is a path connecting the initial
node to a goal node (any one)
§ The cost of a path is the sum of the arc
costs along this path
§ An optimal solution is a solution path of
minimum cost
I
§ There might be
no solution !
G
8-Puzzle: Successor Function
8 2 8 2 7 8 2 7
3 4 7 3 4 6 3 4
5 1 6 5 1 5 1 6
§ Important ideas:
§ Frontier (aka fringe)
§ Expansion
§ Exploration strategy
§ Main question: which frontier nodes to explore?
(search strategy)
Implementation: general tree search
§ Implemented as a queue
d e p
Search
b c e h r q
Tiers
a a h r p q f
p q f q c G
q c G a
a
Depth First Search
a G
Strategy: expand b c
deepest node first
e
d f
Implementation:
Frontier is a LIFO S h
stack p r
q
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Comparisons
1 node
b
… b nodes
s tiers
b2 nodes
bs nodes
bm nodes
BFS
§ When complete?
§ Shallowest goal node is at d, a finite depth
§ Will eventually find after expanding all the
shallower nodes
§ b (branching factor) should be finite
Depth of Nodes to
Solution Expand Time Memory
START a
GOAL
d e p
b c e h r q
a a h r p q f
p q f q c G
q c a
G
a
DFS
§ With cycle checking and graph search (avoid repeated state and
redundant state), DFS is complete
§ d: finite
1 node
b
… b nodes
b2 nodes
m tiers
bm nodes
p 4 r
15
q
Notice that BFS finds the shortest path in terms of number of transitions. It
does not find the least-cost path.
We will quickly cover an algorithm which does find the least-cost path.
Uniform Cost Search
BFS: all step costs are equal 2 a G
b c
UCS: optimal with any step costs 1 8 2
2 e
Expand cheapest node first: 3 d f
9 2
S h 8
Frontier is a priority queue 1
1 p
q
r
What about zero-cost action? 15
S 0
d 3 e 9 p 1
b 4 c e 5 h 17 r 11 q 16
11
Cost a 6 a h 13 r 7 p q f
contours
p q f 8 q c G
q 11 c G 10 a
a
Uniform Cost Search
§ Zero-cost action: leads back to the same state (infinite
loop!)
§ Cost must be greater than some small positive constant
§ Sufficient for optimality and guarantees completeness
§ Cost always increases as we proceed
§ Algorithm always expands nodes in order of increasing
path cost
b
…
* UCS can fail if
C*/ tiers actions can get
arbitrarily cheap
Depth-limited search
§ For b = 10, d = 5,
§ NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111
§ NIDS = 50 + 400 + 3,000 + 20,000 + 100,000 = 123,450
§ NBFS =10+100+1,000+10,000+100,000+999,990=1,111,100
§ Complete? Yes
§ Time? d b1 + (d-1)b2 + … + bd = O(bd)
§ Space? O(bd)
§ Optimal? Yes, if step cost = 1
§ Wasteful as states generated multiple times
§ Not very costly
§ With the same branching factor at each level, most of the nodes
are at the bottom
§ Upper level nodes don’t cost much
When to use what?
§ Depth-First Search:
§ Many solutions exist
§ Know (or have a good estimate of) the depth of solution
§ Breadth-First Search:
§ Some solutions are known to be shallow
§ Uniform-Cost Search:
§ Actions have varying costs
§ Least cost solution is the required
This is the only uninformed search that worries about costs
§ Iterative-Deepening Search:
§ Large search space and depth of the solution is not known
Bi-directional search
§ Alternate searching from the start state toward the goal and from
the goal state toward the start
§ Stop when the frontiers intersect
§ Works well only when there are unique start and goal states and
when actions are reversible
§ Can lead to finding a solution more quickly
Bi-directional search
§ Motivation: bd/2 + bd/2 < bd
§ E.g. if solution depth =6 and each direction runs BFS
§ Worst case: two searches meet when each has expanded all the
nodes at 3
§ For b=10,
b+b2 +b3 = 10+100+1000=1110 *2=2220
§ Optimal
§ If step costs are all identical
§ If both directions use BFS