You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The choice between all the algorithms is available for *one-to-one* calculation like `get_distance_pair` and `get_path_pair` on a non-contracted graph.
81
+
*1*, *2*, *3* and *4* are available for **one-to-one** calculation in `get_distance_pair` and `get_path_pair`functions on a **non-contracted** graph.
81
82
In these functions, uni-directional Dijkstra algorithm is stopped when the destination node is reached.
82
83
`A*` and `NBA*` are relevant if geographic coordinates of all nodes are provided. Note that coordinates should be expressed in a **projection system**.
83
84
To be accurate and efficient, `A*` and `NBA*` algorithms should use an admissible heuristic function (here the Euclidean distance), i.e cost and heuristic function must be expressed in the same unit.
84
85
In `cppRouting`, heuristic function `h` for a node (n) is defined such that :
85
86
**h(n,d) = ED(n,d) / k**
86
87
with *h* the heuristic, *ED* the Euclidean distance, *d* the destination node and a constant *k*.
87
-
88
88
So in the case where coordinates are expressed in meters and cost is expressed in time, *k* is the maximum speed allowed on the road. By default, constant is 1 and is designed for graphs with cost expressed in the same unit than coordinates (for example in meters).
89
-
90
-
If coordinates cannot be provided, bi-directional Dijkstra algorithm is the best option in terms of performance.
89
+
If coordinates cannot be provided, bi-directional Dijkstra algorithm is the best option in terms of performance.
90
+
91
+
*5* is used for **one-to-one** calculation in `get_distance_pair` and `get_path_pair` functions on a **contracted** graph.
92
+
93
+
*1* is used for **one-to-many** calculation in `get_distance_matrix` function on a **non-contracted** graph.
94
+
95
+
*6* and *7* are available for **one-to-many** calculation in `get_distance_matrix` function on a **contracted** graph.
91
96
92
97
##Examples
93
98
###Prepare data
@@ -314,7 +319,7 @@ Initially created for *one-to-one* queries, it has been extended to *many-to-man
314
319
This technique is composed of two phases:
315
320
316
321
- preprocessing phase called *contraction* with `cpp_contract` function
317
-
- query phase : a slightly modified version of bidirectional search for `one-to-one` query, available in `get_distance_pair` and `get_path_pair`; and a `many-to-many` algorithm using buckets available in `get_distance_matrix` function.
322
+
- query phase : a slightly modified version of bidirectional search for `one-to-one` query, available in `get_distance_pair` and `get_path_pair`; PHAST algorithm and a `many-to-many` algorithm using buckets available in `get_distance_matrix` function.
318
323
319
324
Contraction phase consists of iteratively removing a vertex **v** from the graph and creating a shortcut for each pair **(u,w)** of **v**'s neighborhood if the shortest path from **u** to **w** contains **v**. To be efficient and avoid creating too much shortcuts, vertices have to be ordered according to several heuristics. The two heuristics used by `cppRouting` are :
"nba : new bidirectional A* on the original graph"), notation="none")
363
368
364
369
```
365
-
Here are the plots (in log-log) of query time improvement factor :
370
+
Here are the plots (in log-log) of query time improvement factor of *one to one CH* algorithm compared to bidirectional Dijkstra and NBA :
366
371
```{r,echo=FALSE,message=FALSE,warning=FALSE}
367
372
library(ggthemes)
368
373
bench<-read.csv2("benchmark_contract_pair.csv")
@@ -391,40 +396,44 @@ p1
391
396
As we can see on the plot, the larger is the graph, the higher is the benefit of using contraction hierarchies. For OSM Europe, query time can be faster by a factor of 1000 compared to bidirectional Dijkstra and 600 to NBA.
392
397
393
398
#####Distance matrix
394
-
Here are the measurements of contraction time and query time (in second) of contraction hierarchies on different graphs.
395
-
Matrix are square (i.e the sets of source and target nodes are of equal length)
399
+
Here are the measurements of query time (in second) of contraction hierarchies on different graphs.
400
+
We compare *PHAST* and *many to many CH* to Dijkstra algorithm on square matrix (i.e the sets of source and target nodes are of equal length).
Benefits are less important than *one-to-one* queries but still interesting. For OSM Europe, query time can be faster by a factor of 90.
450
+
Benefits are less important than *one-to-one* queries but still interesting. For OSM Europe, query time can be faster by a factor of 90.
451
+
PHAST's improvement is constant since it iteratively perform an *one-to-all* search, just like original Dijkstra.
452
+
*many to many CH* is well adapted for **square matrix**.
453
+
454
+
Here are the plots of query time of *PHAST* and *many to many CH* on assymetric matrix (i.e. number of source and number of target are unequal) with *|S| / |T|* the number of sources divided by the number of targets :
*PHAST* algorithm is much faster for rectangular matrix. The rate *|S| / |T|* where *many to many CH* is better varies according the graph size. For example, if we have to calculate a distance matrix between 10000 sources and 10 targets (or 10 sources and 10000 targets) on OSM France, we must use *PHAST*. On the other hand, if we want a matrix of 10000 sources and 8000 targets, we use *many to many CH* algorithm.
442
489
443
490
###Compute isochrones
444
491
Let's compute isochrones around Dijon city
@@ -475,6 +522,7 @@ p
475
522
476
523
```
477
524
525
+
478
526
#Applications
479
527
480
528
**Except application 4, all indicators are calculated at the country scale but for the limited `R`'s ability to plot large shapefile, only one region is mapped.**
@@ -538,11 +586,11 @@ The shortest travel time is computed with the `cppRouting` function `get_distanc
538
586
In order to compute multiple distances from one source, original uni-directional Dijkstra algorithm is ran without early stopping.
539
587
We compute travel time from all commune nodes to all maternity ward nodes (i.e ~36000*400 distances).
0 commit comments