Вы находитесь на странице: 1из 48

Shortest Path Search Algorithms with

Heuristic and Bidirectional Searches

Marcelo Johann
johann@inf.ufrgs.br
www.inf.ufrgs.br/~johann
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 1

Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 2
Shortest Path Problem
In a locally finite graph G=(V,E), find the
shortest path between two designated nodes
source s and target t - smallest total cost.

v1 v5

v4 v6 t
s v3
v2 v8
v7
v9

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 3

Shortest Path Search


Starting at s, the method builds a search tree by
repetitive application of the successor operator
A node is expanded when we apply the successor
operation on it (the node becomes closed)
A node is generated when it is returned by the
successor operator (the node becomes open)

v1 v6
v4 v8 v0
v3
v2 s admissibility
v5 v9 v7 t

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 4
Breadth-First Search (BFS)
Expand first nodes that are closer to the source,
or at the same time nodes that are at the
same distance (FIFO).

Intermediate
search
target

source

Complete
search

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 5

First Shortest Path Search Methods


 BFS - Moore 1957 - Goes through all graph nodes,
starting with the ones closer to the source. Therefore, it
has: unit costs, FIFO structure, complexity O(n+|E|), for n
nodes.
 Shortest-path Search Algorithm - Dijkstra, 1959 - The
graph has arc costs and the algorithm seeks the path from
a source node to a target node. Complexity O(n2) or O(n
log n + |E|) with a priority queue.
 Maze Router - Lee, 1961 - An adaptation of BFS,
searching in a grid that represents a metal layer, by using
numbers from a sequence. After reaching the target, all
possible paths with the smallest cost can be identified
during the retrace phase. O (l2) for a circuit with side l.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 6
The Maze Router
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X S X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 7

The Maze Router


X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X 2 X
X 2 1 2 X
X 2 X
X X
X X
X X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 8
The Maze Router
X X X X X X X X X X X X X X X X X X X X
X X
X X
X 4 3 X
X 4 3 2 3 X
X 4 3 2 1 2 3 X
X 4 3 2 3 X
X 4 3 X
X X
X X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 9

The Maze Router


X X X X X X X
X X X X X X X X X X X X X
X 7 6 5 6 X
X 7 6 5 4
6 7 5 X
X 7 6 5 4 3
5 6 7 4 X
X 6 5 4 3 2 3
4 5 6 7 X
X 5 4 3 2 1 2
3 4 5 6 7 X
X 6 5 4 3 2 3
4 5 6 7 X
X 7 6 5 4 3
5 6 7 4 X
X 7 6 5 6 4 5 X
X 7 6 5 6 X
X X X X X
X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 10
The Maze Router
X X X X X X X X X
X X X X X X X X X X X
X 9 8 7 6 5 6 7 8X 9 10 11 12
X 8 7 6 5 4 5
12 6 7X 8 9 10 11
X 7 6 5 4 3 4
11 12 5 6X 7 8 9 10
X 6 5 4 3 2 3 4
10 11 12 5X 6 7 8 9
X 5 4 3 2 1 2 3
9 10 11 12 4X 5 6 7 8
X 6 5 4 3 2 3 4
10 11 12 5X 6 7 8 9
X 7 6 5 4 3 4
11 12 5 6X 7 8 9 10
X 8 7 6 5 4 5
12 6 7X 8 9 10 11
X 9 8 7 6 5 6 7 8X 9 10 11 12
X 10 9 X X X X X
X X X X XX X X X X
X 11 10 11 12 X
X 12 11 12 T X
X 12 X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 11

The Maze Router


X X X X X X X X X
X X X X X X X X X X X
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 5 4 3 2 1 2 3 4
13 14 X 5 6 7 8 9 10 11 12
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 10 9 X X X X X X X X X X X X X X X
X 11 10 11 12 13 14 15 16 X
X 12 11 12 13 14 15 16 T X
X 13 12 13 14 15 16 X
X 14 13 14 15 16 X
X 15 14 15 16 X
X 16 15 16 X
X 16 X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 12
The Maze Router
X X X X X X X X X
X X X X X X X X X X X
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 5 4 3 2 1 2 3 4
13 14 X 5 6 7 8 9 10 11 12
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 10 9 X X X X X X X X X X X X X X X
X 11 10 11 12 13 14 15 16 X
X 12 11 12 13 14 15 16 T X
X 13 12 13 14 15 16 X
X 14 13 14 15 16 X
X 15 14 15 16 X
X 16 15 16 X
X 16 X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 13

