CSE 3521: Search
[Many slides are adapted from the UC Berkeley. CS188 Intro to AI at UC Berkeley and previous CSE 3521 course at OSU.]
Recap: Agents & Environments
Environment
Agent
perception
action
Environments (states) can change!
Recap: Agents that plan ahead
Recap: Agents that plan ahead
Recap: Search problems
Today
Search problems
(with actions, costs)
“N”, 1.0
“E”, 1.0
Start:
Goal(s): or or ……
Example: traveling in Romania
What’s in a state space?
The world state includes every detail of the environment
A search state keeps only the details needed for planning (abstraction)
State space sizes? How many possible states?
120 x (230) x (122) x 4
120
120 x (230)
Questions to you
Today
State space graphs and search trees
To “systematically” find the solution rather than brute-force
State space graphs
State space graphs
State space graphs
State space graphs
S
G
d
b
p
q
c
e
h
a
f
r
Tiny state space graph graph for a tiny search problem
Search trees (moves in state space graphs)
“E”, 1.0
“N”, 1.0
This is now / start
Possible futures
Search trees: nodes are not states but partial plans
G
b
a
c
a
b
c
a
G
(a-b)
(a-b-c)
(a-b-c-a)
(a-b-c-G)
(a)
Different plans that achieve the same state, will be different nodes in the tree!
State space graph
Search tree
State space graphs vs. search trees
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
S
G
d
b
p
q
c
e
h
a
f
r
Each NODE in the search tree is a PATH in the state space graph.
Search Tree
State Space Graph
State space graphs vs. search trees
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
S
G
d
b
p
q
c
e
h
a
f
r
Each NODE in the search tree is a PATH in the state space graph.
Search Tree
State Space Graph
A unique STATE can show up at multiple NODES in a search tree; each NODE in the search tree is a unique plan.
State space graphs vs. search trees
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
S
G
d
b
p
q
c
e
h
a
f
r
We construct both on demand – and we construct as little as possible.
Each NODE in the search tree is a PATH in the state space graph.
Search Tree
State Space Graph
A unique STATE can show up at multiple NODES in a search tree; each NODE in the search tree is a unique plan.
Exercise: State space graphs vs. search trees
S
G
b
a
Consider this 4-state graph:
How big/deep is its search tree (from S)?
Exercise: State space graphs vs. search trees
S
G
b
a
Consider this 4-state graph:
Important: Lots of repeated structure in the search tree!
How big/deep is its search tree (from S)?
Questions?
Tree search
How to systematically builds/explores a search tree to find the solution!
Search example: Romania
Searching with a search tree
Searching with a search tree
Searching with a search tree
General tree search
Search problem
General tree search
(1) Fringe (2) Expansion (3) Exploration strategy
Search problem (state space, successor function, start state, and goal test)
Questions?
Uninformed vs. informed search
Uninformed vs. informed search
Example: Tree search
S
G
d
b
p
q
c
e
h
a
f
r
Depth-First Search (DFS)
Depth-First Search (DFS)
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
S
G
d
b
p
q
c
e
h
a
f
r
q
p
h
f
d
b
a
c
e
r
Strategy: expand a deepest node first
Implementation: Fringe is a LIFO stack
Search algorithm properties
Search algorithm properties
…
b
1 node
b nodes
b2 nodes
bm nodes
m tiers
Depth-First Search (DFS) properties
…
b
1 node
b nodes
b2 nodes
bm nodes
m tiers
Questions?
Breadth-First Search (BFS)
Breadth-First Search (BFS)
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
S
G
d
b
p
q
c
e
h
a
f
r
Search
Tiers
Strategy: expand a shallowest node first
Implementation: Fringe is a FIFO queue
Breadth-First Search (BFS) properties
…
b
1 node
b nodes
b2 nodes
bm nodes
s tiers
bs nodes
DFS vs. BFS
| DFS | BFS |
Time to find a solution | O(bm) | O(bs) |
Fringe space | O(bm) | O(bs) |
Complete | No | Yes |
Optimal | No | Yes, if costs are all 1 |
Iterative deepening
…
b
Questions?
Cost-sensitive search
START
GOAL
d
b
p
q
c
e
h
a
f
r
2
9
2
8
1
8
2
3
2
4
4
15
1
3
2
2
Uniform Cost Search (UCS)
Uniform Cost Search (UCS)
S
a
b
d
p
a
c
e
p
h
f
r
q
q
c
G
a
q
e
p
h
f
r
q
q
c
G
a
Strategy: expand the cheapest node first
Implementation: Fringe is a priority queue (priority: cumulative cost)
S
G
d
b
p
q
c
e
h
a
f
r
3
9
1
16
4
11
5
7
13
8
10
11
17
11
0
6
3
9
1
1
2
8
8
2
15
1
2
Cost contours
2
Uniform Cost Search (UCS) properties
…
b
C*/ε “tiers”
c ≤ 3
c ≤ 2
c ≤ 1
The one queue
Search and models
Search gone wrong?
Summary: Search algorithms