improvement of a shortest routes algorithm

26
Improvement of a Shortest Routes Algorithm A Project Submitted In Partial Fulfilment of the Requirements for the Degree of Bachelor of Technology Supervisor: Submitted By: Dr. U.C. Jaiswal Pranav Bharti (1104210034) (Associate Professor) Ankur Yadav (1104210010) Devendra Kumar (1104210019) Department of Computer Science and Engineering

Upload: -

Post on 26-Jul-2015

17 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Improvement Of A Shortest Routes Algorithm

Improvement of a Shortest Routes

Algorithm

A Project Submitted

In Partial Fulfilment of the Requirements

for the Degree of Bachelor of Technology

Supervisor: Submitted By:

Dr. U.C. Jaiswal Pranav Bharti (1104210034) (Associate Professor) Ankur Yadav (1104210010)

Devendra Kumar (1104210019)

Department of Computer Science and EngineeringMadan Mohan Malaviya University of Technology,

Gorakhpur (273010)

(2014-15)

Page 2: Improvement Of A Shortest Routes Algorithm

Candidate’s Declaration

I declare that this written submission represents my work and ideas in my own words and where others' ideas or words have been included, I have adequately cited and referenced the original sources. I also declare that I have adhered to all principles of academic honesty and integrity and have not misrepresented or fabricated or falsified any idea/data/fact/source in my submission. I understand that any violation of the above will be cause for disciplinary action by the University and can also evoke penal action from the sources which have thus not been properly cited or from whom proper permission has not been taken when needed.

Pranav Bharti(1104210034)

Ankur Yadav(1104210010)

Devendra Kumar(1104210019)

Compute science and Engineering

Date: __________

Page 3: Improvement Of A Shortest Routes Algorithm

CERTIFICATE

Certified that Devendra Kumar, Pranav Bharti, Ankur Yadav have carried out the research work presented in this thesis entitled “Improvement Of Shortest Routes Algorithm” for the award of Bachelor of Technology from Madan Mohan Malaviya University of Technology, Gorakhpur under my supervision. The thesis embodies result of original work and studies carried out by Students themself and the contents of the thesis do not form the basis for the award of any other degree to the candidate or to anybody else.

_____________

Dr. U.C. Jaiswal

(Associate Professor)

Page 4: Improvement Of A Shortest Routes Algorithm

Computer Science and Engineering

M.M.M.U.T.Gorakhpur

Approval Sheet

This thesis/dissertation/report entitled “Improvement of Shortest Routes Algorithm” by Pranav Bharti, Ankur Yadav, Devendra Kumar is approved for the degree of Bachelor of Technology (Computer Science and Engineering).

Examiner

________________________

________________________

________________________

Supervisor

________________________

Head of Department

__________________________

Dean, Research & Development or

Other Dean/Professor to be nominated

by the Vice Chancellor in his absence

________________________

Page 5: Improvement Of A Shortest Routes Algorithm

Date: ____________

ACKNOWLEDGEMENT

“Best way to predict the future is to schedule it and then create it.”

It has been an exhilarating experience working from scratch to the accomplishment of our project .It has been great learning experience, teaching us to overcome many impediments on our way. The work has taught us the essence of ‘Team Work’ and also has unlocked the doors of Computer Science and Technology by the way of hands-on experience . A sense of achievements now olds our spirits high. Now, we consider it appropriate in the midst of deeply rooted feelings, to extend our regards to all those who have helped us to accomplish our goals. We express our sincere regards and appreciation to all those who have contributed directly or indirectly towards our project.

We profusely thank our Project Guide, Dr. U.C. Jaiswal for effectively motivating us and providing us invaluable support and guidance.

Our heartfelt gratitude is warmly extended toward our H.O.D., Dr. Uday Shankar for providing us with all facilities required.

Our heartfelt gratitude is warmly extended toward our V.C., Dr. Onkar Singh for his inspiration throughout the endeavour.

