Download Search Algorithms: Queue-Based, Search Trees, General Tree Search, State Graphs, Uniform C and more Slides Robotics in PDF only on Docsity!
Queue-Based Search
State Space Graphs
§ State space graph: A
mathematical
representation of a
search problem
§ For every search problem,
theres a corresponding
state space graph
§ The successor function is
represented by arcs
§ We can rarely build this
graph in memory (so
we dont)
S
G
d
b
p
q
c
e
h
a
f
r
Ridiculously tiny search graph
for a tiny search problem
Search Trees
§ A search tree:
§ This is a what if tree of plans and outcomes
§ Start state at the root node
§ Children correspond to successors
§ Nodes contain states, correspond to PLANS to those states
§ For most problems, we can never actually build the whole tree
E ,
N , 1.
Another Search Tree
§ Search:
§ Expand out possible plans
§ Maintain a fringe of unexpanded plans
§ Try to expand as few tree nodes as possible
State 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 in the
search tree is an
entire PATH in the
problem graph.
Depth First Search
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
deepest node first
Implementation:
Fringe is a LIFO
stack
Breadth First Search
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
shallowest node first
Implementation:
Fringe is a FIFO
queue
Costs on Actions
Notice that BFS finds the shortest path in terms of number of
transitions. It does not find the least-cost path.
We will quickly cover an algorithm which does find the least-cost path.
START
GOAL
d
b
p
q
c
e
h
a
f
r
Uniform Cost Issues
§ Remember: explores
increasing cost contours
§ The good: UCS is
complete and optimal!
§ The bad:
§ Explores options in every
direction
§ No information about goal
location
Start Goal
c ≤ 3
c ≤ 2
c ≤ 1
Search Heuristics
§ Any estimate of how close a state is to a goal
§ Designed for a particular search problem
§ Examples: Manhattan distance, Euclidean distance
Heuristics
Combining UCS and a Heuristic
§ Uniform-cost orders by path cost, or backward cost g(n)
§ A* Search orders by the sum: f(n) = g(n) + h(n)
S a d
b
G
h=
h=
h=
h=
h=
c
h=
e
h=
Example: Teg Grenager
Admissible Heuristics
§ A heuristic h is admissible (optimistic) if:
where is the true cost to a nearest goal
§ Examples:
§ Coming up with admissible heuristics is most of
what s involved in using A* in practice.
Optimality of A*: Blocking
Proof:
§ What could go wrong?
§ We d have to have to pop a
suboptimal goal G off the
fringe before G*
§ This can t happen:
§ Imagine a suboptimal
goal G is on the queue
§ Some node n which is a
subpath of G* must also
be on the fringe (why?)
§ n will be popped before G
UCS vs A* Contours
§ Uniform-cost expanded
in all directions
§ A* expands mainly
toward the goal, but
does hedge its bets to
ensure optimality
Start Goal
Start Goal
Comparison
Uniform Cost
Greedy
A star
8 Puzzle I
§ Heuristic: Number of
tiles misplaced
§ Why is it admissible?
§ h(start) =
§ This is a relaxed-
problem heuristic
Average nodes expanded when
optimal path has length…
…4 steps …8 steps …12 steps
UCS 112 6,300 3.6 x 10
6
TILES
8 Puzzle II
§ What if we had an
easier 8-puzzle where
any tile could slide any
direction at any time,
ignoring other tiles?
§ Total Manhattan
distance
§ Why admissible?
§ h(start) =
Average nodes expanded when
optimal path has length…
…4 steps …8 steps …12 steps
TILES
MANHATTAN
8 Puzzle III
§ How about using the actual cost as a
heuristic?
§ Would it be admissible?
§ Would we save on nodes expanded?
§ What s wrong with it?
§ With A*: a trade-off between quality of
estimate and work per node!
Tree Search: Extra Work!
§ Failure to detect repeated states can cause
exponentially more work. Why?
Optimality
§ Tree search:
§ A* optimal if heuristic is admissible (and non-
negative)
§ UCS is a special case (h = 0)
§ 287 Graph search:
§ A* optimal if heuristic is admissible
§ A* expands every node only once if heuristic also consistent
§ UCS optimal (h = 0 is consistent)
§ Consistency implies admissibility
§ In general, natural admissible heuristics tend to
be consistent
37
§ Weighted A*: expands states in the order of
f = g+εh values,
ε > 1 = bias towards states that are closer to goal
Weighted A* f = g+εh
University of Pennsylvania 38
Weighted A* f = g+εh : ε = 0 --- Uniform Cost Search
s goal
s start
39
Weighted A* f = g+εh : ε = 1 --- A*
s goal
s start
Anytime A*
§ Weighted A*
§ Trades off optimality for speed
§ ε-suboptimal
§ Anytime A*
§ For ² 2 { ²
1
2
§ Run weighted A* with current ²
§ Anytime Repairing A* [Likhachev, Gordon, Thrun
2004]
§ efficient version of above that reuses state values within
each iteration
Anytime Repairing A* (ARA*)
§ Starting point:
Anytime A*
§ For ² 2 { ² 1
2
§ Run weighted A*
with current ²
§ When about to expand node, if already
expanded before, don’t expand again to
save time, instead put on INCON list (for
consistent heuristic this is fine and will
still give us epsilon optimality guarantee)
§ When epsilon decreased
§ Initialize priority queue with current
priority queue union INCON
§ Update priorities
§ Why is this “union INCON” needed?
epsilon*h need not be consistent, hence
need to keep track of potential optimality
violations and re-consider later
Anytime Nonparametric A* (ANA*) [van
den Berg, Shah, Huang, Goldberg, 2011]
§ Tricky issue with ARA*:
§ How much to decrease epsilon in each step?
§ In practice: some tweaking
§ ANA*: provides a theoretically justified and
empirically shown to be superior scheme that can
(a bit crudely) be thought of as always picking the
right next epsilon
Lifelong Planning A* (LPA*)
[Koenig, Likhachev, Furcy, 2004]
§ LPA* is able to handle changes in edge costs
efficiently
§ Example application: find out a road has been blocked