The Maze Router


X X X X X X X X X
X X X X X X X X X X X
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 5 4 3 2 1 2 3 4
13 14 X 5 6 7 8 9 10 11 12
X 6 5 4 3 2 3 4 5
14 15 X 6 7 8 9 10 11 12 13
X 7 6 5 4 3 4 5 6
15 16 X 7 8 9 10 11 12 13 14
X 8 7 6 5 4 5 6 16 7 X 8 9 10 11 12 13 14 15
X 9 8 7 6 5 6 7 8 X 9 10 11 12 13 14 15 16
X 10 9 X X X X X X X X X X X X X X X
X 11 10 11 12 13 14 15 16 X
X 12 11 12 13 14 15 16 T X
X 13 12 13 14 15 16 X
X 14 13 14 15 16 X
X 15 14 15 16 X
X 16 15 16 X
X 16 X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 14
Maze Router’s expansion g++
#include <iostream> void print(void);
#include <queue> int bfs(int source, int target)
using namespace std; {
#define SIDE 20 queue<int> q;
#define PLACE(x,y) ((y)*SIDE+(x)) q.push(source);
#define WEST(n) (n-1) while (!q.empty())
#define EAST(n) (n+1) {
#define NORTH(n) (n-SIDE) int n = q.front();
#define SOUTH(n) (n+SIDE) q.pop();
char Space[SIDE*SIDE]; if (n==target)
void init (void) return 1;
{ if (Space[n] != 'X')
for (int i=0; i<SIDE*SIDE; ++i) {
Space[i] = ' '; Space[n] = 'X';
for (int i=0; i<SIDE; ++i) print();
{ getchar();
Space[PLACE(i,0)] = 'X'; q.push(WEST(n));
Space[PLACE(i,SIDE-1)] = 'X'; q.push(EAST(n));
Space[PLACE(0,i)] = 'X'; q.push(NORTH(n));
Space[PLACE(SIDE-1,i)] = 'X'; q.push(SOUTH(n));
} }
for (int i=3; i<SIDE-3; ++i) }
Space[PLACE(i,10)] = 'X'; return 0;
} }

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 15

Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 16
Heuristic Search (A*) [Hart et al. 1968]

Expand first more promissing nodes, according to:


f(n) = g(n) + h(n)
Also known as Best-First Search

Intermediate
stages
source target

g(n) h(n)
Complete
Search

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 17

Behaviour of f, g and h
1 2 3 4
g= g= g= g=
h= h= h= h=
f= c=1 f= c=2 f= c=2 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=0 g= g= g=
h= h=3 h= h= h=
f= c=1 f =3 c=2 f= c=2 f= c=2 f=
c=1 c=1 c=1 c=1
13 14 15 11
g= g= g= g=
h= h= h= h=
f= c=1 f= c=2 f= c=2 f=

Open List:
7

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 18
Behaviour of f, g and h
1 2 3 4
g=1 g= g= g=
h=4 h= h= h=
f =5 c=1 f= c=2 f= c=2 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g=1 g=0 g=2 g= g=
h=5 h=3 h=2 h= h=
f =5 c=1 f =3 c=2 f =4 c=2 f= c=2 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=1 g= g= g=
h=4 h= h= h=
f =5 c=1 f= c=2 f= c=2 f=

Open List:
8, 1, 13, 6

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 19

Behaviour of f, g and h
1 2 3 4
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g=1 g=0 g=2 g=4 g=
h=4 h=3 h=2 h=1 h=
f =5 c=1 f =3 c=2 f =4 c=2 f =5 c=2 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=

Open List:
1, 13, 6, 9, 2, 14

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 20
Behaviour of f, g and h
1 2 3 4
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g=1 g=0 g=2 g=4 g=
h=4 h=3 h=2 h=1 h=
f =5 c=1 f =3 c=2 f =4 c=2 f =5 c=2 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=

Open List:
1, 13, 6, 9, 2, 14
ties

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 21

Behaviour of f, g and h
1 2 3 4
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g=1 g=0 g=2 g=4 g=
h=4 h=3 h=2 h=1 h=
f =5 c=1 f =3 c=2 f =4 c=2 f =5 c=2 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=1 g=3 g= g=
h=4 h=3 h= h=
f =5 c=1 f =6 c=2 f= c=2 f=