Project Associates:

Ankur Yadav

Pranav Bharti

Devendra Kumar

Page 6: Improvement Of A Shortest Routes Algorithm

Abstract

Ankur Yadav(1104210010)

Pranav Bharti(1104210034)

Devendra Kumar(1104210019)

BACHELOR OF TECHNOLOGY IN COMPUTER SCIENCE AND ENGINEERING

Improvement of Shortest Routes Algorithm Under Dr. U.C. Jaiswal

To be submitted on May,2015

This article describes an original shortest path algorithm for graphs representing a real road network. We test the influence of a coefficient weighing the evaluated distance used in such short path algorithms. This coefficient has an influence on the performance of the shortest path algorithm which uses the evaluated distance as heuristic. We try to provide a better algorithm using this heuristic and we test its evaluation in various situations. The results presented in this paper are used to write new shortest path algorithms for large real road networks. To conclude, we experiment this algorithm and some alternatives in various situations.

This article present an algorithm used for finding of optimal paths in large scale graphs representing real road networks. The algorithm is based upon traditional graph algorithms, like overdo parameter algorithm, but takes advantage of the specific features of a road network graph and partitions the large graph into smaller

Page 7: Improvement Of A Shortest Routes Algorithm

components, producing a simplified graph that is faster to be searched without using the guarantee of finding an optimal solution.

KEYWORDS: Shortest path search, Route planning, Graph partitioning, Graph algorithm.

Page 8: Improvement Of A Shortest Routes Algorithm

TABLE OF CONTENTS

Page No.

Candidate’s Declaration i

Certificate by Guide ii

Approval Sheet iii

Acknowledgement v

List of Figures vii

List of Tables x

List of Symbols xi

Abstract xiii

Table of Contents xvii

Page 9: Improvement Of A Shortest Routes Algorithm

CHAPTER 1 INTRODUCTION

Shortest path algorithm are often used in CGI and transport applications and represent one of the fundamental of the ITS. Many of those algorithms are somewhat optimized and give satisfying performances . Some of those algorithms use the evaluated distance as heuristic. The evaluated distance heuristic incites computed path to take the direction of the destination. In general, the algorithms use an optimistic evaluation and measure the remaining distance between the end of the path and the targeted destination.

In this article we try to determine what are the consequences of multiplying this evaluated distance by a coefficient to reduce the space search . Various articles have already analysed the influence of these parameters , so we propose to improve a previous algorithm . Firstly , we will describe an algorithm using the simple evaluated distance heuristic . We will then show the influence of using a coefficient weighing the evaluated distance on graphs of different densities . These observation will allow us to establish the positive influences of modifying of the evaluated distances algorithm . Then we propose different alternatives to use the algorithm .

1.1 Classical Algorithm

In this article , we consider a real road network as an oriented graph. The nodes represent crossroads and the oriented arcs represent the roads of a real transport network. We describe a simple algorithm to find the shortest path between two intersections. This first algorithm is not optimal but it will serve as a basis for comparison to observe clearly the influence of the modification of the heuristic in the second algorithm. This algorithm builds and explore the possible paths from the origin A and until they reach the desired destination B:

The origin A and the destination B are taken from any node of the graph. The algorithm builds a list of paths l. Initially, the list consists of a single path constituted of the origin node l = {A}. The

length of this path is zero We use the sum of the evaluated distance d between the end of the current path (x1,y1)

the destination B(x2,y2) and of the current path length as the path sorting heuristic.

d =√(x1-x2)2 + (y1-y2)2

While the destination is not attained, we develop the first element of the stored list l:1. New paths are created by appending the various nodes connected by an arc to the last

node of the first path of the list l.

Page 10: Improvement Of A Shortest Routes Algorithm

2. The first path is replaced by the new paths obtained.3. Their lengths are incremented by the lengths of the appended arcs4. We sort the paths using the heuristic. The first path of the list l is one with the smallest

