0% found this document useful (0 votes)
76 views

Lecture 6 - State Space Search - Uninformed Search

The document discusses a lecture on uninformed state space search strategies. It covers topics like state space graphs, search trees, the challenges of search problems like memory and time requirements, and different uninformed search algorithms like breadth-first, depth-first, uniform cost search, and iterative deepening search. It also mentions local search strategies and how to analyze search algorithms. Finally, it provides an example search problem of traveling between cities in Romania.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Lecture 6 - State Space Search - Uninformed Search

The document discusses a lecture on uninformed state space search strategies. It covers topics like state space graphs, search trees, the challenges of search problems like memory and time requirements, and different uninformed search algorithms like breadth-first, depth-first, uniform cost search, and iterative deepening search. It also mentions local search strategies and how to analyze search algorithms. Finally, it provides an example search problem of traveling between cities in Romania.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 43

CE 451: Applied Artificial Intelligence

Lecture 6 – State space search strategies: Uninformed search

Instructor: Dr. Hashim Ali


Ghulam Ishaq Khan Institute of Engineering Sciences and Technology, Topi
[Spring 2019]
CE451 Applied Artificial Intelligence

Announcement
 First announced quiz in next lecture (Monday 28 Jan).
 Course – Lecture 4, 5 and 6 (Week2).

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

State Space Graphs and Search Trees

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

State Space Graphs

 State space graph: A mathematical


representation of a search problem
 Nodes are (abstracted) world configurations
 Arcs represent successors (action results)
 The goal test is a set of goal nodes (maybe only one)

 In a state space graph, each state occurs only


once!

 We can rarely build this full graph in memory


(it’s too big), but it’s a useful idea

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

State Space Graphs

 State space graph: A mathematical


representation of a search problem a G
 Nodes are (abstracted) world configurations b c
 Arcs represent successors (action results) e
 The goal test is a set of goal nodes (maybe only one) d f
S h
 In a search graph, each state occurs only once! p r
q

 We can rarely build this full graph in memory


Tiny search graph for a
(it’s too big), but it’s a useful idea
tiny search problem

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Search Trees
This is now / start

“N”, 1.0 “E”,


1.0 Possible futures

 A search tree:
 A “what if” tree of plans and their outcomes
 The start state is the root node
 Children correspond to successors
 Nodes show states, but correspond to PLANS that achieve those states
 For most problems, we can never actually build the whole tree
Lecture 06 – State space search strategies: Uninformed search
Applied Artificial Intelligence

State Space Graphs vs. Search Trees

State Space Graph Each NODE in


the search Search Tree
tree is an S

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.
Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

State Space Graphs vs. Search Trees

Consider this 4-state graph: How big is its search tree (from S)?

S G

Important: Lots of repeated structure in the search tree!


Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Why search can be hard?

Assuming b=10 nodes, 1000 nodes/sec, 100 bytes/node

Depth of Nodes to Time Memory


solution expand
0 1 10-3 second 100 bytes

2 111 10-1 second 11 kbytes

4 11,111 11 seconds 1 megabyte

8 108 31 hours 11 gigabytes

12 1012 35 years 111 terabytes

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Tic tac toe

 Total space possible = 39


 Actual nodes are less
because only legal moves
can be made
 In game trees, its better
to use graph than trees,
WHY?

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Traversing a state space


 Search algorithms are used to optimally traverse a state space and
retrieve the best path to achieve a goal.
 To successfully design such search algorithms, we should
• be able to analyze their behavior,
• predict their behavior,
• and answer such questions as:
• Is the problem solver guaranteed to find a solution?
• When a solution is found, is it guaranteed to be optimal?
• What is the (time) complexity of the search process?
• How can we (most effectively) reduce search complexity?
 The theory of state space search is our primary tool for answering
these questions.
• Represent the problem as a graph and
• Use graph theory to analyze the structure. Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Search strategies
 Uninformed search  Local search and optimization
• Breadth-first, depth-first search  Hill-climbing
• Uniform cost search  Simulated annealing
• Depth limited search  Genetic algorithms
• Iterative deepening search  Bayesian approaches (Markov chain
 Informed (heuristic) search Monte Carlo)
• Greedy best-first
• A*
• Memory-bounded heuristic search
• And more….

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Tree Search

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Search Example: Romania

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Searching with a Search Tree

 Search:
 Expand out potential plans (tree nodes)
 Maintain a fringe of partial plans under consideration
 Try to expand as few tree nodes as possible
Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

General Tree Search

 Important ideas:
 Fringe
 Expansion
 Exploration strategy

 Main question: which fringe nodes to explore?


Lecture 06 – State space search strategies: Uninformed search
Applied Artificial Intelligence

Example: Tree Search


a G
b c
e
d f
S h
p q r

Lecture 06 – State space search strategies: Uninformed search


Applied Artificial Intelligence

Depth-First Search

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Depth-First Search
Strategy: expand a G
b c
a deepest node
e
first d f
S h
Implementation: p q r
Fringe is a LIFO
stack S

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 Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Search Algorithm Properties

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Search Algorithm Properties


 Complete: Guaranteed to find a solution if one exists?
 Optimal: Guaranteed to find the least cost path?
 Time complexity?
 Space complexity? b
