Applied Mathematics
Vol.05 No.17(2014), Article ID:50798,6 pages
10.4236/am.2014.517264
The Algorithm of the Time-Dependent Shortest Path Problem with Time Windows
Nasser A. El-Sherbeny1,2
1Mathematics Department, Faculty of Science, Al-Azhar University, Cairo, Egypt
2Mathematics Department, Faculty of Applied Medical Science, Taif University, Turabah, KSA
Email: nasserelsherbeny@yahoo.com
Copyright © 2014 by author and Scientific Research Publishing Inc.
This work is licensed under the Creative Commons Attribution International License (CC BY).
http://creativecommons.org/licenses/by/4.0/



Received 15 August 2014; revised 2 September 2014; accepted 9 September 2014
ABSTRACT
In this paper, we present a new algorithm of the time-dependent shortest path problem with time windows. Give a directed graph
, where V is a set of nodes, E is a set of edges with a non-negative transit-time function
. For each node
, a time window
within which the node may be visited and
,
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 time- dependent 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] .
Keywords:
Shortest Path, Time-Dependent Shortest Path, ALT Algorithm, A* Algorithm, Time Windows

1. 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
, where V is a set of nodes, E is a set of edges,
is a non-negative transit-time function. For each node
, a time window
within which the node may be visited and
,
is non-negative of the service and leaving time of the node. A source node
with time window
, a destination node
with time window
, and a departure time







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 



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 
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.
2. 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


























The our algorithm of the A* algorithm given in (Table 2) follows the same fashion except that it employs an estimator 








Remark: The Dijkstra’s algorithm is a special case of

Now we are ready to describe our generalized A* algorithm. It generalizes 






Definition 2.1. Given a directed graph





then for all edges 
In a directed graph










· For all vertices 


· For all edges 


· For all vertices 


Table 1. Pseudo-code of the Dijkstra’s algorithm for the static shortest path problem time windows.
Table 2. Pseudo-code of the 
Table 3. Pseudo-code of 
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





Roughly speaking, it says the supposed transit-time 








Theorem 2.1. Let 



the service and leaving time at node





Proof. 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 

Let ν be an active node satisfies the time windows 










Figure 1. The triangle condition with time windows for the function h.
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.
Let 













That is equivalent to

Then, since ν is the active node with the time windows 


On the other hand, by the FIFO condition and 


Therefore we get the next fact by combining (2.6) and (2.7), we get

This means the equalities hold, hence 


Remark: The analogously to the static version, an h with 








3. Application Instance
The time complexity of the generalized Dijkstra’s algorithm is 



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 




Now let us describe the detail of our generalized ALT algorithm. Let 














In other words, 





It is clear that 






We still have to show how to calculate






Again, we can show the function 






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.
4. 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.
Acknowledgements
The author would like to thank an anonymous referee for some useful comments.
References
- Goldberg, A. and Harrelson, C. (2005) Computing the Shortest Path: A* Search Meets Graph Theory. http://research.microsoft.com/pubs/154937/soda05.pdf
- Dreyfus, S. (1969) An Appraisal of Some Shortest-Path Algorithms. Operations Research, 17, 395-412. http://dx.doi.org/10.1287/opre.17.3.395
- Hart, P., Nilsson, N. and Raphael, B. (1968) A Formal Basis for the Heuristic Determination of Minimum Cost Paths. IEEE Transactions Systems Science and Cybernetics, 4, 100-107. http://dx.doi.org/10.1109/TSSC.1968.300136
- Ahuja, R., Magnanti, T. and Orlin, J. (1993) Network Flows: Theory, Algorithms, and Applications. Prentice-Hall, Upper Saddle River.
- El-Sherbeny, N. (2001) Resolution of a Vehicle Routing Problem with Multiobjective Simulated Annealing Method. Ph.D. Dissertation of Faculty of Science, Mons University, Mons.
- El-Sherbeny, N. and Tuyttens, D. (2001) Optimization Multicriteria of Routing Problem. Troisieme Journee de Travail sur la Programming Mathematique Multi-Objective, Faculte Polytechnique de Mons, Mons.
- Tuyttens, D., Teghem, J. and El-Sherbeny, N. (2004) A Particular Multiobjective Vehicle Routing Problem Solved by Simulated Annealing. Lecture Notes in Economics and Mathematical Systems, 535, 133-152. http://dx.doi.org/10.1007/978-3-642-17144-4_5
- El-Sherbeny, N. (2011) Imprecision and Flexible Constraints in Fuzzy Vehicle Routing Problem. American Journal of Mathematical and Management Sciences, 31, 55-71. http://dx.doi.org/10.1080/01966324.2011.10737800
- Cook, K. and Halsey, E. (1966) The Shortest Route through a Network with Time-Dependent Intermodal Transit. Journal of Mathematical Analysis and Applications, 14, 493-498. http://dx.doi.org/10.1016/0022-247X(66)90009-6
- Halpern, H. (1977) Shortest Route with Time Dependent Length of Edges and Limited Delay Possibilities in Nodes. Operations Research, 21, 117-124.
- Kaufman, D. and Smith, R. (1993) Fastest Paths in Time-Dependent Networks for Intelligent Vehicle-Highway Systems Application. Journal of Intelligent Transportation Systems, 1, 1-11.
- Orda, A. and Rom, R. (1990) Shortest-Path and Minimum-Delay Algorithms in Networks with Time-Dependent Edge- Length. Journal of the ACM, 37, 607-625. http://dx.doi.org/10.1145/79147.214078
- Sherali, H., Ozbay, K. and Subramanian, S. (1998) The Time-Dependent Shortest Pair of Disjoint Paths Problem: Complexity, Models, and Algorithms. Networks, 31, 259-272. http://dx.doi.org/10.1002/(SICI)1097-0037(199807)31:4<259::AID-NET6>3.0.CO;2-C
- Dean, B. (1999) Continuous-Time Dynamic Shortest Path Algorithms. Master’s Thesis, MIT.
- Ding, B., Xu, J. and Qin, L. (2008) Finding Time-Dependent Shortest Paths over Large Graphs. Proceedings of the 11th International Conference on Extending Database Technology, 25-30 March 2008, 205-216.
- Kanoulse, E., Du, Y., Xia, T. and Zhang, D. (2006) Finding Fastest Paths on a Road Network with Speed Patterns. Proceedings of the 22nd International Conference on Data Engineering, Atlanta, 3-7 April 2006, 10-19.
- Wagner, D. and Willhalm, T. (2007) Speed-Up Techniques for Shortest-Path Computations. Lecture Notes in Computer Science, 4393, 23-36. http://dx.doi.org/10.1007/978-3-540-70918-3_3