heuristic evaluation.5. We continue the algorithm until the first path of the list l reaches the destination B. When

the destination B is reached, the first path of the list is the shortest path between the origin A and the destination B.

This is a classic determinist algorithm for this kind of problem. It is not competitive in time but it is sufficient to evaluate the influence of evaluated distance for the shortest path algorithm and gives the optimal solution.

1.2 Evaluation and Influences of the Overdo Parameter

It is possible to improve the performance of the previous algorithm by adapting the heuristic. When we multiply the evaluated distance by a weight (Overdo parameter) the behaviour of algorithm changes. The higher the weight, smaller the size of the explored search tree. Doing this, we don’t always get optimal path, but the algorithm can return a satisfying result quickly. The closer the weighing coefficient is to one, the more likely we are of obtaining the shortest path but the longer the search for the result is likely to be. We will therefore try to find a good compromise between good result and fast resolution.

The optimized value of the weight depends of course on the topology of the graph. But the general behaviour is always the same. There is an interval of values where the coefficient gives a good optimization in terms of path length and search time. This interval depends on the desired origin and destination of the path. It is interesting to see, for different roots the variation of the coefficient in relation to the number of path computed. On the table (Tab 1) we look for the best weight for one hundred different routes. We seek this value in the interval (1,2).It is important to take note of the difference in the search when using the best coefficient or the bad ones: the difference of the performance in terms of computation can vary by a factor up to 300. Another important aspect is the capacity of the algorithm to find the shortest path when the coefficient is adequately chosen. This adequate value generally corresponds to the finding of shortest path.

We can notice that the number of different paths resulting from the search with different parameter values is small. Within large value intervals for the overdo parameter, the shortest path found path remains constant. However the coefficient has an important influence on the number of calculation.

Page 11: Improvement Of A Shortest Routes Algorithm

FIGURE 1: WITH OUT THE OVERDO COEFFICIENT, THE SEARCH TREE IS TOO LARGE AND THE ALGORITHM SPENDS TOO MUCH TIME FINDING THE

SOLUTION(MORE THAN 3000 COMPUTED PATHS)

FIGURE 2: WITH AN ADEQUATE OVERDO COEFFICIEN THE ALGORITHM CAN FIND THE SOLUTION QUICKLY (89 COMPUTED PATH)

Page 12: Improvement Of A Shortest Routes Algorithm

A. Influence on Different Maps

The previous results, we are based on a graph with a high density of nodes. When the density is lower, it may become different to find the only arc which leads to the target in the particular cases where such arcs are part of the graph. In these cases, the overdo coefficient can also improve performance. In such example, a value close to one is catastrophic, it will lead to the exploration of all the arcs in the subgraph on the origin node side of the critical arc before finding the arc enabling to reach destination.

Coef Nbpath Coef Nbpath Coef Nbpath Coef Nbpath

1.05 132 1.3 131 1.52 60 1.89 47

1.08 120 1.33 584 1.55 84 1.92 86

1.11 522 1.36 113 1.59 25 1.94 63

1.15 186 1.38 88 1.6 35 1.97 160

1.19 459 1.41 1144 1.63 68 1.98 120

1.21 291 1.43 83 1.65 136 1.99 291

1.23 290 1.46 255 1.69 479 2 9

1.25 27 1.48 63 1.75 1649 2 35

1.28 421 1.5 3000 1.8 116 2 2069

Table 1

BEST COEFFICIENTS FOUND IN THE INTERVAL 1-2 IN TERMS OF NUMBER OF CALCULATED PATHS AND FINDING THE SHORTEST PATH FOR ONE HUNDRED DIFFERENT ROUTES

(AVERAGE COEFFICIANT-1.54,NBPATHS-432.09)

For a high coefficient (more than 5 for example) the algorithm always leads a solution quickly. It is possible to optimize the value of this parameter by gradually decreasing it down to 2.70.

