Updating Shortest Paths - Semantic Scholar

Report 4 Downloads 214 Views
Updating Shortest Paths Stefan Edelkamp 1 Abstract. Moving target search is a state space approach

for nding non-stationary goals. The plot is given by a realtime situation in which the target has to be captured by a so-called problem solver. The model chosen in the trailblazer search allows the problem solver to maintain a map of the explored graph and to move faster than the target. Within this map the shortest paths to a current position are calculated after every move that a competitor commits. The trailblazer search does not use information about former maps. Thus, the main problem tackled in this paper is the incremental calculation of the shortest path tree. We proof the correctness of our approach, reason about its eciency and show that it is empirically good in the average case.

1 Introduction Chasing a moving target is a natural concept, e.g. for an animal to survive. The strategies of the hunter and its prey in the chase re ect the abilities of the animals, such as speed, coordination and senses. In most cases the hunter has to change its plan due to the reaction of the victim and vice versa. We simplify the situation to get the chase in state space search. Therefore, we allow both the problem solver and the target to perform only state transitions, and concentrate on exploring and updating the shortest path information. The search itself relies on the proposed model of the chase. We assume that the (problem) solver knows the location of the target, has a lower bound estimate of the shortest path distance between every two positions, and is moving faster than the target. The state space can be modelled as a (positively) weighted graph G = (V; E; w), wherein a subgraph has been explored. In most cases G is undirected. In Ishida and Korf (1991) the solver tries to learn the shortest path distances between every two states in the space, with a strategy based on Korf's (1990) well-known learning real-time A algorithm. Unfortunately, the space requirements are tremendous. According to the assumptions given above the solver may maintain the set of expanded nodes (his own and the target ones). Chimura and Tokoro (1994) call this representation a map and the chase itself trailblazer search. In the rst phase the map consists of two di erent trails, one for the solver and one for the target, respectively (cf. Fig 1). The solver tries to nd the trail of the target by using the heuristic estimation for the set of newly generated nodes. If the solver crosses the trail of the target or vice versa the chase phase is invoked in which the solver hunts the target by traversing the shortest path 1 Institut fur Informatik, Albert-Ludwigs-Universitat, Am Flug-

hafen 17, D-79110 Freiburg, eMail: [email protected]

c 1998 S. Edelkamp ECAI 98. 13th European Conference on Arti cial Intelligence Edited by Henri Prade Published in 1998 by John Wiley & Sons, Ltd.

found in the map. Since the solver is faster, it will succeed in catching up with the target. PS 4 2 1

G = (V; E; w)

3 1

2

h

2 3

T

Searching a moving target in an undirected graph. The arrows indicate the shortest path tree with respect to the problem solver and the target.

Figure 1.

The costs of map maintenance in the trailblazer search are high, since the shortest path distances to the current position are updated in every step. Chimura and Tokoro (1994) use Dijkstra's (1959) shortest path algorithm, which has a time complexity of O(n2 ), with n being the number of nodes in G. The decision time of O(n2 ) may be too long to solve a large scale real-world situation. Therefore, Sasaki et al. (1995) have improved the trailblazer approach by introducing subproblem spaces and a second order or so-called abstract map. The subproblem structure has to be either known prior to the search or to be predicted in a learning phase. The claimed time result of O(n4=3 ) for rearranging the shortest path tree only applies to grid-like structures. Instead of the algorithm of Dijkstra in a maze we may also invoke a simple breadth rst search for a time complexity of O(n) (the branching factor is less than four). Last but not least, in grids di erent paths overlap on crossings only, meaning that it is more ecient to consider the underlying weighted graph structure. Dijkstra's algorithm does not need the information calculated so far. Hence, the expensive calculation of several shortest path trees in search phase is not necessary at all. In this paper, however, we propose an algorithm which reduces the decision time required to x the shortest path from the problem solver to the target at the time when the trails overlap by using the shortest path information calculated so far. We deeply investigate the question of how to calculate the shortest paths in iteration i using the knowledge of iteration i 1. The main issue is to prevent the traversal of the whole expanded graph. If the solver or the target move to a position

subset of nodes in Tu we nally determine the new position of v and set the root to v. More precisely, we execute the following procedure, in which the IncreaseKey (z0 ; z0 :) operation updates the improvement value of z0 in Open (if z0 is not already in Open, it is inserted with value z0 :).

that has not been visited before, we achieve constant run time. The case in which the node has already been encountered is studied in detail. The algorithm for performing a move can best be thought of as a dynamic version of the algorithm of Dijkstra. In the worst case (n + e) edges in the shortest path tree have to be rearranged, but we achieve better performance in the average case.

