The Algorithm of the Time-Dependent Shortest Path Problem with Time Windows

In this paper, we present a new algorithm of the time-dependent shortest path problem with time windows. Give a directed graph ( ) , G V E = , where V is a set of nodes, E is a set of edges with a non-negative transit-time function ( ) e c t . For each node v V ∈ , a time window [ ] , v v a b within which the node may be visited and v v a t b ≤ ≤ , t T ∈ is non-negative of the service and leaving time of the node. A source node s, a destination node d and a departure time t0, the timedependent shortest path problem with time windows asks to find an s, d-path that leaves a source node s at a departure time t0; and minimizes the total arrival time at a destination node d. This formulation generalizes the classical shortest path problem in which ce are constants. Our algorithm of the time windows gave the generalization of the ALT algorithm and A* algorithm for the classical problem according to Goldberg and Harrelson [1], Dreyfus [2] and Hart et al. [3].


Introduction
The shortest path problem on graphs is a problem with many real-life applications such as: route planning in an internet, car navigation system, traffic simulation or logistic optimization.The shortest path problem is a classical combinatorial optimization problem.It has countless applications and so far numerous algorithms have been proposed (see Ahuja et al. [4]) including the well-known Dijkstra's algorithm.Recently, because some of the new improvement becomes fairly difficult, researchers began to study variants of this problem which include the time-dependent and the time windows generalization.
Give a directed graph ( )  [5], El-Sherbeny and Tuyttens [6], Tuyttens et al. [7] and El-Sherbeny [8]).One can notice that the undirected graphs can be treated by replacing each undirected edge with two reverse directed edges.Without losing of the generalization, we suppose that a destination node d is reachable from a source node s.For simplicity, we suppose that the domain of the definition for all ( ) e c t is + ℜ , but our algorithms work for the discrete version too.We also assume the time complexity to calculate a ( ) e c t which is bounded by some constant α .This formulation generalizes the classical shortest path problem with constant ( ) e c t and o t .It can further handle time-variable edge costs, thus it has more application than the classical one, which is also referred to as the static problem in contrast.
In Cook and Halsey [9], it has considered and given a dynamic programming algorithm which is not polynomial-time at all.Dreyfus [2] suggested a polynomial-time straightforward generalization of the Dijkstra's algorithm.However, he did not notice that it works correctly only for instances satisfying the First-In First-Out (FIFO) property, i.e., for any edge With this property, we can ensure that there is no cycle of negative transit-time, hence a simple optimal solution exists.This was pointed out and discussed later (see Halpern [10], Kaufman and Smith [11] and Orda and Rom [12]).
On the other hand, the general problem without the FIFO constraint is NP-hard if the waiting at nodes is not allowed (see Sherali et al. [13]).In Orda and Rom [12], it showed that, if the waiting at nodes is allowed, which is natural in transportation systems, any instance can be converted to an equivalent instance that satisfies the FIFO property; hence, no waiting is needed, and that can be done in polynomial time (if ( ) e c t can be calculated in polynomial time).Thus, in the following, we will only consider instances that satisfy the FIFO property.
Even with the FIFO constraint, unlike the static case, studies are not rich.Dreyfus's proposal of the generalized Dijkstra's algorithm, despite of many studies (see Dean [14], Ding et al. [15], Halpern [10], Kanoulas et al. [16], Kaufman and Smith [11] and Orda and Rom [12]), there was no significant advancement in solving the problem more efficiently.
In this paper, we give a new algorithm of the time-dependent shortest path problem with time windows that generalizes the ALT algorithm (see Goldberg and Harralson [1]) and A * algorithm for the static problem, unlike the generalized Dijkstra's algorithm, which uses a function h to estimate the distances between nodes in the graph in Section 2. In Section 3, we give an application instance of our algorithm and a generalization of the ALT algorithm (see Goldberg and Harralson [1], Dreyfus [2] and Hart et al. [3]) that is based on the static A * algorithm and is faster than the Dijkstra's algorithm using preprocessing.Thus, we have found the first algorithm for the time-dependent shortest path problem with time windows that speeds up the calculation using preprocessing and we have observed that it is several time faster than the generalized Dijkstra's algorithm.Finally, the conclusion is given in Section 4.

The Algorithm of the Time-Dependent Shortest Path Problem with Time Windows
We start from the classical and well-known Dijkstra's algorithm.For each edge ( )