Under the value 2.70 the search is not sufficient attracted by the destination to find the bridge quickly. However it is possible to find the solution quickly with the adequate coefficient.

Page 13: Improvement Of A Shortest Routes Algorithm

CHAPTER 2 OVERDO PARAMETER ALGORITHM

2.1 Algorithm

In this algorithm, we want to exploit the advantages introduced by the use of coefficient weighing the evaluated distance. The best values are not always the same and depend on the topology of the graph (Tab 1). We propose an algorithm giving an optimized solution in constant time. This solution will not always be the best possible. To achieve this, we limit the number of computed path: maxpath is the maximal size of the list of the paths l. The higher maxpath is, closer we will eventually get to the optimal path. We also define maxcoef, an upper bound for the coefficient value. We start the algorithm with this value for the overdo coefficient and we seek a better value down from this initial value. The best value is generally close to 1.The goal of this algorithm is to find a coefficient giving the shortest path in the shortest possible time. There is not single interesting coefficient, but rather an interval of interesting value for this coefficient.

The algorithm builds a list of paths. Initially, the list consist of a single path constituted of the origin node l= {A}, The length of this path is zero while nbpath does not exceed maxpath :

The algorithm starts with the exploration from the origin A of the route and finishes when the destination B reached:

1. The origin A and destination B are taken from any nodes of the graph.2. We use the sum of the evaluated distance d multiplied by the overdo parameter

and of the current path length as the path shorten heuristic.d=√{(x1-x2)2+(y1-y2)2}*coef

3. While (The destination B is not reached or there is a potential best path with a new coefficient) and maxpath is not exceeded, we develop the first element of the list l

New paths are created by appending the various nodes connected by an arc to the last of the first path of the list l.

The first path is replaced by the new paths obtained. There lengths are incremented by the length of the appended arcs. We sort the paths using the heuristic. The first path of the list l is one with the smallest

new heuristic evaluation. We continue the algorithm until the first path of the list reaches the destination. Once the

destination reached, the first path of the list is the shortest path between the origin and the destination.

Decreasing of the coefficient coef:=coef-delta.

Page 14: Improvement Of A Shortest Routes Algorithm

The decrease of the coefficient has a major influence of the performance of the algorithm. We are sure that the best values are greater than one, for the value one, the algorithm necessarily returns the optimal solution.We are sure that the best values are greater than 1, for the value 1, the algorithm necessarily returns the optimal solution. Note, the list l doesn’t need to be reanalysed. All the paths are kept in the list after decreasing the coefficient coef. By this way, the list is pre-initialised by the precedent results and reduces the space search.

2.2 EVALUATION

The first idea is to decreasing coef with a constant value: delta. This works but it is not the more optimal in time. The overdo coefficients obtained like this often give no interesting results and we lost some time to compute its. And if the value of the overdo is under the critical value, the algorithm will compute for nothing until attains maxpath. So we need to find a method to approach the critical value to find quickly the shortest path. For this, we use two bounds. A down bound and an up bound initialized respectively to 1 and with maxcoef. To adjust the coef, we use this formula: coef =(upbound-downbound)*weight

During the execution of the algorithm, it also possible to evaluate how many computed paths are necessary for each no critical value. So if the coefficient is a critical value, is not necessary to compute until maxpath. The bound evolve after each change of coef: if is a critical value, the down bound is replaced by it else the up bound. The algorithm could be stopped when the bounds are closed. With this method, the shortest path is find quickly and it’s easy to adjust the different parameters to get different results.

FIGURE 3 : Two bounds are used to adjust coef. A threshold is adjusted to compute a necessary number of paths.

Page 15: Improvement Of A Shortest Routes Algorithm

CHAPTER 3 IMPROVEMENT OF ALGORITHM THROUGH GRAPH PARTITIONING

