Vehicle Route Planning Using Dynamically Weighted
Vehicle Route Planning Using Dynamically Weighted
Abstract—Traditional vehicle routing algorithms do not con- Municipalities, the world over, keep making heavy invest-
sider the changing nature of traffic. While implementations of ments in building new roads, expanding the existing ones
Dijkstra’s algorithm with varying weights exist, the weights and repairing the damaged parts, although controversies on
are often changed after the outcome of algorithm is executed,
which may not always result in the optimal route being chosen. whether broader and a greater number of roads alleviate
Hence, this paper proposes a novel vehicle routing algorithm congestion persist [4]. Traffic congestion also causes increased
that improves upon Dijkstra’s algorithm using a traffic pre- vehicular emissions of harmful greenhouse gases such as
diction model based on the traffic flow in a road network. CO2 , CO, SO2 , NO2 which results in a significant rise of air
Here, Dijkstra’s algorithm is adapted to be dynamic and time pollutant exposures of commuters and urban populations due
dependent using traffic flow theory principles during the planning
stage itself. The model provides predicted traffic parameters and to the increased time spent in traffic [5]. Continued exposure to
travel time across each edge of the road network at every time such harmful emissions can lead to severe respiratory problems
instant, leading to better routing results. The dynamic algorithm and health risks [6] [7].
proposed here predicts changes in traffic conditions at each time One way to reduce traffic congestion is to enable traffic flow
step of planning to give the optimal forward-looking path. The optimisation. This would provide insights into more efficient
proposed algorithm is verified by comparing it with conventional
Dijkstra’s algorithm on a graph with randomly simulated traffic, routing in conjunction to smart roads networks. Better routing
and is shown to predict the optimal route better with continuously would eventually lead to better utilisation of all the roads in
changing traffic. the network, supporting optimal traffic flow and enabling a
reduction in emission.
Index Terms—Dijkstra’s algorithm, vehicle routing, traffic flow Bellman-Ford [8], A* [9], Floyd Warshall [10] and Dijk-
theory, traffic prediction model stra’s [11] are some of the common vehicle routing algorithms.
I. I NTRODUCTION One of the main advantages of Dijkstra’s algorithm is its
considerably low complexity, especially when dealing with a
Traffic congestion is a significant challenge in modern sparse road network. There are quite a few efforts studying
society, characterised by slower speeds, longer trip times, and the improvement of Dijkstra’s algorithm and its practical
increased vehicle queueing [1]. In a recent report by TomTom, applications. One such effort attempted to solve the Optimal
a leading Global Positioning System (GPS) company, the issue Route Planning in a Parking Lot based on the Dijkstra’s
of traffic congestion and the resultant loss of time, energy algorithm [12]. The authors combined an impedance function
and money of the commuters in major metro cities around model with the traditional Dijkstra’s algorithm to obtain the
the globe is highlighted and the time lost is estimated to be dynamic time of route. A balance function between distance
greater than three-fourths of the actual travel time [2]. Traffic and time was adopted as the weight matrix. In another paper,
congestion costed a total of $160 billion in the United States modelling of the optimal route-finding problem was carried out
of America (USA) due to 6.9 billion extra hours travelled and using a combination graph with three cost components namely
3.1 billion additional gallons of fuel purchased in 2014. As per travel distance, toll costs and road surface conditions [13]. An
the INRIX Roadway Analytics in 2017, the most congested optimal route was then calculated based on a combination of
25 cities of the U.S.A. are estimated to cost the drivers $480 these weights fed to the Dijkstra’s in the form of an adjacency
billion, over the next 10 years, owing to lost time, wasted fuel, matrix. In a related study, the authors optimized Dijkstra’s
and carbon emitted during congestion. In 2018, the total cost Algorithm from a control network scale and proposed a
of lost productivity due to congestion was found to be $87 shortest path algorithm based on the ellipse, which limits the
billion in the U.S.A., highlighting the massive effect of traffic search node collection in a certain area and greatly narrows
congestion on the global economy [3]. the search scale [14].
1 Vehicle Engineering Department, Jaguar Land Rover India Limited, Although the above studies tried to improve the efficiency of
Bengaluru 560 048, India
a Contributed equally
the Dijkstra algorithm, none of them actually solved the vehi-
b Present address: Department of Engineering, University of Cambridge, cle routing problem dynamically. The traffic density, average
Cambridge CB2 1PZ, UK speed on a patch of road, travel time and traffic flow keep
* Corresponding author (e-mail: [email protected]) changing dynamically, i.e., at nearly every instant. There is
need for a forward-looking traffic model that can predict the total weight of the shortest path to it from source, if a smaller
various traffic parameters in a road network at future time- distance is found in the iterative process. In this manner, the
steps and feed those in the form of adjacency matrices to shortest path from the source node to every other node in a
the routing algorithm. The routing algorithm itself needs to static graph can be found. Considering the graph shown in
be modified beyond the conventional Dijkstra’s algorithm, so the Figure 3 as an example, where the source and destination
that it can work with dynamic inputs and provide an optimal nodes are enumerated as 0 and 9 respectively. The highlighted
route calculated by taking into consideration the future traffic path, which has been arrived at by visiting neighbouring nodes
conditions in the road network. and iteratively updating their values, is the least weighted route
In this paper, traffic flow theory is used for developing a between the two nodes.
new routing algorithm based on the traffic model of the road
network. Consequently, Dijkstra’s algorithm is used here over
the A* algorithm, as it traverses through all the nodes of
the network. Fundamental diagrams from traffic flow theory
provide a good relation between traffic flow rate, traffic density
and average speed, that helps model traffic well. This paper
also uses the traffic flow conservation law to understand traffic
flow at junctions and a Gaussian probabilistic modelling for
external traffic inflows into the road network. Here, travel
times are chosen as the weights in the adjacency matrix
over which optimisation is carried out, instead of a common
metric like distance. This is because travel time is an all-
Fig. 3. Shortest Path on Weighted Graph using Dijkstra’s Algorithm
encompassing factor, calculation of which takes into consid-
eration all the traffic parameters in the road journey.
The rest of the paper is structured as follows. Section For the problem statement this paper attempts to solve,
II follows with the methodology used to modify Dijkstra’s the weights of the edges are dynamic and can change with
algorithm using traffic prediction. Section III discusses the time, in which is representative of a real traffic network.
implementation with the steps involved in generating and Here, the weight of an edge signifies travel time conforming
analysing the traffic. Section IV compares the proposed al- to traffic flow theory. The inputs to the proposed algorithm
gorithm with Dijkstra’s algorithm for various routes obtained are a graph,the source node number and the destination node
from real datasets, with concluding remarks in Section V. number. The graph is in the form of a dictionary with the
timestamps as keys and an adjacency matrix as the value at
II. M ETHODOLOGY
each key. The matrix is of Nth , where N is the total number
A. Dijkstra’s Algorithm of nodes in the graph, and the value of adj[i,j] gives the travel
Dijkstra’s algorithm is an algorithm used for finding the time between nodes i and j at the time instant t as given by the
path with the minimum sum of weights between two nodes in key. This matrix is obtained as an output from the prediction
a graph. A road network can be represented as a graph. Here, model, which is outlined further in the paper.
a ‘node’ represents a junction which connects two or more The algorithm is an iterative procedure that repeatedly
paths, and an ‘edge’ represents a road connecting the ‘nodes’ attempts to improve an initial approximation of the values of
[11]. Figures 1 and 2 below depict how a graph containing time[v]. The initial approximation is simply time[0] = 0 (as the
nodes and edges is generated from an underlying road network source node is indexed as 0) and time[v] = ∞ for v = 1, 2, . . . ,
obtained from Google Maps. (n-1). In each iteration, a new node is processed, and its time[v]
value is used to update the time[v] value of its immediate
successors if the time to reach them is lower through the parent
node v. Compared to standard Dijkstra’s algorithm, the visited
array is removed because this is a dynamic weights problem.
So, there might arise a condition where at a later time instant,
the weight of an edge falls, requiring the weights of all the
connected nodes to be updated, even if they were previously
visited. To keep a track of the path taken to reach a particular
Fig. 1. Actual Road Network Fig. 2. Derived Graph node minimally, there is a parent array, which is updated with
the new parent node if the path to reach the successor is lower
1) Modified Dynamic Weight Dijkstra’s Algorithm: Con- through the new node. When the destination node is reached,
ventional Dijkstra’s algorithm helps find the shortest path its neighbours are not pushed back into the queue since we
between a source node and a destination node in a static, will not leave the destination after reaching it, thus saving
weighted graph. The algorithm entails visiting each neighbour- computation cycles. The details of this are shown in Algorithm
ing node and updating its value, which is a measure of the 1.
Algorithm 1 Pseudocode for Modified Dynamic Dijkstra of the road per unit distance, and u(i,j) is the space mean speed
Input: Graph(dict), source node, destination node defined as the spatial average speed of all vehicles.
Initialisation : The conservation law states that the measurable parameters
1: for each node v do of an isolated physical system remain constant. In this system,
2: time[v] ← ∞ the conserved parameter is the number of vehicles on a given
3: parent[v] ← NULL stretch of road. Since the number of vehicles on a given stretch
4: end for of road between [x, x’] is constant, for there to be a change
5: time[source] ← 0 in the traffic density ρ, there must be an inflow or an outflow,
6: push(0, source) → Q such that the traffic flow is conserved, as illustrated in Figure
LOOP Process 4.
7: while Q not empty do
8: u ← node in Q with min time[u]
9: remove u from Q
10: for each neighbour v of u do
11: alt ← time[u] + TRAVELTIME[u, v] at time[u]
12: if alt < time[v] then
13: time[v] ← alt
14: parent[v] ← u
15: if v is not destination then
16: push(alt, v) → Q
Fig. 4. Conservation law illustration
17: end if
18: end if
19: end for In 1955, Lighthill, Whitman and Richards proposed a
20: end while
macroscopic traffic flow model known as the LWR model [15]
21: return time[], parent[]
[16]. According to this model, if a vehicle can be assumed to
be a molecule, then the traffic in the lane can be presented as
an incompressible fluid which cannot be compressed beyond a
certain density. Based on the conservation laws and the relation
In this case, Dijkstra’s algorithm would use the travel
between the traffic variables, traffic flow is represented by the
time[u, v] at time t = 0 which would give an initial path as well
model as follows
as a travel time. However, the traffic parameters would have
changed by the time a node u is reached. Hence, the travel ∂k ∂k
time at that time instant, which is the output of the prediction + Q0 (k) · = f (), (2)
∂t ∂x
model considering updated traffic parameters, is considered in where, k is the density, Q is the flux or the flow rate, and
this implementation. f () represents the source term which represents the inflow and
B. Prediction model outflow.
This methodology involves the representation of the system
1) Traffic Flow Theory: Traffic flow theory is used to in a state space form. The associated model then uses the
understand various parameters that help define the flow of conservation law and dynamic speed formula with a linear
traffic. The change in traffic parameters of a particular edge traffic stream model to study the traffic flow. The density and
over time is attributed to the flow of traffic in and out of the aggregate space mean speed are considered to be the state
corresponding lane. Each lane is represented as an edge and variables of interest in this model. The relative difference in
its weight is defined as the time taken to traverse the lane, the entry and exit flows is taken as the input variable and
which is directly dependent on the traffic in that lane and a the space mean speed is the output variable. The classified
few other factors as explained below. volume per minute and spot speeds are extracted from the
The travel time of the vehicle through a particular lane data collected, and the traffic variables, flow and space mean
depends on the length of the lane and the average speed, which speed, are calculated. The actual densities are calculated using
in turn depends on the traffic in that lane. Traffic flow theory an input-output analysis.
gives a relationship between the traffic flow rate q, density k Hence, the traffic flow at the next timestep is determined
and speed u given by by considering the present inflows and outflows.
D. Prediction Component
The task of the prediction component is broken down as
predicting the future states of external and internal traffic.
Algorithm 2 Determine Speed of Vehicles Algorithm 4 Algorithm for Selecting Next Edge
Input: Traffic density Input: node X
1: K ← dictionary with edge id as key and traffic situation
Initialisation :
1: vret ← free-flow speed of the edge, where the vehicle is
as value
2: sum ← 0
present
3: for every edge E directly connected to node X do
2: curr tr dens ← traffic density × vehicle thickness
4: tr ← get value of traffic in that edge
curr tr dens 5: if node X ≡ start node of edge E then
3: curr tr dens ← × edge thickness 6: tr ← transformation function(E.forward traffic)
edge length
7: else
4: if curr tr dens < β & curr tr dens ≤ α then 8: tr ← transformation function(E.backward traffic)
5: vret ← (edge.free flow speed - edge.jam speed) × (1 9: end if
– curr tr dens) + edge.jam speed 10: K[E.id] = tr
6: else if curr tr dens > β then 11: sum += K[E.id]
7: vret ← jam speed of edge is assigned 12: end for{Normalising values in K}
8: end if 13: for every edge E id in K do
9: return vret {speed value for vehicle returned} 14: K[E.id]/ = sum
10: return time[ ], parent[ ] 15: end for{Using these values assigned for every directly
connected edge in dictionary K as probabilities}
Step 2: Using the traffic densities, the speed of every vehicle 16: choice = random.choices(node connections, weights=k)
is calculated using the function shown in Algorithm 2. The {this returns chosen edge id}
average speed is then calculated by taking the mean of the 17: return choice
speed of all vehicles along that particular edge.
IV. EXPERIMENTATION, RESULTS AND
OBSERVATIONS
In the dataset [19] used for testing, the road networks of five
major cities of the globe are expressed in the form of a graph.
The junctions are exhibited as nodes, and the roads connecting
them as edges. The rationale behind using this dataset for road
networks is to calibrate and evaluate the model on data which Fig. 7. Road Network at t = 6 Fig. 8. Road Network at t = 8
mimics real life road networks and traffic conditions as much
as possible. As this dataset is designed to replicate actual road
networks, it serves as an ideal data feed for the model.
Fig. 13. Mean time difference between the proposed algoritm and Dijkstra’s
Fig. 12. Shortest path using modified dynamic Dijkstra algorithm with varying values of α and β
N
VI. ACKNOWLEDGEMENT
X Ti − τi
λ= (4) The authors would like to thank Mr. Piyush Laddha (Soft-
i=1
N ware Product Manager, Jaguar Land Rover India) and Mr.
where, Terence Soares (Software Architect, Jaguar Land Rover India)
for their continued support, guidance and encouragement
λ = Average difference throughout the project. The authors also thank Ms. Isabella
τi = Travel time by proposed algorithm for ith test case Panela (Senior Manager, Jaguar Land Rover Ireland), Mr.
Ti = Travel time by Dijkstra’s algorithm for ith test case Sravan Kallam (Senior Engineer ADAS, Jaguar Land Rover
N = Total number of test cases Ireland) and Dr. Damien Dooley (former Senior Engineer
The average travel time difference is recorded to be 387 ADAS, Jaguar Land Rover Ireland) for reviewing the work
seconds, i.e., 6.45 minutes. Model performance was also anal- and providing valuable feedback for the team to work on. This
ysed for different values of α and β, and the results achieved work was supported by Jaguar Land Rover.
are shown in Figure 15. This depicts the significant deduction R EFERENCES
in travel time achieved when using the proposed routing
[1] R. W. Caves, Encyclopedia of the City. Routledge, 2004.
algorithm with traffic prediction as compared to conventional [2] S. Çolak, A. Lima, and M. C. González, “Understanding congested travel
Dijkstra’s algorithm. in urban areas,” Nature communications, vol. 7, no. 1, pp. 1–8, 2016.
[3] T. Afrin and N. Yodo, “A survey of road traffic congestion measures
towards a sustainable and resilient transportation system,” Sustainability,
vol. 12, no. 11, p. 4660, 2020.
[4] D. Braess, A. Nagurney, and T. Wakolbinger, “On a paradox of traffic
planning,” Transportation science, vol. 39, no. 4, pp. 446–450, 2005.
[5] H. Xue, S. Jiang, and B. Liang, “A study on the model of traffic flow
and vehicle exhaust emission,” Mathematical Problems in Engineering,
vol. 2013, 2013.
[6] K. Zhang and S. Batterman, “Air pollution and health risks due to vehicle
traffic,” Science of the total Environment, vol. 450, pp. 307–316, 2013.
[7] M. Zuurbier, G. Hoek, M. Oldenwening, K. Meliefste, P. van den Hazel,
and B. Brunekreef, “Respiratory effects of commuters’ exposure to air
pollution in traffic,” Epidemiology, pp. 219–227, 2011.
[8] R. Bellman, “On a routing problem,” Quarterly of applied mathematics,
vol. 16, no. 1, pp. 87–90, 1958.
[9] P. E. Hart, N. J. Nilsson, and B. Raphael, “A formal basis for the heuristic
determination of minimum cost paths,” IEEE transactions on Systems
Science and Cybernetics, vol. 4, no. 2, pp. 100–107, 1968.
[10] R. W. Floyd, “Algorithm 97: shortest path,” Communications of the
ACM, vol. 5, no. 6, p. 345, 1962.
[11] E. W. Dijkstra et al., “A note on two problems in connexion with graphs,”
Numerische mathematik, vol. 1, no. 1, pp. 269–271, 1959.
[12] G. Xiaoxue et al., “Optimal route planning of parking lot based on
dijkstra algorithm,” in 2017 International Conference on Robots &
Intelligent System (ICRIS), pp. 221–224, IEEE, 2017.
[13] A. R. Soltani, H. Tawfik, J. Y. Goulermas, and T. Fernando, “Path
planning in construction sites: performance evaluation of the Dijkstra,
A?, and GA search algorithms,” Advanced engineering informatics,
vol. 16, no. 4, pp. 291–303, 2002.
[14] H. Wei, S. Zhang, and X. He, “Shortest path algorithm in dynamic
restricted area based on unidirectional road network model,” Sensors,
vol. 21, no. 1, p. 203, 2020.
[15] M. J. Lighthill and G. B. Whitham, “On kinematic waves ii. a theory of
traffic flow on long crowded roads,” Proceedings of the Royal Society
of London. Series A. Mathematical and Physical Sciences, vol. 229,
no. 1178, pp. 317–345, 1955.
[16] A. Ali, L. S. Andallah, et al., “Inflow outflow effect and shock wave
analysis in a traffic flow simulation,” American Journal of Computa-
tional Mathematics, vol. 6, no. 02, p. 55, 2016.
[17] J. Zhao and S. Sun, “High-order gaussian process dynamical models for
traffic flow prediction,” IEEE Transactions on Intelligent Transportation
Systems, vol. 17, no. 7, pp. 2014–2019, 2016.
[18] L. Lin, J. Li, F. Chen, J. Ye, and J. Huai, “Road traffic speed prediction:
a probabilistic model fusing multi-source data,” IEEE Transactions on
Knowledge and Data Engineering, vol. 30, no. 7, pp. 1310–1323, 2017.
[19] Department of Computer Science, The University of Utah, “Real datasets
for spatial databases: Road networks and points of interest,” 2005. data
retrieved from The University of Utah.