( )
p v denote the precedent node of a node ν of the shortest s, ν-path found so far.The Dijkstra's algorithm maintains for each node ν a status ( ) v ∈ {"unlabeled", "labeled", "finished"} and a distance label ( ) g v .At the beginning, ( ) g s is the set to 0 and all status ( ) v is initialized to "unlabeled" except that s is "labeled".Then it repeatedly find a "labeled" node ν with the smallest ( ) then it tries to relax all non "finished" neighbors w of ν, i.e., if status ( ) w = "unlabeled" then the set it to "labeled" and let ( ) ( ) ( ) , ( ) , ( ) after all these have done, set status ( ) v to "finished" and continue.See Table 1 for the pseudo-code.The our algorithm of the A * algorithm given in (Table 2) follows the same fashion except that it employs an estimator ( ) a b and chooses the active node by the smallest ( ) ( ) ∈ can be used to reduce the search space (i.e. the set of nodes that have to be explored before the solution is found) of the shortest path queries effectively.Notice that how to determine ( ) h v is not part of the algorithm.It must be obtained by some other method, and the choice of h determines the correctness and the efficiency of the A * algorithm (a good lower-bound on the , v d -distance is preferred).Clearly the Dijkstra's algorithm is a special case with 0 h = .Remark: The Dijkstra's algorithm is a special case of 0 h = .For general h , however, the correctness is not guaranteed.Now we are ready to describe our generalized A * algorithm.It generalizes ( )  3) FOR all edges ( ) status ( ) : w = "labeled" with the time window (i.e., [ ] , , , , ( ) :  2) Let v be a "labeled" with time window [ ] , , , and the smallest ( ) ( ) In the case that there are multiple candidates, choose one with the smallest ( ) 3) FOR all edges ( ) status ( ) : w = "labeled", ( ) ( ) ( ) ( ) ( ) , ( ) : 11) OUTPUT ( ) The triangle condition (2.2) (see Figure 1) is a natural generalization from the classical A * algorithm whereas the FIFO condition is only available in the time-dependent and time windows case.The generalized Dijkstra's algorithm is nothing but the simplest case with 0 h = , and the generalization of Kanoulas et al. [16], on the other hand, simply uses a constant function ( ) ( ) ∈ is the service and leaving time to a node v V ∈ thus, it also a simple special-case of our algorithm.
Roughly speaking, it says the supposed transit-time ( ) By the above conditions (2.1), (2.2) and (2.3).We show by the induction that, every active node ν must get the optimal distance label (the induction variable is the number of nodes in the shortest path), i.e., the earliest arrival time at node ν for leaving s at time 0 t .
Let ν be an active node satisfies the time windows [ ]   (notice 0 σ ≥ ).By applying the above conditions (2.1), (2.2) and (2.3) to the , w v -path with time windows on p with ( ) we have That is equivalent to Then, since ν is the active node with the time windows [ ] On the other hand, by the FIFO condition and ( ) ( ) (the optimality of g * ), we have Therefore we get the next fact by combining (2.6) and (2.7), we get This means the equalities hold, hence .
Then by our choice of the active node, ( ) ( ) The analogously to the static version, an h with ( ) , 0 ∈ is a lower bound on the shortest transit-time from ν to d with leaving time ( ) g v (by Theorem 2.1).Moreover, it is not difficult to show that with an h satisfying ( ) , 0 h d t = and 0 h ≥ , the search space (the set of active nodes) of the generalized A * algorithm is no longer than that the generalized Dijkstra's algorithm.Using this observation, we will give our algorithm in the next section that is practically faster than the generalized Dijkstra's algorithm.

Application Instance
The time complexity of the generalized Dijkstra's algorithm is ( )  [15]), where , , m n α are the number of edges, the number of nodes, and the time complexity to calculate ( ) e c t , respectively.While we cannot improve this theoretical bound, let us give a practically faster algorithm that is based on our A * algorithm and generalizes the static landmark-based ALT algorithm (Goldberg and Harrelsin [1], Dreyfus [2], and Hart et al. [3]).
The ALT algorithm is such as an algorithm that is supposed to answer the shortest-path queries for a known graph.This means we can preprocess the graph beforehand and use it to answer a query faster than a normal calculation by the Dijkstra's algorithm.Of course there is a trivial method of saving solutions for all possible queries and answers a query in ( ) time, but the 2 n order (for the static case) is big (if not impossible) for large graphs, usually a road network is spares (i.e., m kn ≤ for some small k ) and has several millions of nodes.So researchers are seeking efficient algorithm that uses