Open List:
1, 13, 6, 9, 2, 14
But not critical as f * = 6

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 22
Quality of the estimator h
1 2 3
g=1 g=3 g=
h=4 h=3 h=
f =5 c=1 f =6 c=2 f=
Effect of the
c=1 c=1 c=1 estimation
6 7 8 9
g=1 g=0 g=2 g=4 efficiency
h=4 h=3 h=2 h=1
f =5 c=1 f =3 c=2 f =4 c=2 f =5
c=1 c=1 c=1
13 14 15
g=1 g=3 g=
h=4 h=3 h=
f =5 c=1 f =6 c=2 f=

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 23

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X X
X X
X
X
7 X
X
X X X X X X X X X X X X X X X X
X X
X T X
X
X
3 X
X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

h = estimation function

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 24
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X X
X X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Min f = g + h Max g

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 25

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X 10 X
X 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Min f = g + h Max g

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 26
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Straingth path from S to T

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 27

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Try all possible straight paths

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 28
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X 12 12 12 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Maze router-like with obstacles

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 29

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X 16 16 16 16 X
X 16 14 14 14 14 16 X
X 16 14 12 12 12 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 X X X X X X X X X X X X X X X
X 16 X
X 16 16 16 16 16 16 T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Maze router-like with obstacles

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 30
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X 16 16 16 16 X
X 16 14 14 14 14 16 X
X 16 14 12 12 12 12 14 16 Saved
X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 effort
X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 X X X X X X X X X X X X X X X
X 16 X
X 16 16 16 16 16 16 T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 31

Some Notation…
s, t - source and target nodes
k(n1,n2) - estimate to go from n1 to n2
k*(n1,n2) - actual cost of the shortest path from n1 to n2
h(n) = k(n,t)
h*(n) = k*(n,t)
g*(n) = k*(s,n)
Pa-b = path from a to b
Pa-b* = optimal path from a to b
f*(n) = cost of Ps-n* ∪ Pn-t* (going through n)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 32
Properties of the Heuristic Estimator

 *): cost from n to t ≥ h(n)


