Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 1
Shortest Path Search Algorithms with Shortest Path Search Algorithms with Heuristic and Bidirectional Searches Heuristic and Bidirectional Searches
Marcelo Johann
johann@inf.ufrgs.br www.inf.ufrgs.br/~johann
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 3
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
v2 v3
v4 v5
v6
v8 v7 v9
s t
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
v2
v3 v4
v5 v6
v7 v8
s
v9t
v0
v5
v1 v6
v3
v8
v9 v7 v2
v4
admissibility
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 5
Expand first nodes that are closer to the source, or at the same time nodes that are at the same distance ( FIFO ).
source
target Intermediate
search
Complete search
Breadth-First Search (BFS) Breadth-First Search (BFS)
First Shortest Path Search Methods 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(n
2) 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 (l
2) for a circuit with side l.
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 7
The Maze Router 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
The Maze Router 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 9
The Maze Router 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
The Maze Router 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 5 6 7 X
X 7 6 5 4 3 4 5 6 7 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 4 5 6 7 X
X 7 6 5 4 5 6 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 11
The Maze Router 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 9 10 11 12 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 X X 5 4 3 2 1 2 3 4 5 6 7 8 9 10 11 12 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 X X 9 8 7 6 5 6 7 8 9 10 11 12 X X 10 9 X X X X X X X X X X X 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
The Maze Router 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 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 5 4 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 9 8 7 6 5 6 7 8 9 10 11 12 13 14 15 16 X 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 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 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 5 4 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 9 8 7 6 5 6 7 8 9 10 11 12 13 14 15 16 X 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
The Maze Router 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 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 5 4 3 2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 X X 6 5 4 3 2 3 4 5 6 7 8 9 10 11 12 13 14 15 X X 7 6 5 4 3 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 8 7 6 5 4 5 6 7 8 9 10 11 12 13 14 15 16 X X 9 8 7 6 5 6 7 8 9 10 11 12 13 14 15 16 X 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 15
Maze Router
Maze Router ’ ’ s expansion s expansion g++
void print(void);
int bfs(int source, int target) { queue<int> q;
q.push(source);
while (!q.empty()) {
int n = q.front();
q.pop();
if (n==target) return 1;
if (Space[n] != 'X') { Space[n] = 'X';
print();
getchar();
q.push(WEST(n));
q.push(EAST(n));
q.push(NORTH(n));
q.push(SOUTH(n));
} } return 0;
}
#include <iostream>
#include <queue>
using namespace std;
#define SIDE 20
#define PLACE(x,y) ((y)*SIDE+(x))
#define WEST(n) (n-1)
#define EAST(n) (n+1)
#define NORTH(n) (n-SIDE)
#define SOUTH(n) (n+SIDE) char Space[SIDE*SIDE];
void init (void)
{ for (int i=0; i<SIDE*SIDE; ++i) Space[i] = ' ';
for (int i=0; i<SIDE; ++i) {
Space[PLACE(i,0)] = 'X';
Space[PLACE(i,SIDE-1)] = 'X';
Space[PLACE(0,i)] = 'X';
Space[PLACE(SIDE-1,i)] = 'X';
}
for (int i=3; i<SIDE-3; ++i) Space[PLACE(i,10)] = 'X';
}
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 17
Expand first more promissing nodes, according to:
f(n) = g(n) + h(n)
Also known as Best-First Search
source target
Intermediate stages
Complete Search
g(n) h(n)
Heuristic Search
Heuristic Search (A*) (A*) [Hart et al. 1968]
Behaviour of Behaviour of f f , g , g and h and h
g=
h= f = 1
g=0 h=3 f =3 7
g=
h= f = 13
g=
h= f = 2
g=
h= f = 8
g=
h= f = 14
g=
h= f = g= 9
h= f = 6
Open List:
7
c=1 c=2 c=2
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2
g=
h= f = 10 c=2
g=
h= f = 4
c=1 c=2
g=
h= f = 11
c=1
c=2
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 19
g=
h= f = 9
Open List:
8, 1, 13, 6
c=2 g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2
g=
h= f = 10 c=2
g=
h= f = 4
c=1 c=2
g=
h= f = 11
c=1
c=2 g=1
h=4 f =5 1
g=0 h=3 f =3 7
g=1 h=4 f =5 13
g=
h= f = 2
g=2 h=2 f =4 8
g=
h= f = 14 g=1
h=5 f =5 6
c=1 c=2
c=1
c=1 c=1
c=1 c=1
c=1
Behaviour of Behaviour of f f , g , g and h and h
Open List:
1, 13, 6, 9, 2, 14
g=
h= f = 10 c=2
g=
h= f = 4
c=1 c=2
g=
h= f = 11
c=1
c=2 g=1
h=4 f =5 1
g=0 h=3 f =3 7
g=1 h=4 f =5 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=3 h=3 f =6 14
g=4 h=1 f =5 g=1 9
h=4 f =5 6
c=1 c=2 c=2
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2
Behaviour of Behaviour of f f , g , g and h and h
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 21
g=
h= f = 10 c=2
g=
h= f = 4
c=1 c=2
g=
h= f = 11
c=1
c=2 g=4 h=1 f =5 9 c=2
g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2 g=1
h=4 f =5 1
7
g=1 h=4 f =5 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=3 h=3 f =6 14 g=1
h=4 f =5 6
c=1 c=2
c=1
c=1 c=1
c=1 c=1
c=1 g=0 h=3 f =3
Open List:
1, 13, 6, 9, 2, 14 ties ties
Behaviour of Behaviour of f f , g , g and h and h
g=
h= f = 10 c=2
g=
h= f = 4
c=1 c=2
g=
h= f = 11
c=1
c=2 g=4 h=1 f =5 9 c=2
g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2 g=1
h=4 f =5 1
7
g=1 h=4 f =5 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=3 h=3 f =6 14 g=1
h=4 f =5 6
c=1 c=2
c=1
c=1 c=1
c=1 c=1
c=1 g=0 h=3 f =3
Open List:
1, 13, 6, 9, 2, 14 But not critical But not critical as f * = 6 as f * = 6
Behaviour of Behaviour of f f , g , g and h and h
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 23
Effect of the Effect of the estimation estimation efficiency efficiency
g=4 h=1 f =5 9 c=2
g=
h= f = 3
c=1 c=2
g=
h= f = 15
c=1
c=2 g=1
h=4 f =5 1
7
g=1 h=4 f =5 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=3 h=3 f =6 14 g=1
h=4 f =5 6
c=1 c=2
c=1
c=1 c=1
c=1 c=1
c=1 g=0 h=3 f =3
Quality of the estimator h Quality of the estimator h
The A* The A* Algorithm 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
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
7 3
h = estimation function
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 25
The The A* A* Algorithm 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
The A* The A* Algorithm 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 27
The The A* A* Algorithm 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
The A* The A* Algorithm 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 29
The The A* A* Algorithm 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
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
The A* The A* Algorithm Algorithm
Maze router-like with obstacles
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 31 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
The The A* A* Algorithm Algorithm
Saved effort
Some
Some Notation… 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)
P a-b = path from a to b
P a-b * = optimal path from a to b
f*(n) = cost of P s-n * ∪ P n-t * (going through n)
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 33
Admissibility (* *): cost from n to t ≥ h(n) ensures the shortest path
Consistency: k(n1,n2) + k(n2,n3) ≥ k(n1,n3) Every expanded node
has optimal cost
known n
1n
2n
3 k(n1,n2) k(n2,n3)k(n1,n3)
n t
h(n)
Shortest path from n to t
g(n) = g*(n)
Properties of the Heuristic Estimator Properties of the Heuristic Estimator
Properties of the
Properties of the A* Algorithm A* Algorithm
Continuity - the search has always an open node ∈ P
s-t*.
Completeness - A* terminates.
Admissibility - A* finds the optimal path.
sufficient condition for expansion - f(n) < P s-t * .
Necessary condition for expansion - f(n) ≤ P s-t * .
Indeterminism on critical ties - biasing.
Monotonicity - if n 2 is expanded after n 1 then f(n 2 ) ≥ f(n 1 ) .
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 35
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…
Two simultaneous search fronts
Meeting node: recognized by both fronts
Terminating condition: f(n) > min[f(m)]
Leads to overlapping
source
target Source search
Unidirectional search ( to compare)
Target search
Meeting node m
Bidirectional Search Bidirectional Search [Pohl 1971]
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 37
Two simultaneous search fronts
Meeting node: recognized by both fronts
Terminating condition: f(n) > min[f(m)]
Leads to overlapping
source
target
Source search Target search
Meeting node m
Bidirectional Search Bidirectional Search
Two simultaneous search fronts
Meeting node: recognized by both fronts
Terminating condition: f(n) > min[f(m)]
Leads to overlapping
Bidirectional Search Bidirectional Search
a
e c
b d
f 4
6
5
6 4
6 6
5
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 39
Two simultaneous search fronts
Meeting node: recognized by both fronts
Terminating condition: f(n) > min[f(m)]
Leads to overlapping
Bidirectional Search Bidirectional Search
a
e c
b d
f 4
6
5
6 4
6 6
5 g=10
g=9
Two simultaneous search fronts
Meeting node: recognized by both fronts
Terminating condition: f(n) > min[f(m)]
Leads to overlapping
Bidirectional Search Bidirectional Search
a
e c
b d
f 4
6
5
6 4
6 6
5 g=10
First Meeting
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 41
Goal: to combine the advantages of both The challenge:
Terminating condition
Overlapping
The missing fronts problem
The missing fronts problem
Goal
Bi-A*
Bi-BFS
[Kwa 1989]
Heuristic Bidirectional Search Heuristic Bidirectional Search
One front looks at the other
Calculates distance to each node in the oposite front f(n) = g
s(n) + min[k(n,p
i) + g
t(p
i)]
gs(n) gt(pi)
k(n,pi ) s
n
t pi
Requires quadratic time (or space)
Wave-Shapping Wave-Shapping
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 43
Two separate searches following one another The first BFS and the second A*, usualy
gs(n)
gt(pi)
k(n,pi )
s n
t pi First search, up to a
predetermined perimeter
Second search with front-to-front estimates
It demonstrates the potencial of bidirectional heuristic
Perimeter Search Perimeter Search [Manzini 1995]
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 45
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]
The The LCS* Algorithm LCS* Algorithm
Conditions for Conditions for expansion expansion … …
Sufficient Condition for Expansion
A* expands all nodes with f(n) < P s-t *
Necessary Condition for Expansion
A* only expands nodes with f(n) ≤ P s-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 47
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
.The The Pruning Power Pruning Power! !
Resistence ( min idea [Kaindl 96])
gt(pi) t
pi
k(pi ,t)
R
t= Min[g
t(p
i) - k(p
i,t)]
F(n) = f(n) + R
tDynamic Estimation Dynamic Estimation
gt(pi) t
pi
k(pi ,t)
A good idea for BFS, but
with A* the minimum values
are always at the opposite
side of the search
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 49
Penalty ( max idea [Kaindl 96])
gt(pi) t
pi
k(p
i,s)
gs(n)
s n
ht(n) hs(n) ht(pi)
P
t= Min[g
t*(p
i) + k(p
i,s)]
F(n) = g
s(n) + P
t- h
t(n)
Dynamic Estimation Dynamic Estimation
LCS* uses both, as penalties can be smaller than resistances in some cases
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
Cooperation and Visibility Cooperation and Visibility
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 51
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 L min (best cost so far)
LCS* is Admissible LCS* is Admissible
LCS*
LCS* ’s ’ s code : code :
Too many details!
Ask me later on if you want…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 53
Expanded nodes and actual runtime: typical
200 by 200 grids with random costs, mean 100, minimum 50, maximum 300
0 0.2 0.4 0.6 0.8 1
100 140 180 220 260 300 340 380
range of random costs
ratio LCS*/A*
nodes runtime
Results: LCS* versus A* Results : LCS* versus A* [Johann 2000]
Specification of random costs Specification of random costs
maximum
minimum Center (mean)
0
range
DC
cost
AC
costs
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 55
Expanded nodes
Expanded nodes in 2D in 2D grids grids
ε -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 57
LCS*/A* in 2D grids, regular cost regime
Testing Testing ε- ε -admissibility admissibility
200 by 200 grids with random costs, mean 100, minimum 50, maximum 300
0 0.5 1 1.5 2 2.5 3
15 25 35 45 55 65 75 85 95
range of random costs
ratio LCS*/A*
100%
96%
100x100 random BFS, DFS and multi-DFS mazes
LCS* wins on harder mazes LCS* wins on harder mazes
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 59
70 nodes, all 70x70 path problems
LCS* wins on random graphs LCS* wins on random graphs
70 nodes, all 70x70 path problems
A* almost optimal A* almost optimal in in geometric graphs geometric graphs
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 61
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…
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.
Main Conclusions
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 63
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.
Pathological cases
Direction choosing criteria:
Alternating
Smallest f
Cardinality
Inertial Cardinality
Expanding from the most difficult first But this contradicts others
Open question
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 65
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…
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 67
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.
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 69
Open List:
13
g=
h= f = 10 c=1
g=
h= f = 4
c=1 c=1
g=
h= f = 11
c=1
c=1 g=
h= f = 1
g=
h= f = 7
g=0 h=4 f =4 13
g=
h= f = 2
g=
h= f = 8
g=
h= f = 14
g=
h= f = g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=
h= f = 15
c=1
c=1
Uniform costs
Open List:
14,7
g=
h= f = 10 c=1
g=
h= f = 4
c=1 c=1
g=
h= f = 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=
h= f = 2
g=
h= f = 8
g=1 h=3 f =4 14
g=
h= f = g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=
h= f = 15
c=1
c=1
Critical Ties
f(14) = f(7) = f *
f(14) = f(7) = f *
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 71
Open List:
15,8,7
g=
h= f = 10 c=1
g=
h= f = 4
c=1 c=1
g=
h= f = 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=
h= f = 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=
h= f = g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Can choose what you want
Open List:
11,9,8,7
g=
h= f = 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Nodes close to the target first
worst
best
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 73
Open List:
15,7,2,3
Nodes close to the target first
Only
Only four four nodes expanded nodes expanded
g=4 h=0 f =4 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
g=4 h=0 f =4 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Open List:
15,7,2,3
But pay attention to:
Degree of freedom
Degree of freedom
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 75
g=4 h=0 f =4 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Open List:
15,7,2,3
But pay attention to:
Degree of freedom Degree of freedom
g=4 h=0 f =4 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Open List:
15,7,2,3
But pay attention to:
Degree of freedom
Degree of freedom
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 77
g=4 h=0 f =4 10 c=1
g=
h= f = 4
c=1 c=1
g=3 h=1 f =4 11
c=1
c=1 g=
h= f = 1
g=1 h=3 f =4 7
g=0 h=4 f =4 13
g=3 h=3 f =6 2
g=2 h=2 f =4 8
g=1 h=3 f =4 14
g=3 h=1 f =4 g= 9
h= f = 6
c=1 c=1 c=1
c=1
c=1 c=1
c=1 c=1
c=1
g=
h= f = 3
c=1 c=1
g=2 h=2 f =4 15
c=1
c=1
Open List:
15,7,2,3
But pay attention to:
options
The A* The A* Algorithm 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
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
7 3
h = estimation function
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 79
The A* The A* Algorithm 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
The A* The A* Algorithm 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 81
The A* The A* Algorithm 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
The A* The A* Algorithm 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 83
The A* The A* Algorithm 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…
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
The A* The A* Algorithm Algorithm
After it escapes, A* again
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 85 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
The A* The A* Algorithm Algorithm
There are degrees of freedom in backtrace!
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 87
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
A simple visual example…
Bidirectional Heuristic Shortest Path Search - Marcelo Johann - 2009 Visit to Intel: Slide 89
A simple visual example…
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 91
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.
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 93
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
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