procedure DoMove u:pred v; v:pred ; if (v 2 Vi 01 ) 8e = fz ; zg 2 Tu  Tv

// v is new root // v has been reached before // z0 2 Open, z 2 Closed BuildPath(z'); BuildPath(z) // calculate z0 : and z: (z0 ) z0 : (z: + w(z; z0 )) // x improvement if (0 (z0 ) > 0) // alternative better z :pred z // change predecessor z0 : z: + w(z; z0 ) // change estimate z0 : (z0 ) + z0 : // change improvement Open.IncreaseKey (z0 ; z0 :) // z0 : is new value Broadcast(Open) // inform neighborhood u v; v Choice // choose new position to go to

2 Searching the Target

We consider the exploration phase of the trailblazer search. Since the trails of the solver and of the target are not connected, we only describe changes to the shortest path tree rooted at the position of the solver. Let u and v be the solver position before and after committing the move in the i-th generation and Gi = (Vi ; Ei ) be the explored graph of the solver in iteration i. Let i (z) be the length of the shortest path from z to the root node of Gi . Further on, let Tv be the subtree of the shortest path tree in Gi 1 rooted at v and Tu be the remaining subtree with respect to root u. In other words, the trees Tu and Tv are partitioning Vi 1 . Initially, let Open and Closed be the set of nodes in Tu and Tv , respectively, for which there is an edge e = fz0 ; zg connecting the two trees. We associate four values with every node in the space: the predecessor pred within the shortest path tree, a value  of the current shortest path distance to the root, an improvement value  according to an abbreviation found, and a ag calc denoting which  values are valid in the current iteration. When we move from u to v, we rst change the preceding relationship of u and v to establish a rooted tree at v. If v has not been expanded before, we conclude that the shortest path tree to v can be composed of the shortest path tree to u and the new edge fu; vg. Hence, the shortest path tree is correct. This is a common case in the chase and takes only constant time. If v is not new, then at least the old subtree of v inherits the shortest path tree structure, since a subpath of the shortest path in a graph is known to be a shortest path as well.

The  values of the nodes z and z0 equal i 1 (z) w(u; v) and i 1 (z0 ) + w(u; v), respectively, and are determined in a backward traversal BuildPath of the shortest path tree. By using the ag calc at every node, we assure that for each invocation of DoMove in BuildPath value  is calculated at the most once.

procedure BuildPath (z) do p1 z; i 1 // start at z while (pi =6 v) and not (pi :calc) // until x root or visited i i + 1 pi pi 1 :pred; // next node path p if (pi = v) // root node reached v: 0; v: 0; v:calc true // shortest path is zero 8j 2 fi 1; : : : ; 1g // traverse path, top-down pj : pj+1 : + pj+1 : + w(pj+1 ; pj ) // set  value pj : 0; pj :calc true // improvement at pj is zero To avoid the reinitialization of the ags calc when entering iteration i we can use iteration numbers to distinguish visited

and unvisited nodes. Now we turn our attention to the Broadcast routine. Until the priority queue gets empty, we consider the node z with the highest  value and calculate the set (z) of successors of z. The new improvement value (z0 ) for z0 in (z) is deter0 mined, and z is inserted into Open. If (z0 ) is positive then the shortest path tree has to be changed due to the alternative path found.

v

u v 1111 0000 0000 1111 0000 1111 0000 z1111 000 111 0000 1111 000 111 0000 1111 000 111 000 111 000 111 000z 111 Tu

u

0

Tv

Figure 2.

z 1111 0000 0000 1111 z 0

Tu 0

Tv0

procedure Broadcast (Open ) while (Open ! = ;) z 0 Open.DeleteMax 8z 2 (z) \ Vi0 1

// Closed Closed [fzg // for all successor nodes BuildPath (z ) // calculate z0 : (z0 ) z0 : (z: + w(z; z0 )) // x improvement if (0 (z0 ) > 0) // alternative is better z0 :pred z // change predecessor z : z: + w(z; z0 ) // change estimate z0 : (z0 ) + z0 : 0 0 // change improvement Open.IncreaseKey (z ; z :) // z0 : is new value

Broadcasting shortcuts within the shortest path tree.

The strategy for the rest of the nodes is to explore the horizon Open until the old path in Tu is shorter than the new path o ered by v (cf. Fig. 2). Therefore, we broadcast the improvement  of the shortest path values by using a priority queue, a common data structure for totally ordered sets (cf. Cormen et al. (1990)). Having updated the shortest path values of the

