Lecture 3 - Uninformed Search
Lecture 3 - Uninformed Search
Search Problems
o Search Problems
o Reflex agents:
o Choose action based on current percept
(and maybe memory)
o May have memory or a model of the world’s
current state
o Do not consider the future consequences of
their actions
o Consider how the world IS
o Planning agents:
o Ask “what if”
o Decisions based on (hypothesized)
consequences of actions
o Must have a model of how the world evolves
in response to actions
o Must formulate a goal (test)
o Consider how the world WOULD BE
o A state space
“E”, 1.0
o A start state and a goal test
o State space:
o Cities
o Successor function:
o Roads: Go to adjacent city with
cost = distance
o Start state:
o Arad
o Goal test:
o Is state == Bucharest?
o Solution?
What’s in a State Space?
The world state includes every last detail of the environment
A search state keeps only the details needed for planning (abstraction)
o World state:
o Agent positions: 120
o Food count: 30
o Ghost positions: 12
o Agent facing: NSEW
o How many
o World states?
120x(230)x(122)x4
o States for pathing?
120
o States for eat-all-dots?
120x(230)
Quiz: Safe Passage
o A search tree:
o A “what if” tree of plans and their outcomes
o The start state is the root node
o Children correspond to successors
o Nodes show states, but correspond to PLANS that achieve those states
o For most problems, we can never actually build the whole tree
State Space Graphs vs. Search Trees
a G entire PATH in d e p
b c the state b c e h r q
d
e
f
space graph. h r p q f
a a
S h We construct
p q f q c G
p r
q both on a
q c G
demand – and
a
we construct
as little as
possible.
Quiz: State Space Graphs vs. Search Trees
Consider this 4-state graph: How big is its search tree (from S)?
S G
Consider this 4-state graph: How big is its search tree (from S)?
a s
a b
S G
b G a G
b a G b G
… …
o Search:
o Expand out potential plans (tree nodes)
o Maintain a fringe of partial plans under
consideration
o Try to expand as few tree nodes as possible
General Tree Search
o Important ideas:
o Fringe
o Expansion
o Exploration strategy
S s
sd
d e p
se
b c e h r q sp
a a h r p q f sdb
sdc
p q f q c G
sde
q c G a sdeh
a sder
Depth-First Search
Depth-First Search
Strategy: expand a a G
b c
deepest node first
e
d f
Implementation: S h
Fringe is a LIFO stack p q r
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
Search Algorithm Properties
Search Algorithm Properties
o Complete: Guaranteed to find a solution if one exists?
o Optimal: Guaranteed to find the least cost path?
o Time complexity?
o Space complexity? b 1 node
… b
o Cartoon of search tree: nodes
b2
o b is the branching factor m tiers nodes
o m is the maximum depth
o solutions at various depths
bm nodes
o Number of nodes in entire tree?
o 1 + b + b2 + …. bm = O(bm)
Depth-First Search (DFS) Properties
o What nodes DFS expand?
o Some left prefix of the tree. 1 node
o Could process the whole tree!
b
… b nodes
o If m is finite, takes time O(bm) b2 nodes
m tiers
o How much space does the fringe take?
o Only has siblings on path to root, so O(bm)
o Is it complete?
o m could be infinite, so only if we prevent bm nodes
cycles (more later)
o Is it optimal?
o No, it finds the “leftmost” solution,
regardless of depth or cost
Breadth-First Search
Breadth-First Search
Strategy: expand a G
b c
a shallowest
d e
node first f
S h
Implementation: p q r
Fringe is a FIFO
queue S
d e p
Sear q
b c e h r
ch
a a h r p q f
Tiers
p q f q c G
q c G a
a
Breadth-First Search (BFS) Properties
o What nodes does BFS expand?
o Processes all nodes above shallowest 1 node
solution b
… b
o Let depth of shallowest solution be s s tiers nodes
b2
o Search takes time O(bs)
nodes
bs nodes
o How much space does the fringe
take?
o Has roughly the last tier, so O(bs) bm nodes
o Is it complete?
o s must be finite if a solution exists, so yes!
o Is it optimal?
o Only if costs are all 1 (more on costs later)
Quiz: DFS vs BFS
Quiz: DFS vs BFS
b 4 c 11 e 5 h 17 r 11 q 16
Cost a 6 a h 13 r 7 p q f
contour
s p q f 8 q c G
q 11 c G 10 a
a
Uniform Cost Search (UCS) Properties
o What nodes does UCS expand?
o Processes all nodes with cost less than cheapest
solution! b c1
…
o If that solution costs C* and arcs cost at least , then the c2
“effective depth” is roughly C*/ C*/
“tiers” c3
o Takes time O(bC*/) (exponential in effective depth)
o Is it complete?
o Assuming best solution has a finite cost and minimum
arc cost is positive, yes!
o Is it optimal?
o Yes! (Proof next lecture via A*)
Uniform Cost Issues
o Remember: UCS explores increasing
cost contours … c1
c2
c3
o The bad:
o Explores options in every “direction”
o No information about goal location Start Goal