1 node
… b nodes
b2 nodes
 Cartoon of search tree:
 b is the branching factor m tiers
 m is the maximum depth
 solutions at various depths
bm nodes
 Number of nodes in entire tree?
 1 + b + b2 + …. bm = O(bm)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Depth-First Search (DFS) Properties


 What nodes DFS expand?
 Some left prefix of the tree. 1 node
 Could process the whole tree! b b nodes

 If m is finite, takes time O(bm) b2 nodes
m tiers
 How much space does the fringe take?
 Only has siblings on path to root, so O(bm)

 Is it complete? bm nodes
 m could be infinite, so only if we prevent
cycles (more later)

 Is it optimal?
 No, it finds the “leftmost” solution,
regardless of depth or cost
Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Breadth-First Search

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

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
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 Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Breadth-First Search (BFS) Properties


 What nodes does BFS expand?
 Processes all nodes above shallowest solution 1 node
b
 Let depth of shallowest solution be s … b nodes
s tiers
 Search takes time O(bs) b2 nodes

 How much space does the fringe take? bs nodes


 Has roughly the last tier, so O(bs)

 Is it complete? bm nodes
 s must be finite if a solution exists, so yes!

 Is it optimal?
 Only if costs are all 1 (more on costs later)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Quiz: DFS vs BFS

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Quiz: DFS vs BFS

 When will BFS outperform DFS?

 When will DFS outperform BFS?

Lecture 06 – State space search strategies: Uninformed search


[Demo: dfs/bfs maze
CE451 Applied Artificial Intelligence

Video of Demo Maze Water DFS/BFS (part 1)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Video of Demo Maze Water DFS/BFS (part 2)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Iterative Deepening
 Idea: get DFS’s space advantage with BFS’s
time / shallow-solution advantages
b
 Run a DFS with depth limit 1. If no solution… …
 Run a DFS with depth limit 2. If no solution…
 Run a DFS with depth limit 3. …..

 Isn’t that wastefully redundant?


 Generally most work happens in the lowest
level searched, so not so bad!

Lecture 06 – State space search strategies: Uninformed search


Applied Artificial Intelligence

Cost-Sensitive Search
GOAL
a
2 2
b c
3
2
1 8
2 e
3 d f
9 8 2
START
h
1 4 2
p 4 r
1 q
5
BFS finds the shortest path in terms of number of actions.
It does not find the least-cost path. We will now cover
a similar algorithm which does find the least-cost path.
Lecture 06 – State space search strategies: Uninformed search
Applied Artificial Intelligence

Uniform Cost Search

Lecture 06 – State space search strategies: Uninformed search


Applied Artificial Intelligence

Uniform Cost Search


2 a G
Strategy: expand a b c
1 8 2
cheapest node first: 2 e
3 d f

Fringe is a priority S 9 h 8 2 1
p r
queue (priority: 1 q
15
cumulative cost)
S 0
d 3 e 9 p 1
b 4 c 11 e 5 h 17 r 11 q 16
Cost a 6 a h 13 r 7 p q f
contou
p q f 8 q c G
rs
q 11 c G 10 a
a Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Uniform Cost Search (UCS) Properties


 What nodes does UCS expand?
 Processes all nodes with cost less than cheapest solution!
 If that solution costs C* and arcs cost at least  , then the b c

“effective depth” is roughly C*/ 1c 
C*/
 Takes time O(bC*/) (exponential in effective depth) 2c 
“tiers”
3
 How much space does the fringe take?
 Has roughly the last tier, so O(bC*/)

 Is it complete?
 Assuming best solution has a finite cost and minimum arc cost
is positive, yes!

 Is it optimal?
 Yes! (Proof next lecture via A*)
Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Uniform Cost Issues


 Remember: UCS explores increasing cost
contours … c
1c 
2c 
3
 The good: UCS is complete and optimal!

 The bad:
 Explores options in every “direction”
 No information about goal location
Start Goal

 We’ll fix that soon! [Demo: empty grid UCS


(L2D5)]
Lecture 06 – State space search strategies: Uninformed search
CE451 Applied Artificial Intelligence

Video of Demo Empty UCS

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 1)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 2)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Video of Demo Maze with Deep/Shallow Water --- DFS, BFS, or UCS? (part 3)

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

The One Queue


 All these search algorithms are the
same except for fringe strategies
 Conceptually, all fringes are priority
queues (i.e. collections of nodes with
attached priorities)
 Practically, for DFS and BFS, you can
use stacks and queues.

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Search and Models

 Search operates over


models of the world
 The agent doesn’t
actually try all the plans
out in the real world!
 Planning is all “in
simulation”
 Your search is only as
good as your models…

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

Search Gone Wrong?

Lecture 06 – State space search strategies: Uninformed search


CE451 Applied Artificial Intelligence

References & Acknowledgements

 Partially adapted from lecture slides from Stanford University, UCIrvine, and UC
Berkeley.
 Some videos taken from UC Berkeley website.
 Contents from George F. Luger, AI: Structures and strategies for complex problem
solving, 6th Ed.

Lecture 06 – State space search strategies: Uninformed search

You might also like