Search and Meta-Heuristics for AI

656

S. Edelkamp

If z0 is reached for the rst time in Broadcast, i.e., the value z0 : is calculated in BuildPath, then z0 : equals i 1 (z0 ) + w(u; v). But since the  value of the rst node x on the path p to z0 may change over time we have to restore i 1 (z0 ) given the information of x: and x:. This is done by incrementing y: with x: for all y on p.

Lemma 2 Let b(z) for z in the exploration graph be de ned

2.1 Correctness

have 0 > b(x) b(y) = i 1 (x) i 1 (y) i (x) + i (y) = i 1 (x) i 1 (y) + w(x; y): This implies i 1 (x) + w(x; y) < i 1 (y). This is in contradiction to the fact that shortest paths satisfy the triangular inequality. 2 The value b is the total improvement that has been made at a node. Theorem 1 will show that DoMove correctly computes the shortest path tree. Thus Lemma 2 immediately leads to the following result.

as b(z) = i 1 (z)+ w(u; v) i (z) and let x be the predecessor of y on a shortest path from y to v. Then b(x)  b(y).

Proof: Applying the de nition of b to x and y we get b(x) = i 1 (x)+w(u; v) i(x) and b(y) = i 1 (y)+w(u; v) i (y), respectively. Suppose b(x) is less than b(y). We then

The Broadcast procedure is very similar to the algorithm of Dijkstra where the priority queue is ordered with respect to the  values.

Lemma 1 Let Vi be the set of nodes in the exploration graph

Gi of iteration i and let Ci be the subset of Vi for which the

ag calc is set. Further on, let u be the root node of Gi 1 and v be the root node of Gi . For all nodes y in Ci the following equation is ful lled:

y: = i 1 (y) + w(u; v) y::

(1)

Corollary 1 The value b never increases in the shortest path

Proof: The  value at each node y in Ci is set for the rst time within the procedure BuildPath. Let p = (x = pi ; : : : ; p1 = z) be the path that is established in BuildPath. Using the stated result inductively we have x: + x: = i 1 (x) + w(u; v). For the next node pi 1 we have pi 1 : = 0 and

tree with respect to the new root node v.

Theorem 1 The DoMove algorithm is correct, i.e., it com-

putes the shortest path tree with respect to the new root node v.

Proof: We have already shown that the shortest path tree is correct when an unexplored node v is reached and that in this case the shortest path tree structure in Tv is also valid. The rest of the proof splits into two parts. First we show that the shortest path tree for all expanded nodes in Tu is correct. These are nodes, which are or have been maintained in the priority queue. Second, we proof the correctness of the shortest path tree for the rest of the nodes in Tu . Let us consider the rst case. It suces to show that at the time when a node q is expanded the shortest path given by the predecessor relation is correct, since it does not change afterwards. Suppose the relation is violated for the rst time at q. Then there is a path p in the resulting shortest path tree with weight i (q) strictly less than q:. At the time when q is expanded there exists an x in Closed and an adjacent y in Open on p. Let (x; y) be minimal with that property. Since all elements in the priority queue are marked with a calc ag, we can apply Lemma 1 for these nodes.

pi 1 : = x: + x: + w(x; pi 1 ) = i 1 (x) + w(u; v) + w(x; pi 1 ) = i 1 (pi 1 ) + w(u; v): Therefore, Equation 1 is ful lled for pi 1 . Similary, for all other nodes pj , j 2 fi 2; : : : ; 1g on p; Equation 1 is inherited from the predecessor node pj+1 .

It remains to be shown that Equation 1 is valid after each assignment of  and  values in the procedures DoMove and Broadcast. Let y be reached for the rst time by node x and let p be the path to y considered in BuildPath. Since y is on p, for the old value of y: we have i 1 (y) + w(u; v) by the considerations described above. On the other hand the old value of y: is zero. The new value y: is de ned by y: = x: + w(x; y). Thus the new value y: is given by

y: = i 1 (y) + w(u; v) (x: + w(x; y)):

y: = i 1 (y) + w(u; v) y: = i 1 (y) + w(u; v) (i (x) + w(x; y)) = i 1 (y) + w(u; v) i (y) = b(y)  : : :  b(q) = i 1 (q) + w(u; v) i (q) > i 1 (q) + w(u; v) q: = q: Since q is expanded and y is not, the value y: does not exceed q:. This is a contradiction. Therefore, the shortest path to q is correct.

