SP14 CS188 Lecture 3 - Informed Search
SP14 CS188 Lecture 3 - Informed Search
SP14 CS188 Lecture 3 - Informed Search
Informed Search
Today
Informed Search
Heuristics
Greedy Search
A* Search
Graph Search
Recap: Search
Recap: Search
Search problem:
Search tree:
Nodes: represent plans for reaching states
Plans have costs (sum of action costs)
Search algorithm:
Systematically builds a search tree
Chooses an ordering of the fringe (unexplored
nodes)
Optimal: finds least-cost plans
3
3
4
3
4
3
2
2
2
4
3
Pathflip
to all
reach
Action:
fourgoal:
Flip four,
flip
Cost:
4
three
Total cost: 7
Uninformed Search
c1
c2
c3
The bad:
Start
Goal
Informed Search
Search Heuristics
A heuristic is:
A function that estimates how close a state is
to a goal
Designed for a particular search problem
Examples: Manhattan distance, Euclidean
distance for pathing
10
5
11.2
h(x)
h(x)
4
3
4
4
3
4
4
3
Greedy Search
h(x)
Greedy Search
Expand the node that seems closest
Greedy Search
A common case:
A* Search
A* Search
UCS
Greedy
A*
a
h=5
1
1
b
h=6
d
h=
2
g=
a
1
h=5
h=1
G
h=0
g=
2
h=6
g=
3
h=7
b
c
g=
0
h=6
g=
e
9
h=1
g=
d
10
h=2
g=
G 12
h=0
Example: Teg
d g=
4
h=2
g=
G
6
h=0
2
S
h=3
h=0
h=1
Is A* Optimal?
h=6
h=
7
h=0
5
What went wrong?
Actual bad goal cost < estimated good goal cost
We need estimates to be less than actual costs!
Admissible Heuristics
Idea: Admissibility
Admissible Heuristics
A heuristic h is admissible (optimistic) if:
where
Examples:
15
Definition of fcost
Admissibility of h
h = 0 at a goal
B is suboptimal
h = 0 at a goal
Properties of A*
Properties of A*
UniformCost
A*
UCS vs A* Contours
Uniform-cost expands equally
in all directions
Star
t
Star
t
Goal
Goal
Comparison
Greedy
Uniform Cost
A*
A* Applications
A* Applications
Video games
Pathing / routing problems
Resource planning problems
Robot motion planning
Language analysis
Machine translation
Speech recognition
Creating Heuristics
Example: 8 Puzzle
Start State
Actions
Goal State
8 Puzzle I
Heuristic: Number of tiles
misplaced
Why is it8admissible?
h(start) =
This is a relaxed-problem
heuristic
Start State
Goal State
Average nodes
expanded when the
optimal path has
4
steps
UCS
112
8
steps
6,300
12
steps
3.6 x
6
Statistics10
from
Andrew
8 Puzzle II
What if we had an easier 8-puzzle
where any tile could slide any
direction at any time, ignoring
other tiles?
Start State
Goal State
Average nodes
expanded when the
optimal path has
3 + 1 + 2 + = 18
h(start) =
TILES
4
steps
8
steps
13
39
12
steps
227
8 Puzzle III
How about using the actual cost as a heuristic?
Would it be admissible?
Would we save on nodes expanded?
Whats wrong with it?
Semi-Lattice of Heuristics
Trivial heuristics
Bottom of lattice is the zero heuristic
(what does this give us?)
Top of lattice is the exact heuristic
Graph Search
Graph Search
In BFS, for example, we shouldnt bother expanding the circled
nodes (why?)
S
d
b
e
h
p
q
q
c
a
h
r
q
G
p
q
r
q
f
c
a
Graph Search
Idea: never expand a state twice
How to implement:
Tree search + set of expanded states (closed set)
Expand the search tree node-by-node, but
Before expanding a node, check to make sure its state
has never been expanded before
If not new, skip it, if new add to closed set
Search tree
S (0+2)
S
h=2
h=4
h=1
B
h=1
G
h=0
A (1+4)
B (1+1)
C (2+1)
C (3+1)
G (5+0)
G (6+0)
Consistency of Heuristics
Main idea: estimated heuristic costs
actual costs
A
h=4
h=2
h=1
3
goal
h(A) actual cost from A to G
Consistency: heuristic arc cost actual cost
for each arc
h(A) h(C) cost(A to C)
Consequences of consistency:
The f value along a path never decreases
h(A) cost(A to C) + h(C)
f1
f2
f3
Optimality
Tree search:
Graph search:
A*: Summary
A*: Summary
A* uses both backward costs and (estimates of)
forward costs
A* is optimal with admissible / consistent heuristics
Heuristic design is key: often use relaxed problems