( )
O n storage, see Wagnar and Willhalm [17] for a review.While this is an extremely hot topic for the static problem of these several years, for the time-dependent case, as far as we know, there was no proposal before our work.Now let us describe the detail of our generalized ALT algorithm.Let ( ) (by the triangle inequality due to the optimality of τ * ).Moreover, we can show that z h satisfies the FIFO condition, the triangle condition and the time windows condition at the same time, too.The proof is not trivial nor difficult, but due to the page limit, we omit it in this work.We note it is important to choose t to be the maximum.
We still have to show how to calculate t , which usually is difficult if there is no explicit expression for ( ) ≤ with periodic piecewise-linear transit-time functions (with 9 samples a day), we have noticed that it ran at an average of about 4 times faster than the generalized Dijkstra's algorithm with 16 landmarks and 2 time samplings.
A comparison example of the search space between the generalized Dijkstra's algorithm and the generalized ALT algorithm for the time dependent shortest path problem time windows and our ALT algorithm for an instance with the number of nodes are 321,270 and the number of edges are 800,172.The number of landmarks is 16 and the number of time samplings is 2. The search space of the ALT algorithm is 0.055 smaller and the running time is 7.4 times faster.

Conclusion
In this paper, we present a new algorithm framework of A * algorithm for the time-dependent shortest path problem with time windows.By constructing some appropriate estimator h, it is possible to get an algorithm that is faster than a normal generalized Dijkstra's algorithm.As an example, we have generalized the landmark based ALT algorithm, which we believe is the first algorithm that uses preprocessing to speed up the calculation of time-dependent shortest paths problem with time windows.Our experimental result shows that it is several times faster than a normal generalized Dijkstra's algorithm for large road networks.
t T ∈ is non-negative of the service and leaving time of the node.A source node s, a destination node d and a departure time t 0 , the timedependent shortest path problem with time windows asks to find an s, d-path that leaves a source node s at a departure time t 0 ; and minimizes the total arrival time at a destination node d.This formulation generalizes the classical shortest path problem in which c e are constants.Our algorithm of the time windows gave the generalization of the ALT algorithm and A * algorithm for the classical problem according to Goldberg and Harrelson [1], Dreyfus [2] and Hart et al. [3].
. The service and leaving time to node v V ∈ is t T the Dijkstra's algorithm tries to find a shortest , s d -path in greedy manner.Let

1 ) 2 )
status ( ) : s = "labeled", ( ) : 0 g s = , status ( ) : v = "unlabeled" for all v s ≠ Let v be a "labeled" node with the time window (i.e., [ ] the active node).IF v d =GOTO 11) . the supposed transit-time of the , v d -path v w d → → .Notice that, transit-time from w to d by leaving w at time t T ∈ is the service and leav- ing time of this node.If v s = , we are done.Otherwise, let p be a simple optimal , s v -path (it exists) and w be the first node on p such that status ( ) w ≠ "finished".Clearly w must exist and w s ≠ (it can be ν) see Figure 2.

Figure 1 .
Figure 1.The triangle condition with time windows for the function h.

Figure 2 .
Figure 2.An optimal s, v-path with time windows is being considered.s, u: finished nodes; w: the first non-finished node; v: the active node.
where V is a set of nodes, E is a set of edges, ∈ is non-negative of the service and leaving time of the node.A source node s V , and a departure time o t .The time-dependent shortest path problem with time windows asks to find an s, d-path that leaves a source node s at time o t and minimizes the total arrival time at a destination node d which satisfies the set of all constraints (see El-Sherbeny

Table 1 .
is the time windows of a node ν where v , a destination node d and a departure time 0 t at a source node s of the time-dependent shortest path problem with time windows such that the FIFO properly is satisfies and d is reachable from s , the generalized of A * algorithm in Table3finds an optimal solution if h satisfies the three conditions: Pseudo-code of the Dijkstra's algorithm for the static shortest path problem time windows.
≤ ≤ , t T ∈ is the service and leaving time to node ν, a source node s

Table 2 .
Pseudo-code of the A * algorithm for the static problem time windows.

Table 3 .
Pseudo-code of A * algorithm for the time-dependent shortest path problem with time windows.
d and the , for all nodes v and all t ( z is called a landmark).Also, suppose we can calculate a t (if exists) that In other words, t is the latest leaving time in order to get ν before t (from z ).Define h by: Again, we can show the function z h defined by (3.2) with the above t satisfies the FIFO conditions, the triangle condition, the time windows condition, and Moreover, we can employ more than one land marks to get a better estimation (notice the maximum of all z h s works).Applying this generalized ALT algorithm to a number of US road networks (obtained from the web site of the 9 th DIMACS implementation challenge http://www.dis.uniromal.it/~challenge9/,where 320, 000 z h ≥ .