This implies Equation 1. Now suppose that y is reached another time. If (y) is not greater than zero, Equation 1 remains true since nothing is changed at all. Otherwise y is reached by a node, say x0 , and y: is set to x0 : + w(x0; y). Further on, y: is increased by (y). Therefore, by using the stated result of Equation 1 as an invariant for y: we infer that the old value of y: cancels, such that we have

y: = i 1 (y) + w(u; v) (x0 : + w(x0 ; y)) = i 1 (y) + w(u; v) y::

It remains to be shown that the shortest paths are correct for the set Tu Closed as well. Suppose this is not true and let q be a node for which the estimate is wrong. There then exists

2

Search and Meta-Heuristics for AI

657

S. Edelkamp

S

i.e., Sv (G0 ) = v2G pv . By using Fibonacci heaps for the implementation of the priority queue (the IncreaseKey operation is available in amortized constant time, see Cormen et al. (1990)), s.t. we achieve a total of O(n0 log n0 +e0 +jSv (G0 )j). It is usual to assume that at least a xed fraction of the nodes Sv (G0 ) have more than one successor. This leads to at least jSv (G0 )j=c leaves in Sv (G0 ), such that jSv0(G0 )j0 is in O(n0 ). 0 Thus, the worst case run time is O(n log n + e ) amortized. If max = maxfz0 :jz0 2 Open g is small and the weights are all integers then the priority queue can be realized using max buckets. The idea is common sense in state space search since several domains are integer weighted. Note, that max is smaller than max = maxfz0 :jz0 2 Closed g. Moreover, it can be determined beforehand, such that the time complexity (using the assumption jSv (G0 )j 2 O(n0 )) of this approach is O(n0 + e0 + max ). We can improve the algorithm if we terminate the calculation of Tv and the broadcasting of the improvement  at articulation points a of Gi , i.e., nodes that disconnect Gi . In a shortest path subtree of a no preceding relationship can change since all shortest path to v via a were correct in Gi 1 . The set of articulation points A can be calculated dynamically by discarding all cycles found in the search. There are three opportunities to nd the set of edges Tu  Tv . First, we might examine all edges e = fz; z0 g and determine the root nodes of z and z0 . The time requirements are proportional to the size of the entire graph. Alternatively, we can start at v and explore the tree Tv in a depth rst traversal until we nd the nodes with a predecessor which is not in Tv . This costs O(jTv j) time, with pz being the generating path for z0 . The third variant is to explore the tree Tu analogous to the exploration of Tv in the second case. The second alternative looks most promising, since the size of Tu is supposed to be large compared to the size Tv .

v u p x

y

e

q

Figure 3.