The algorithm could be improved by the relative information of arcs of the network.Real-world road networks are abstractedly represented by weighted directed graphs, whose edges represent roads and whose nodes are equivalent to road junctions. The task of planning a shortest/fastest route from one place on a map to another utilizing roads of the road network is then analogous to finding edges belonging to a shortest path in the affiliated graph from the node representing the origin of the route to the node that represents the destination.

Edges are assigned weights according to conditions of the roads that they representwith respect to the criteria that we are optimizing. To obtain the shortest route, edges’weights are derived from their lengths; for a fastest route, the weights will represent times needed to pass the roads at average speeds that are assigned to them. The weights are always non-negative and the path-finding algorithm tries to minimize the sum of the weights of all edges along the path.

Edges or nodes can also have other attributes that the route planning application needs to regard, such as road conditions. In order for the additional attributes to be transformed to edge weight penalties, they are assumed to be constant along the entire edge. If any of the attributes should change along the edge then the original edge is divided in multiple new edges that are interconnected by newly created nodes (that do not represent real-world road junctions) so that the attribute’s values are constant along each of the new edges. For simplicity, the edge weights are also considered constant in time.

Graphs of road networks are large; they consist of millions of nodes and millions of edges. Such a size renders traditional shortest-path algorithms too slow for a real application. The graphs are also sparse, since the degree of the nodes is typically less than 10 and they are nearly planar. Figure 1 shows a graph of the road network of the Czech Republic. Each edge is visualized as a straight line segment and the nodes, though not explicitly visualized, are placed according to their geographical coordinates.

Page 16: Improvement Of A Shortest Routes Algorithm

FIGURE 4: Graph representing the road network of the Czech republic

3.1 Road Hierarchy

Road networks have a hierarchical structure (in fact, they are purposely built as such). Roads on the highest levels of the hierarchy, for example highways or speedways, inter-connect distant destinations, while roads on the lowest levels have only local importance (they only belong to shortest paths between nodes that lie geographically near these edges). Also, long-distance routes from multiple starting nodes that are geographically adjacent are usually very similar, because apart from low-order roads near the start and destination, the routes utilize the same high ways. It appears reasonable to simplify the detailed road network graph by clustering nodes that are geographically near each other. In the resulting simplified graph, local edges will only be searched near the start or the destination of the route, Further from the endpoints, only transit edges need to be considered.

.

Page 17: Improvement Of A Shortest Routes Algorithm

3.2 Partition based on minimal edge cut

Definition 1 Cluster of nodes of the graph produced by some clustering algorithm will be referred to as component.Definition 2 Inner node of a component is a node, whose all edges lead to nodes in the same component.Definition 3 Outer node (or border node) of a component is a node, whose at least one edge leads to another component.An algorithm described in [2] uses graph partitioning (which can be performed with clustering) to speed up shortest path queries on a network representing means of public transport. However a similar algorithm is also applicable to road networks. Each component Cj (with inner nodes Nij , outer nodes Nej , inner edges Eij that begin and end in the the inner nodes, and connector edges Eej that begin in the outer nodes and end in a different component) is an isolated subgraph of the original graph. We then create a reduced component Rj(Nrj ,Erj), such that nodes of the reduced component, Nrj , are the same as the outer nodes Nej of the original component, Nrj = Nej ; and the set of edges Erj of the reduced component is a union of the connector edges Eej and a set of new edges, containing one edge ex,y for each pair of nodes x, y 2 Nrj , for which there exists a path in the component Cj . The weight of the edge ex,y is set to the sum of weights of all edges along the shortest path from node x to node y in Cj .To take advantage of the structure of the graph G0, the partition can not be random.The partitioning should be performed that the edge cut (the number of connector edges)is minimal. To achieve this, we can use the METIS library.

Figure 2 shows a possible partitioning of the graph on Figure 1. Edges of each component are drawn in the same color. It is evident that the partitioning is not random, since the partitions form compact subgraphs of the original graph.

Page 18: Improvement Of A Shortest Routes Algorithm

