17.3.1. Geometric Container Pruning
In a domain like route planning, where a multitude of shortest path queries have to be answered on the same problem graph, it is possible to accelerate search by means of pieces of information computed prior to the arrival of the queries. As an extreme case, we could compute and memorize all distances and starting edges for the paths between all pairs of nodes using the Floyd-Warshall (
Ch. 2) or Johnson's algorithm; this can reduce the query processing to a mere linear backtracking from target to source. However, the space required for saving this information is
O (
n2), which is often not feasible because of
n being very large. In the next section, we present an approach that reduces the search time in return for more reasonable memory requirements.
Research on annotating a graph by
geometric containers to guide a search algorithm has shown significant gains in terms of the number of expanded nodes. The basic idea is to reduce the size of the search space of Dijkstra's algorithm or the A* algorithm by pruning edges that can be safely ignored because they are already known not to lie on a shortest path to the target. The two stages for geometric speedups are as follows:
1. In a preprocessing step, for each edge e = (u, v), store the set of nodes t such that a shortest path from u to t starts with this particular edge e(as opposed to other edges emanating from u).
2. While running Dijkstra's algorithm or A*, do not insert edges into the priority queue of which the stored set does not contain the target.
The problem that arises is that for
n nodes in the graph we would need
O (
n2) space to store this information, which is not practically feasible. Hence, we do not remember the set of possible target nodes explicitly, but approximations of it, so-called
geometric containers. For containers with constant space requirement, the overall storage will be in
O (
n).
A simple example for a container would be an axis-parallel rectangular bounding box around all possible targets. However, this is not the only container class we can think of. Other options are enclosing circles or the convex hull of a set of points
P, which is defined as the smallest convex set that contains
P. Recall that a set
is called
convex if for every two elements
the line segment between
a and
b is also completely contained in
.
A container will generally contain nodes that do not belong to the target node set. However, this does not hurt an exploration algorithm in the sense that it still returns the correct result, but increases only the search space. Incorporating this geometric pruning scheme into an exploration algorithm like Dijkstra or A* will retain its completeness and optimality, since all shortest paths from the start to the goal node are preserved.
The containers can be computed by
Algorithm 17.1 in time
O (
n2lg
n). It essentially solves a sequence of single-source-all-targets problems, for all nodes; a variable
ancestor (
u) remembers the respective outgoing edge from
s used on the shortest path to
u.
Figure 17.5 shows the result of computing a container for the starting point
C and the resulting container for edge (
C,
D).
The application of containers in explicit graph search is shown in
Algorithm 17.2. While running any optimal exploration algorithm on query (
s,
t), we do not insert edges into the horizon list that are definitely not part of a shortest path to the target. The time required for the computation of these containers pays off well during the main search. Empirical results show a reduction of 90% to 95% in the number of explored nodes in rail networks of different European countries.
Figure 17.6 illustrates the effect of bounding-box pruning in the reduction of traversed edges.
It is instructive to compare shortest path pruning to the related approach of pattern database heuristics (see
Ch. 15). In the latter case, state-to-goal instead of state-to-state information is stored. Pattern databases are used to refine the search for a fixed goal and varying initial state. In contrast, shortest path pruning uses precomputed shortest path information for a varying initial state and goal state.
17.3.2. Localizing A*
Consider the execution of the A* algorithm on a search space that is slightly larger than the internal memory capacity of the computer, yet not as large to require external search algorithms. We often cannot simply rely on the operating system's virtual memory mechanism for moving pages to and from the disk; the reason is that A* does not respect locality at all; it explores nodes strictly according to the order of f-values, regardless of their neighborhood, and hence jumps back and forth in a spatially unrelated way only for marginal differences in the estimation value.
In the following, we present a heuristic search algorithm to overcome this lack of locality.
Local A* is a practical algorithm that takes advantage of the geometric embedding of the search graph. In connection with
software paging, it can lead to a significant speedup. The basic idea is to organize the graph structure such that node locality is preserved as much as possible, and to prefer to some degree local expansions over those with globally minimum
f-value. As a consequence, the algorithm cannot stop with the first solution found; we adopt the Node-Ordering-A* framework of
Chapter 2. However, the overhead in the increased number of expansions can be significantly outweighed by the reduction in the number of page faults.
In the application of the algorithm to route planning we can partition the map according to the two-dimensional physical layout, and store it in a tile-wise fashion. Ideally, the tiles should roughly have a size such that a few of them fit into main memory.
The
Open list is represented by a new data structure, called
Heap of Heaps (see
Fig. 17.7). It consists of a collection of
k priority queues
H1,…,
Hk, one for each page. At any instant, only one of the heaps,
Hactive, is designated as being
active. One additional priority queue
keeps track of the root nodes of all
Hi with
i≠
active. It is used to quickly find the overall minimum across all of these heaps.
Let node
u be mapped to tile ϕ (
u). The following priority queue operations are delegated to the member priority queues
Hi in the straightforward way. Whenever necessary,
is updated accordingly.
The
Insert and
DecreaseKey operations (see
Alg. 17.3) can affect all heaps. However, the hope is that the number of adjacent pages of the active page is small and that they are already in memory or
have to be loaded only once; for example, in route planning, with a rectangular tiling each heap can have at most four neighbor heaps. All other pages and priority queues remain unchanged and thus do not have to reside in main memory. The working set of the algorithm will consist of the active heap and its neighbors for some time, until it shifts attention to another active heap.
To improve locality of the search,
DeleteMin is substituted by a specialized
DeleteSome operation that prefers node expansions with respect to the current page. Operation
DeleteSome performs
DeleteMin on the active heap (see
Alg. 17.4).
As the aim is to minimize the number of switches between pages, the algorithm favors the active page by continuing to expand its nodes, although the minimum f-value might already exceed the minimum of all remaining priority queues. There are two control parameters: an activeness bonus Δ and an estimate Λ for the cost of an optimum solution. If the minimum f-value of the active heap is larger than that of the remaining heaps plus the activeness bonus Δ, the algorithm may switch to the priority queue satisfying the minimum root f-value. Thus, Δ discourages page switches by determining the proportion of a page to be explored. As it increases to large values, in the limit each activated page is searched to completion. However, the active page still remains valid, unless Λ is exceeded. The rationale behind this second heuristic is that we can often provide a heuristic for the total least-cost path that is, on the average, more accurate than that obtained from h, but that might be overestimating in some cases.
With this implementation of the priority queue, the algorithm Node-Ordering-A* remains essentially unaltered; the data structure and page handling is transparent to the algorithm. Traditional A* arises as a special case for Δ = 0 and
, where
h* (
s) denotes the actual minimum cost of a path between the source and a goal node. Optimality is guaranteed, since we leave the heuristic estimates unaffected by the heap prioritizing scheme, and since each node inserted into the
Heap of Heaps must eventually be returned by a DeleteMin operation.
The algorithm has been incorporated into a commercially available route planning system. The system covers an area of approximately 800 × 400 km at a high level of detail, and comprises approximately 910,000 nodes (road junctions) linked by 2,500,000 edges (road elements).
For long-distance routes, conventional A* expands the nodes in a spatially uncorrelated way, jumping to a node as far away as some 100 km, but possibly returning to the successor of the previous one in the next step. Therefore, the working set gets extremely large, and the virtual memory management of the operating system leads to excessive paging and is the main burden on the computation time.
As a remedy, we achieve memory locality of the search algorithm by exploiting the underlying spatial relation of connected nodes. Nodes are geographically sorted according to their coordinates in such a way that neighboring nodes tend to appear close to each other. A page consists of a constant number of successive nodes (together with the outgoing edges) according to this order. Thus, pages in densely populated regions tend to cover a smaller area than those representing rural regions. For not too small sizes, the connectivity within a page will be high, and only a comparably low fraction of road elements cross the boundaries to adjacent pages.
Figure 17.8 shows some bounding rectangles of nodes belonging to the same page.
There are three parameters controlling the behavior of the algorithm with respect to secondary memory: the algorithm parameters Δ and Λ and the (software) page size. The latter one should be adjusted so that the active page and its adjacent pages together roughly fit into available main memory. The optimum solution estimate Λ is obtained by calculating the Euclidean distance between the start and the goal and adding a fixed percentage.
Figure 17.9 juxtaposes the number of page faults to the number of node expansions for varying page size and Δ. We observe that the rapid decrease of page faults compensates the increase of expansions (note the logarithmic scale). Using an activeness bonus
of about 2 km suffices to decrease the value by more than one magnitude for all page sizes. At the same time the number of expanded nodes increases by less than 10%.