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.]
Announcement
Recap: Search problems
(with actions, costs)
“N”, 1.0
“E”, 1.0
Start:
Goal(s): or or ……
Recap: 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.
Recap: Search algorithms
Recap: Uninformed vs. informed search
Recap: 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
Costs on edges are assumed to be 1!
Recap: Search algorithm properties
…
b
1 node
b nodes
b2 nodes
bm nodes
m tiers
Recap: Depth-First Search (DFS) properties
…
b
1 node
b nodes
b2 nodes
bm nodes
m tiers
Today
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?
Recent progress
https://wayve.ai/thinking/scaling-gaia-1/
https://wayve.ai/thinking/learning-a-world-model-and-a-driving-policy/
Questions?
Uninformed vs. informed search
Example: Pancake problem
Cost: Number of pancakes flipped
Example: Pancake problem
3
2
4
3
3
2
2
2
4
State space graph with costs as weights
3
4
3
4
2
S
G
General tree search
Action: flip top two�Cost: 2
Action: flip all four�Cost: 4
Path to reach goal:
Flip four, flip three
Total cost: 7
Search stops when you dequeue/expand a goal state, not when you enqueue a goal state
Uninformed search
Informed search
Search heuristics
10
5
11.2
Example: Heuristic function
h(x)
Example: Heuristic function
Heuristic: the largest pancake that is still out of place
4
3
0
2
3
3
3
4
4
3
4
4
4
h(x)
GOAL
Questions?
Greedy Search
Example: Heuristic function
h(x)
Greedy Search
Search stops when you dequeue/expand a goal state, not when you enqueue a goal state
Greedy Search
…
b
…
b
Greedy Search
G
S
Questions?
A* Search
A* Search
UCS
Greedy
A*
Combining UCS and Greedy
S
a
d
b
G
h=5
h=6
h=2
1
8
1
1
2
h=6
h=0
c
h=7
3
e
h=1
1
S
a
b
c
e
d
d
G
G
g = 0 h=6
g = 1 h=5
g = 2 h=6
g = 3 h=7
g = 4 h=2
g = 6 h=0
g = 9 h=1
g = 10 h=2
g = 12 h=0
State space graph
Search tree
Is A* optimal?
A
G
S
1
3
h = 6
h = 0
5
h = 7
Is A* optimal?
A
G
S
1
3
h = 6
h = 0
5
h = 7
Admissible heuristics
Idea: Admissibility
Inadmissible (pessimistic) heuristics break optimality by trapping good plans on the fringe
Admissible (optimistic) heuristics slow down bad plans but never outweigh true costs
Admissible heuristics
where is the true cost to a nearest goal G
= g(G) – g(n)
Admissible heuristics
where is the true cost to a nearest goal G
15
= g(G) – g(n)
Optimality of A* Tree Search
Optimality of A* Tree Search
…
Optimality of A* Tree Search: Blocking
Proof:
Definition of f-cost
Admissibility of h
…
h = 0 at a goal
Optimality of A* Tree Search: Blocking
Proof:
B is suboptimal
h = 0 at a goal
…
Optimality of A* Tree Search: Blocking
Proof:
…
UCS vs. A* contours
Start
Goal
Start
Goal
Comparison
Greedy
Uniform Cost
A*
A* applications
Creating Heuristics
Creating admissible heuristics
15
366
Example: 8 Puzzle
Start State
Goal State
Actions
8 Puzzle I
8
| Average nodes expanded when the optimal path has… | ||
| …4 steps | …8 steps | …12 steps |
UCS | 112 | 6,300 | 3.6 x 106 |
TILES | 13 | 39 | 227 |
Start State
Goal State
Statistics from Andrew Moore
8 Puzzle II
3 + 1 + 2 + … = 18
| Average nodes expanded when the optimal path has… | ||
| …4 steps | …8 steps | …12 steps |
TILES | 13 | 39 | 227 |
MANHATTAN | 12 | 25 | 73 |
Start State
Goal State
8 Puzzle III
Tree search pseudo-code
Important note for search