A and Weighted A Search: Maxim Likhachev Carnegie Mellon University
A and Weighted A Search: Maxim Likhachev Carnegie Mellon University
Maxim Likhachev
Carnegie Mellon University
Maxim Likhachev
Maxim Likhachev
- lattice-based graphs
replicate action
template online
- lattice-based graphs
replicate action
template online
part of efforts by Tartanracing team from CMU for the Urban Challenge 2007 race
Maxim Likhachev
Maxim Likhachev
1
Sstart
S2
S1
1
1
S4
Maxim Likhachev
Sgoal
S3
g=1
g=0
Sstart
S2
g=3
S1
1
1
S4
g=2
Maxim Likhachev
g=5
Sgoal
S3
g=5
g=1
g=0
Sstart
S2
g=3
S1
1
1
S4
g=2
Maxim Likhachev
g=5
Sgoal
S3
g=5
10
s' arg min s '' pred ( s ) ( g ( s' ' ) c( s' ' , s))
g=1
g=0
Sstart
S2
g=3
S1
1
1
S4
g=2
Maxim Likhachev
g=5
Sgoal
S3
g=5
11
A* Search
Computes optimal g-values for relevant states
at any point of time:
an (under) estimate of the cost
of a shortest path from s to sgoal
the cost of a shortest path
from sstart to s found so far
g(s)
h(s)
S
S1
Sstart
Maxim Likhachev
S2
Sgoal
12
A* Search
Computes optimal g-values for relevant states
at any point of time:
heuristic function
g(s)
h(s)
S
S1
Sstart
S2
Sgoal
13
A* Search
minimal cost from s to sgoal
Maxim Likhachev
14
A* Search
Computes optimal g-values for relevant states
Main function
g(sstart) = 0; all other g-values are infinite; OPEN = {sstart};
ComputePath();
publish solution;
set of candidates for expansion
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
expand s;
g=
g=0
h=3
for every expanded state
g(s) is optimal
Sstart
h=2
S2
1
1
S4
Maxim Likhachev
g=
h=1
S1
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
15
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
expand s;
g=
g=0
h=3
Sstart
h=2
S2
g=
h=1
S1
1
1
S4
Maxim Likhachev
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
16
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
set of states that have already been expanded
insert s into OPEN;
tries to decrease g(s) using the
found path from sstart to s
g=0
h=3
Sstart
g=
h=2
S2
g=
h=1
S1
1
1
S4
Maxim Likhachev
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
17
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {}
OPEN = {sstart}
next state to expand: sstart
Maxim Likhachev
g=0
h=3
Sstart
g=
h=2
S2
g=
h=1
S1
1
1
S4
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
18
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s2) > g(sstart) + c(sstart,s2)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {}
OPEN = {sstart}
next state to expand: sstart
Maxim Likhachev
g=0
h=3
Sstart
g=
h=2
S2
g=
h=1
S1
1
1
S4
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
19
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
g=0
h=3
g=1
h=2
S2
Sstart
g=
h=1
S1
1
1
S4
Maxim Likhachev
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
20
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {sstart}
OPEN = {s2}
next state to expand: s2
Maxim Likhachev
g=0
h=3
g=1
h=2
S2
Sstart
g=
h=1
S1
1
1
S4
Carnegie Mellon University
g=
h=2
g=
h=0
Sgoal
S3
g=
h=1
21
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {sstart,s2}
OPEN = {s1,s4}
next state to expand: s1
Maxim Likhachev
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
Carnegie Mellon University
g= 2
h=2
g=
h=0
Sgoal
S3
g=
h=1
22
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {sstart,s2,s1}
OPEN = {s4,sgoal}
next state to expand: s4
Maxim Likhachev
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
Carnegie Mellon University
g= 2
h=2
g= 5
h=0
Sgoal
S3
g=
h=1
23
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {sstart,s2,s1,s4}
OPEN = {s3,sgoal}
next state to expand: sgoal
Maxim Likhachev
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
24
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
CLOSED = {sstart,s2,s1,s4,sgoal}
OPEN = {s3}
done
Maxim Likhachev
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
25
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
26
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
27
A* Search
Computes optimal g-values for relevant states
ComputePath function
while(sgoal is not expanded)
remove s with the smallest [f(s) = g(s)+h(s)] from OPEN;
insert s into CLOSED;
for every successor s of s such that s not in CLOSED
if g(s) > g(s) + c(s,s)
g(s) = g(s) + c(s,s);
insert s into OPEN;
g=0
h=3
Sstart
g=1
h=2
S2
g= 3
h=1
S1
h=2
1
3
g= 5
h=0
Sgoal
S3
g= 5
h=1
28
A* Search
Is guaranteed to return an optimal path (in fact, for every
expanded state) optimal in terms of the solution
g=0
h=3
g=1
h=2
S2
Sstart
g= 3
h=1
S1
1
1
S4
Maxim Likhachev
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
29
A* Search
Is guaranteed to return an optimal path (in fact, for every
expanded state) optimal in terms of the solution
Sketch of proof by induction for h = 0:
assume all previously expanded states have optimal g-values
next state to expand is s: f(s) = g(s) min among states in OPEN
OPEN separates expanded states from never seen states
thus, path to s via a state in OPEN or an unseen state will be
g= 3
worse than g(s) (assuming positive costs) g=1
CLOSED = {sstart,s2,s1,s4}
OPEN = {s3,sgoal}
next state to expand: sgoal
Maxim Likhachev
g=0
h=3
h=2
S2
Sstart
h=1
S1
1
1
S4
g= 2
h=2
g= 5
h=0
Sgoal
S3
g= 5
h=1
30
Maxim Likhachev
expansion of s
31
32
g(s)
h(s)
S
S1
Sstart
Maxim Likhachev
S2
Sgoal
33
g(s)
h(s)
S
S1
Sstart
Maxim Likhachev
S2
Sgoal
34
sstart
Maxim Likhachev
sgoal
35
sstart
Maxim Likhachev
sgoal
University of Pennsylvania
36
sstart
Maxim Likhachev
sgoal
University of Pennsylvania
37
sstart
sgoal
key to finding solution fast:
shallow minima for h(s)-h*(s) function
Maxim Likhachev
38
Maxim Likhachev
39
Maxim Likhachev
40
=1.5
=1.0
13 expansions
solution=11 moves
15 expansions
solution=11 moves
20 expansions
solution=10 moves
Maxim Likhachev
41
=1.5
=1.0
13 expansions
solution=11 moves
15 expansions
solution=11 moves
20 expansions
solution=10 moves
Inefficient because
many state values remain the same between search iterations
we should be able to reuse the results of previous searches
Maxim Likhachev
42
=1.5
=1.0
13 expansions
solution=11 moves
15 expansions
solution=11 moves
20 expansions
solution=10 moves
43
then A* is -suboptimal:
cost(solution) cost(optimal solution)
44
then A* is -suboptimal:
cost(solution) cost(optimal solution)
Proof?
45
then A* is -suboptimal:
cost(solution) cost(optimal solution)
Proof?
46
Euclidean distance
Manhattan distance: h(x,y) = abs(x-xgoal) + abs(y-ygoal)
Diagonal distance: h(x,y) = max(abs(x-xgoal), abs(y-ygoal))
More informed distances???
Maxim Likhachev
Euclidean distance
Manhattan distance: h(x,y) = abs(x-xgoal) + abs(y-ygoal)
Diagonal distance: h(x,y) = max(abs(x-xgoal), abs(y-ygoal))
More informed distances???
Maxim Likhachev
Euclidean distance
Manhattan distance: h(x,y) = abs(x-xgoal) + abs(y-ygoal)
Diagonal distance: h(x,y) = max(abs(x-xgoal), abs(y-ygoal))
More informed distances???
Maxim Likhachev
Memory Issues
A* does provably minimum number of expansions (O(n)) for finding
a provably optimal solution
Memory requirements of A* (O(n)) can be improved though
Memory requirements of weighted A* are often but not always better
Maxim Likhachev
50
Memory Issues
Alternatives:
Depth-First Search (w/o coloring all expanded states):
explore each every possible path at a time avoiding looping and keeping in the
memory only the best path discovered so far
Complete and optimal (assuming finite state-spaces)
Maxim Likhachev
51
Memory Issues
Alternatives:
Depth-First Search (w/o coloring all expanded states):
explore each every possible path at a time avoiding looping and keeping in the
memory only the best path discovered so far
Complete and optimal (assuming finite state-spaces)
Maxim Likhachev
52
Memory Issues
Alternatives:
Depth-First Search (w/o coloring all expanded states):
explore each every possible path at a time avoiding looping and keeping in the
memory only the best path discovered so far
Complete and optimal (assuming finite state-spaces)
Example:
graph: a 4-connected grid of 40 by 40 cells, start: center of the grid
A* expands up to 800 states, DFS may expand way over 420 > 1012 states
Maxim Likhachev
53
Memory Issues
Alternatives:
Maxim Likhachev
54
Memory Issues
Alternatives:
Maxim Likhachev
55