Admissibility (*
ensures the shortest path h(n) t
n
Shortest path
from n to t

 Consistency: k(n1,n2) + k(n2,n3) ≥ k(n1,n3)


Every expanded node
n2
has optimal cost k(n1,n2 )
k(n2,n3 )
n3
known n1
k(n1,n3 )
g(n) = g*(n)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 33

Properties of the A* Algorithm


 Continuity - the search has always an open node ∈ Ps-t*.
 Completeness - A* terminates.
 Admissibility - A* finds the optimal path.
 sufficient condition for expansion - f(n) < Ps-t* .
 Necessary condition for expansion - f(n) ≤ Ps-t* .
 Indeterminism on critical ties - biasing.
 Monotonicity - if n2 is expanded after n1 then
f(n2) ≥ f(n1 ).
 Dominance - A more informed A* expands less nodes.
 Excelence - A* is optimal among all unidirectional
algorithms that are no better informed, with a consistent
heuristic and no critical ties.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 34
Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 35

Bidirectional Search [Pohl 1971]


Two simultaneous search fronts
 Meeting node: recognized by both fronts
 Terminating condition: f(n) > min[f(m)]
 Leads to overlapping

Source search Target search

target
m

source

Meeting node
Unidirectional search
( to compare)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 36
Bidirectional Search
Two simultaneous search fronts
 Meeting node: recognized by both fronts
 Terminating condition: f(n) > min[f(m)]
 Leads to overlapping

Source search Target search

target
m

source

Meeting node

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 37

Bidirectional Search
Two simultaneous search fronts
 Meeting node: recognized by both fronts
 Terminating condition: f(n) > min[f(m)]
 Leads to overlapping

4 5
a b d

6
6 6 6
5 4
c e f

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 38
Bidirectional Search
Two simultaneous search fronts
 Meeting node: recognized by both fronts
 Terminating condition: f(n) > min[f(m)]
 Leads to overlapping

4 5
a b d
g=10 6
6 6 6
5 4
c e f
g=9

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 39

Bidirectional Search
Two simultaneous search fronts
 Meeting node: recognized by both fronts
 Terminating condition: f(n) > min[f(m)]
 Leads to overlapping

4 5
a b d

g=10 6
6 6 6
5 4
c e f
First Meeting

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 40
Heuristic Bidirectional Search
Goal: to combine the advantages of both
The challenge:
 Terminating condition
 Overlapping [Kwa 1989]
 The missing fronts problem

Goal The missing fronts


Bi-BFS
problem

Bi-A*

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 41

Wave-Shapping
One front looks at the other
Calculates distance to each node in the oposite front
f(n) = gs (n) + min[k(n,pi) + gt (pi)]

pi

t
s

gs(n) gt(pi)

n k(n,pi )

Requires quadratic time (or space)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 42
Perimeter Search [Manzini 1995]

Two separate searches following one another


The first BFS and the second A*, usualy

First search, up to a
predetermined
perimeter pi
t
Second search with
front-to-front
gt(pi)
estimates
gs(n)
s k(n,pi )
n

It demonstrates the potencial of bidirectional heuristic


Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 43

Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 44
The LCS* Algorithm
Lowerbound Cooperative Search [ISA/CI2000]
Cooperation
 overall code is like BS* [Kwa 89]
 dynamic estimation (resistances e penalties)
 Function h of one front will be improved by the
other’s g values
 estimated values stored in references
completeness and admissibility proved [SBIA2000]

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 45

Conditions for expansion…

Sufficient Condition for Expansion


 A* expands all nodes with f(n) < Ps-t*

Necessary Condition for Expansion


 A* only expands nodes with f(n) ≤ Ps-t*

Missing fronts?
 No, this is not the main problem! [Kaindl 95,97]

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 46
The Pruning Power!

 The power of a heuristic admissible algorithm


is not in how fast it finds the goal but in how
efficiently it computes higher f(n) values for
the generated nodes.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 47

Dynamic Estimation
 Resistence (min idea [Kaindl 96])
pi
Rt = Min[gt(pi) - k(pi,t)] gt(pi)
t

F(n) = f(n) + Rt k(pi ,t)

 A good idea for BFS, but


with A* the minimum values pi

are always at the opposite t


gt(pi)

side of the search k(pi ,t)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 48
Dynamic Estimation
 Penalty (max idea [Kaindl 96])
Pt = Min[gt*(pi) + k(pi,s)]
pi
F(n) = gs(n) + Pt - ht(n)
gt(pi)
ht(pi) t
k(pi ,s)

ht(n) hs(n)
s
gs(n) n

 LCS* uses both, as penalties can


be smaller than resistances in
some cases

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 49

Cooperation and Visibility


Function h of one front will be improved by the
other’s g values
But h is under-estimated while g is over-estimated
In previous works:
 g and h were associated with the nodes
themselves
Visibility:
 estimated values stored in references
 single public closed set for both fronts allows
cooperation

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 50
LCS* is Admissible
Admissibility
 There are always references to nodes in the
optimal path in both search fronts;
 The algorithm terminates only after they meet;
Prunning Power
 Less nodes are expanded by increasing f(n) values
 Normal values are used in the open lists, but
single quantities Ω (resistance) and P (penalty)
are subtracted from Lmin (best cost so far)

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 51

LCS*’s code :

Too many details!


Ask me later on if you want…
Results: LCS* versus A* [Johann 2000]

Expanded nodes and actual runtime: typical

200 by 200 grids with random costs, mean 100,


1 minimum 50, maximum 300
0.8
ratio LCS*/A*

0.6 nodes
0.4 runtime

0.2

0
0

0
10

14

18

22

26

30

34

38
range of random costs

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 53

Specification of random costs

maximum
range
Center AC
(mean) costs
minimum
DC
cost
0

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 54
Expanded nodes in 2D grids

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 55

ε-Admissibility in A* and LCS*


 It is to find a path which is within ε from the
shortest one
 In heuristic search this is accomplished by
simply multiplying the original h function by
1+ε
 But in LCS*, you can also check how far
each meeting node is from a possible optimal
by comparing it to the smalest open f.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 56
Testing ε-admissibility

LCS*/A* in 2D grids, regular cost regime

200 by 200 grids with random costs, mean 100,


3 minimum 50, maximum 300
2.5
ratio LCS*/A*

2
100%
1.5
96%
1
0.5
0
15 25 35 45 55 65 75 85 95
range of random costs

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 57

LCS* wins on harder mazes

100x100 random BFS, DFS and multi-DFS mazes

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 58
LCS* wins on random graphs

70 nodes, all 70x70 path problems

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 59

A* almost optimal in geometric graphs

70 nodes, all 70x70 path problems

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 60
Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 61

Main Conclusions
 A* is way easier to implement. Always the
first choice.
 LCS* will usually lose when the area is
empty, as A* expands the smallest number
of nodes. (but it’s on easy instances)
 LCS* can get you a small constant
advantage, and can be significantly better
when the heuristic is bad, like in congested
routing, or when one of the pins (A* target)
is blocked.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 62
Pathological cases
 When one of the pins is in a very congested
area, A* starting from this pin has an
advantage, for when the search leaves the
congested area, it goes direct to the target.
LCS* will always duplicate its efforts.
 Similar case happens with a barrier in the
middle. A* wins with 50% probability.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 63

Open question
Direction choosing criteria:
 Alternating
 Smallest f
 Cardinality
 Inertial Cardinality
 Expanding from the most difficult first
But this contradicts others

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 64
Outline
 Introduction
 Heuristic Search: properties of A*
 Bidirectional Search and the quest for Bi-A*
 LCS*
 principles, the algorithm, and how it performs
 Main Conclusions
 Pathological cases and open questions
 Application in grids and routing (mainly A*)
 6 ideas that we find significant…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 65

Application in grids and routing

1. Do we need admissibility?
2. Degrees of freedom
3. Cost functions: add some processing
4. Optimizing data structures
5. How to avoid blocking pins
6. Grid properties and some ideas

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 66
1. Admissibility: do we need it?
 LCS* is a nice proved admissible algorithm
 But who cares?
 In most cases we don’t need full admissibility
 The advantage of LCS is that it can compute
ε-admissibility in two ways.
 The disadvantage is that if you don't need to
guarantee ε, then forget LCS* and make a
simple Bi-A* that terminates in the first
meeting.
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 67

2. Degrees of freedom

During expansion
On ties, use biasing, like in AMAZE
[Hentschke ISPD 2007]

And during retrace?


Need to record multiple pointers:

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 68
Uniform costs
1 2 3 4
g= g= g= g=
h= h= h= h=
f= c=1 f= c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g= g= g= g=
h= h= h= h= h=
f= c=1 f= c=1 f= c=1 f= c=1 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g= g= g=
h=4 h= h= h=
f =4 c=1 f= c=1 f= c=1 f=

Open List:
13

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 69

Critical Ties
1 2 3 4
g= g= g= g=
h= h= h= h=
f= c=1 f= c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g= g= g=
h= h=3 h= h= h=
f= c=1 f =4 c=1 f= c=1 f= c=1 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g= g=
h=4 h=3 h= h=
f =4 c=1 f =4 c=1 f= c=1 f=

Open List:
14,7
f(14) = f(7) = f *

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 70
Can choose what you want
1 2 3 4
g= g= g= g=
h= h= h= h=
f= c=1 f= c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g= g=
h= h=3 h=2 h= h=
f= c=1 f =4 c=1 f =4 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=
h=4 h=3 h=2 h=
f =4 c=1 f =4 c=1 f =4 c=1 f=

Open List:
15,8,7

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 71

Nodes close to the target first


1 2 3 4
g= g=3 g= g=
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=
h= h=3 h=2 h=1 h=
c=1 c=1 c=1 c=1
f= f =4 f =4 f =4 f=
worst
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4
best
Open List:
11,9,8,7

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 72
Nodes close to the target first
1 2 3 4
g= g=3 g= g=
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=4
h= h=3 h=2 h=1 h=0
f= c=1 f =4 c=1 f =4 c=1 f =4 c=1 f =4
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4

Open List:
15,7,2,3
Only four nodes expanded

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 73

But pay attention to:


1 2 3 4
g= g=3 g= g=
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=4
h= h=3 h=2 h=1 h=0
f= c=1 f =4 c=1 f =4 c=1 f =4 c=1 f =4
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4

Open List:
15,7,2,3
Degree of freedom

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 74
But pay attention to:
1 2 3 4
g= g=3 g= g=
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=4
h= h=3 h=2 h=1 h=0
f= c=1 f =4 c=1 f =4 c=1 f =4 c=1 f =4
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4

Open List:
15,7,2,3
Degree of freedom

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 75

But pay attention to:


1 2 3 4
g= g=3 g= g=
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=4
h= h=3 h=2 h=1 h=0
f= c=1 f =4 c=1 f =4 c=1 f =4 c=1 f =4
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4

Open List:
15,7,2,3
Degree of freedom

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 76
But pay attention to:
1
g=
2
g=3
3
g=
4
g= options
h= h=3 h= h=
f= c=1 f =6 c=1 f= c=1 f=
c=1 c=1 c=1 c=1
6 7 8 9 10
g= g=1 g=2 g=3 g=4
h= h=3 h=2 h=1 h=0
f= c=1 f =4 c=1 f =4 c=1 f =4 c=1 f =4
c=1 c=1 c=1 c=1
13 14 15 11
g=0 g=1 g=2 g=3
h=4 h=3 h=2 h=1
f =4 c=1 f =4 c=1 f =4 c=1 f =4

Open List:
15,7,2,3

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 77

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X X
X X
X
X
7 X
X
X X X X X X X X X X X X X X X X
X X
X T X
X
X
3 X
X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

h = estimation function

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 78
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X X
X X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Min f = g + h Max g

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 79

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X 10 X
X 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Min f = g + h Max g

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 80
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Straingth path from S to T

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 81

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Biasing already considered


Degrees of freedom
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 82
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X 12 12 12 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X 12 10 10 10 10 12 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

But all this area will be expanded


anyway…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 83

The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X 16 16 16 16 X
X 16 14 14 14 14 16 X
X 16 14 12 12 12 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 X X X X X X X X X X X X X X X
X 16 X
X 16 16 16 16 16 16 T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

After it escapes, A* again

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 84
The A* Algorithm
X X X X X X X X X X X X X X X X X X X X
X X
X 16 16 16 16 X
X 16 14 14 14 14 16 X
X 16 14 12 12 12 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 14 12 10 10 10 10 12 14 16 X
X 16 X X X X X X X X X X X X X X X
X 16 X
X 16 16 16 16 16 16 T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

There are degrees of freedom in backtrace!

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 85

3. Cost Functions
 This is a delicate question for routing, but let's
just consider we may have different scenarios.
 So, things we can do:
 You can introduce noise (dither) in the cost
function to better randomize the paths. But
then you loose degrees of freedom.
 On the contrary, you can round the costs
down to low resolution, as to increase the
number of ties.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 86
3. Cost Functions
Also, costs represent conflicting factors:

1. resource usage (how much metal this takes)


2. Path quality, = delay
3. Congestion

So they can be weighted for net, factor, layer


It helps taking better paths with less effort

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 87

A simple visual example…

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 88
A simple visual example…

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 89

4. Optimizing Data Structures


A* expands nodes with increasing values of f.
If the maximum cost per arc is known, we have
a limited range for f values at the same time in
the open list.
Therefore, we can implement it as an array of
lists.
Also, the ordering of each list can be calculated
only when a new f value is needed.

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 90
5. To avoid blocking pins
Typically the number of alternate paths is proportional to the
distance from a given pin.
So the probability of getting blocked is higher close to the pins.
We can minimize blocking by reserving some escapes for a pin.
But fixed reservations compromise freedom, and should be used
only when there is a single way out.
For multiple possible accesses, a technique of alternate
reservations was proposed by Johann/Reis in 1995:
 Place an alternate reservation in one position for each pin, maintaining a list of
other options to it. When drawing a connection during retrace, if this connection
passes on an alternate reservation, eliminate the reservation and check for the
other options. If there are more than one still available, chose one of then to hold
an alternate reservation. On the other hand, if there is only one way out remaining,
make it a fixed reservation. In both cases, no change is made to the path being
recorded in the current retrace.
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 91

6. Grid Properties
Let us look at this again…
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 X
X 10 X
X 10 X
X 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 92
6. Grid Properties
Its clear that this area could not reach t with cost f=10.
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 93

6. Grid Properties
This is still an open problem…
X X X X X X X X X X X X X X X X X X X X
X X
X X
X X
X X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X 10 10 10 10 X
X X X X X X X X X X X X X X X X
X X
X T X
X X
X X
X X
X X
X X
X X
X X X X X X X X X X X X X X X X X X X X

Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 94
Shortest Path Search Algorithms with
Heuristic and Bidirectional Searches

y ou !
h an k
T
Marcelo Johann
johann@inf.ufrgs.br
www.inf.ufrgs.br/~johann
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 95

Вам также может понравиться