FIGURE 2: Partitioning of a road network graph into compact components. Different colors symbolize different components.

3.3 Shortest path search on the reduced graph

The actual shortest path search is then performed in two phases.

In the first phase, the algorithm determines the index k of a component Ck, where the starting node belongs, and the index l of the component Cl containing the end node.Then a simplified graph G1(N1,E1) is constructed, such that N1 = Ụp

j=1NejỤNi

kỤNil , and E1 = EkỤEl Ụp

j=1,j={k,l}Erj. In

other words, the graph consists of reduced variants of all components except for the components where the starting and the end nodes belong, which the graph G1 contains in the original, non-reduced, form.

Note that if k = l, which means that both the starting and the end node belong to the same component, it is not sufficient to search only in the component Ck. The other (reduced) components must also be included in the search, because the component Ck is not guaranteed to entirely contain globally shortest paths between its nodes. The situation is demonstrated on Figure 3.

Shortest path P is found in the simplified graph G1. A list L of component indexes is created so that it contains indexes of all components containing edges of the path P.

Page 19: Improvement Of A Shortest Routes Algorithm

FIGURE 3: Two adjacent components, Ck and Cl. A shortest path from the node 0 tothe node 2, which are both in Ck, may expand to the component Cl if the sum of edgeweights wa + wb > wc + wd + we

3.4 Path search on a detailed subgraph

In the second phase, graph G2(N2,E2) is constructed consisting of those components of the original graph G0, whose indexes are in the set L. The first phase on the reduced graph has determined, via which components the optimal path lead does. The second phase needs to reconstruct the path from the edges of the original, non-reduced graph, but it will only have to search the components of L. An example is provided on Figure 4, where the highlighted part is the subgraph that contains all components selected by the first phase.

FIGURE 4: The first phase of a path search from Praha to ˇ Cesk´e Budˇejovice has selectedcomponents forming a subgraph (red) that needs to be searched by the second phase.

1 2

a

b

cd

e

Page 20: Improvement Of A Shortest Routes Algorithm

3.5 Consideration

The selection of a partitioning strategy is crucial to the performance (but not the correctness) of the algorithm. There are various parameters that we want to optimize.An appropriate component size must be chosen. With too many small components, the graph G1 won’t be much simpler than the original graph G0. With too few big components, the complexity of the graph G0 will be reflected in the complexity of the components, since the number of edges of reduced components raises with the number of outer nodes.

The number of connector edges should be minimal. With less connector edges, the graph G1 becomes simpler. To minimize the number of connector edges, METIS is used for the partitioning. The number of outer nodes of each component should be minimal. Number of edges in the reduced component Rj is a square of the number of outer nodes Nej . The quadratic dependency of the number of edges could be improved by adding new transit nodes, which are not outer nodes, to the reduced component and substitute some direct connections between outer nodes with indirect connections via the transit nodes. However, it is then necessary to come up with an algorithm to pick the transit nodes. It is favorable to create components, whose nodes are geographically located near each other. The requirement of minimal edge cut doesn’t guarantee that the components will be compact in the terms of geographical locality. The locality is useful to reduce the number of components in the set L selected by the first phase of the algorithm (when the first phase is performed during a preprocessing step for multiple simultaneous shortest path queries).

3.6 Evaluation of final shortest path

As we know the main drawback of previous overdo parameter algorithm was optimal only for 1000 nodes in network. If we want to find path in large network containing millions of nodes then we have to use the new concept i.e. Graph Partitioning. Using this technique a large network is divided into small network containing components as we have discussed so far in this chapter.

As we have performed the partitioning, now we will apply overdo coefficient algorithm on each components Cj,of the network i.e.

d=√{(x1-x2)2+(y1-y2)2}*coefAfter that we take union of shortest path of each component.

An algorithm described an overdo coefficient uses graph partitioning (which can be performed with clustering) to speed up shortest path queries on a network representing means of public transport. However a similar algorithm is also applicable to road networks.