The connection of the two sets Tu Closed and Tv [Closed.

a shortest path p from q to v that does not traverse fu; vg. The path p connects Tu Closed and Closed via e = fx; yg (cf. Fig. 3). At the time when y was expanded the value y: was correct by the analysis given above. The assignment of x: to y: + w(u; v) has not been executed because the predecessor of x is not set to y. Thus x: was correct before and there is another shortest path p0 from q to v which does not traverse e. One after another all edges between Closed and Tu Closed can be discarded. Therefore, there exists a shortest path from q to v traversing fu; vg and the new shortest path i (q) equals i 1 (q) plus w(u; v). 2 Th argumentation in Theorem 1 is similar to the correctness proof for the algorithm of Dijkstra (cf. Cormen et al. (1990)), but uses Lemma 2 transitively, and Lemma 1 to connect the  and the  values. We now consider the worst case example shown in Fig. 4. Since the predecessor of every node changes, we have to traverse the entire graph in order to readjust the shortest path tree . Therefore, every algorithm needs at least (n) time to readjust the shortest path tree. n

2 -1 1 2

Figure 4.

n

0

3 Results In the experiments we consider the chase in a (100x100) maze with a 35 percent chance that a square represents a wall. The choice of the neighbor v in (u) depends on the strategy of the moving object. It is called shy if it tries to increase the heuristic estimate and it is called aggressive if it tries to decrease it. Usually, the problem solver is aggressive. An interesting observation in a maze is that an aggressive target performs better than a shy one, since it does not tend to walk into dead ends. A random strategy chooses the successor node randomly. One problem in the chase is oscillation as illustrated in Fig. 5 where the (aggressive) problem solver moves right when the (aggressive) target moves left and vice versa.

1 u n-3 n-2 n-1 n 6 4 8 2 v 2 2 2 7

2

5

2

3

2

A whole tree has to be restructured.

2.2 Eciency

How fast is the update algorithm for the shortest path tree? Suppose, the initial sets Open and Closed are found. Let G0 be the subgraph of n0 nodes and e0 edges that are involved in the modi cations within the priority queue. We might assume that n0 is small compared to the total number n of nodes in G. The BuildPath procedure calculates the shortest path values in the subtree Sv (G0 ) of v, whereas Sv (G0 ) is the set of nodes described by the generating paths of the nodes in G0 ,

Search and Meta-Heuristics for AI

0

T PS

Figure 5.

658

A live lock situation in the chase.

S. Edelkamp

This can be dealt with in the following way. The problem solver chooses the next position by considering only the unexpanded successors. If there are none it moves to the predecessor of the current position. In a maze Dijkstra's algorithm is a breadth rst search. In Fig. 6 we compare the number of expansions of our dynamic DoMove algorithm with the number of expansions when traversing the whole exploration graph. One iteration consist of a hundred DoMove steps and we have depicted fteen independent iterations.

v

1

u 10

1

10 10

=6

3

z =9

1

10

=6

=8

c 10

a

1

b  =?

6000 aa ar naa nar a r

Number of expanded nodes

5000

The node ordering is crucial. If c and b are expanded before a, then the incorrect predecessor of b in the shortest path tree is set to c

Figure 7.

4000

except in special graph classes such as directed acyclic graphs and uniformly weighted graphs. It is an open question, whether or not the dynamic variant can be designed to be optimal in this sense, since additional shortest path information pertaining to the old position is available. Our algorithm performs well on average. There may exist a relaxed strategy which could spread the peaks of rearrangements over successive moves in order to get a short decision time and, therefore, a better real-time performance. Another question of further research is to nd the initial partition of the explored tree incrementally; for a better performance compared to the strategies provided.

3000

2000

1000

0 0

2

4

6

8 Iteration Number

10

12

14

16

Experimental results on dynamic updating of the shortest path tree. The descriptor a is short for an aggressive strategy, whereas r abbreviates a random strategy. Further on, the pre xes a and na denote, whether or not pruning at articulation points is performed. Figure 6.

ACKNOWLEDGEMENTS

S. Edelkamp is supported by DFG within the graduate program on human and machine intelligence. Thanks to Jurgen Eckerle for fruitful and helpful discussions concerning this research.

If the solver is aggressive and if we use pruning at articulation points, our algorithm performs at a ratio from less than one percent (iteration 4,6 and 15) up to about ten percent (iteration 8) of the total number of expanded nodes in Dijkstra's algorithm (4.5 percent on average). If we apply our algorithm scheme without using articulation points, we use tree quarters less time compared to the approach of Chimura and Tokoro (1995). The maximum  value is 10.5 for a random strategy and 8.5 for the aggressive strategy on average for the 15 iterations. The maximum  values, however, are 36 and 40.3, respectively.

REFERENCES

[1] F. Chimura and M. Tokoro. The trailblazer search: A new method for searching and capturing moving targets. In Proceedings of the 12th National Conference on Arti cial Intelligence, pages 1347{1352, Menlo Park, CA, USA, 1994. AAAI Press. [2] T. H. Cormen, C. E. Leiserson, and R. L. Rivest. Introduction to Algorithms. The MIT Press, 1990. [3] E. W. Dijkstra. A note on two problems in connexion with graphs. Numerische Mathematik, 1:269{271, 1959. [4] T. Ishida and R. E. Korf. Moving target search. In R. Myopoulos, John; Reiter, editor, Proceedings of the 12th International Joint Conference on Arti cial Intelligence, pages 204{211, Sydney, Australia, 1991. Morgan Kaufmann. [5] R. E. Korf. Real-time heuristic search. Arti cial Intelligence, 42(2-3):189{211, 1990. [6] T. Sasaki, F. Chimura, and M. Tokoro. The trailblazer search with a hierarchical abstract map. In C. S. Mellish, editor, Proceedings of the Fourteenth International Joint Conference on Arti cial Intelligence, pages 259{265, San Mateo, 1995. Morgan Kaufmann.

4 Conclusion and Outlook This paper provides a dynamic estimation of the lower bound of the distance between a hunter and its prey, who both traverse a state space graph. We present a fast solution to the dynamic version of Dijkstra's shortest path algorithm, analyze the eciency and proof the correctness of our approach. We have used a priority queue in our solution since the ordering of the nodes in the update procedure is crucial as shown in Figure 7. The algorithm of Dijkstra is famous in computer science. The gap between the best lower bound, i.e. the input size of O(n + e), and the fastest algorithm has as yet not been closed

Search and Meta-Heuristics for AI

659

S. Edelkamp