@@ -27,6 +27,7 @@ pub use crate::fast_graph::FastGraph;
27
27
pub use crate :: fast_graph32:: FastGraph32 ;
28
28
pub use crate :: fast_graph_builder:: FastGraphBuilder ;
29
29
pub use crate :: fast_graph_builder:: Params ;
30
+ use crate :: fast_graph_builder:: ParamsWithOrder ;
30
31
pub use crate :: input_graph:: Edge ;
31
32
pub use crate :: input_graph:: InputGraph ;
32
33
pub use crate :: path_calculator:: PathCalculator ;
@@ -67,6 +68,15 @@ pub fn prepare_with_order(input_graph: &InputGraph, order: &[NodeId]) -> Result<
67
68
FastGraphBuilder :: build_with_order ( input_graph, order)
68
69
}
69
70
71
+ /// Like `prepare_with_order()`, but allows specifying some parameters used for the graph preparation
72
+ pub fn prepare_with_order_with_params (
73
+ input_graph : & InputGraph ,
74
+ order : & [ NodeId ] ,
75
+ params : & ParamsWithOrder ,
76
+ ) -> Result < FastGraph , String > {
77
+ FastGraphBuilder :: build_with_order_with_params ( input_graph, order, params)
78
+ }
79
+
70
80
/// Calculates the shortest path from `source` to `target`.
71
81
pub fn calc_path ( fast_graph : & FastGraph , source : NodeId , target : NodeId ) -> Option < ShortestPath > {
72
82
let mut calc = PathCalculator :: new ( fast_graph. get_num_nodes ( ) ) ;
@@ -136,6 +146,7 @@ mod tests {
136
146
use crate :: preparation_graph:: PreparationGraph ;
137
147
138
148
use super :: * ;
149
+ use crate :: fast_graph_builder:: ParamsWithOrder ;
139
150
140
151
#[ test]
141
152
fn routing_on_random_graph ( ) {
@@ -391,9 +402,11 @@ mod tests {
391
402
fn run_performance_test_dist ( ) {
392
403
println ! ( "Running performance test for Bremen dist" ) ;
393
404
// road network extracted from OSM data from Bremen, Germany using the road distance as weight
405
+ // prep: 190ms, query: 16μs, out: 68494, in: 68426
406
+ // todo: try to tune parameters
394
407
run_performance_test (
395
408
& InputGraph :: from_file ( "meta/test_maps/bremen_dist.gr" ) ,
396
- & Params :: default ( ) ,
409
+ & Params :: new ( 0.1 , 500 , 2 , 50 ) ,
397
410
845493338 ,
398
411
30265 ,
399
412
)
@@ -404,9 +417,11 @@ mod tests {
404
417
fn run_performance_test_time ( ) {
405
418
println ! ( "Running performance test for Bremen time" ) ;
406
419
// road network extracted from OSM data from Bremen, Germany using the travel time as weight
420
+ // prep: 256ms, query: 11μs, out: 64825, in: 65027
421
+ // todo: try to tune parameters
407
422
run_performance_test (
408
423
& InputGraph :: from_file ( "meta/test_maps/bremen_time.gr" ) ,
409
- & Params :: default ( ) ,
424
+ & Params :: new ( 0.1 , 100 , 2 , 100 ) ,
410
425
88104267255 ,
411
426
30265 ,
412
427
) ;
@@ -416,9 +431,11 @@ mod tests {
416
431
#[ test]
417
432
fn run_performance_test_ballard ( ) {
418
433
println ! ( "Running performance test for ballard" ) ;
434
+ // prep: 1150ms, query: 53μs, out: 43849, in: 43700
435
+ // todo: try to tune parameters
419
436
run_performance_test (
420
437
& InputGraph :: from_file ( "meta/test_maps/graph_ballard.gr" ) ,
421
- & Params :: new ( 0.01 ) ,
438
+ & Params :: new ( 0.1 , 100 , 3 , 100 ) ,
422
439
28409159409 ,
423
440
14992 ,
424
441
) ;
@@ -428,9 +445,11 @@ mod tests {
428
445
#[ test]
429
446
fn run_performance_test_23rd ( ) {
430
447
println ! ( "Running performance test for 23rd" ) ;
448
+ // prep: 170ms, query: 23μs, out: 11478, in: 11236
449
+ // todo: try to tune parameters
431
450
run_performance_test (
432
451
& InputGraph :: from_file ( "meta/test_maps/graph_23rd.gr" ) ,
433
- & Params :: default ( ) ,
452
+ & Params :: new ( 0.1 , 100 , 3 , 100 ) ,
434
453
19438403873 ,
435
454
20421 ,
436
455
) ;
@@ -440,26 +459,46 @@ mod tests {
440
459
#[ test]
441
460
fn run_performance_test_south_seattle_car ( ) {
442
461
println ! ( "Running performance test for South Seattle car" ) ;
462
+ // prep: 877ms, query: 26μs, out: 68777, in: 68161
463
+ // todo: try to tune parameters
443
464
run_performance_test (
444
465
& InputGraph :: from_file ( "meta/test_maps/south_seattle_car.gr" ) ,
445
- & Params :: default ( ) ,
466
+ & Params :: new ( 0.1 , 100 , 10 , 100 ) ,
446
467
77479396 ,
447
468
30805 ,
448
469
) ;
449
470
}
450
471
451
472
#[ ignore]
452
473
#[ test]
453
- fn run_performance_test_dist_fixed_ordering ( ) {
474
+ fn run_performance_test_bremen_dist_fixed_ordering ( ) {
454
475
println ! ( "Running performance test for Bremen dist (fixed node ordering)" ) ;
476
+ // prep: 340ms, prep_order: 64ms, query: 16μs, out: 66646, in: 66725
477
+ // todo: try to tune parameters
455
478
run_performance_test_fixed_ordering (
456
479
& InputGraph :: from_file ( "meta/test_maps/bremen_dist.gr" ) ,
457
480
& Params :: default ( ) ,
481
+ & ParamsWithOrder :: default ( ) ,
458
482
845493338 ,
459
483
30265 ,
460
484
) ;
461
485
}
462
486
487
+ #[ ignore]
488
+ #[ test]
489
+ fn run_performance_test_south_seattle_fixed_ordering ( ) {
490
+ println ! ( "Running performance test for South Seattle car (fixed node ordering)" ) ;
491
+ // prep: 811ms, prep order: 138ms, query: 27μs, out: 68777, in: 68161
492
+ // todo: try to tune parameters
493
+ run_performance_test_fixed_ordering (
494
+ & InputGraph :: from_file ( "meta/test_maps/south_seattle_car.gr" ) ,
495
+ & Params :: new ( 0.1 , 100 , 10 , 100 ) ,
496
+ & ParamsWithOrder :: new ( 100 ) ,
497
+ 77479396 ,
498
+ 30805 ,
499
+ ) ;
500
+ }
501
+
463
502
fn run_performance_test (
464
503
input_graph : & InputGraph ,
465
504
params : & Params ,
@@ -484,6 +523,7 @@ mod tests {
484
523
fn run_performance_test_fixed_ordering (
485
524
input_graph : & InputGraph ,
486
525
params : & Params ,
526
+ params_with_order : & ParamsWithOrder ,
487
527
expected_checksum : usize ,
488
528
expected_num_not_found : usize ,
489
529
) {
@@ -496,7 +536,10 @@ mod tests {
496
536
) ;
497
537
let order = get_node_ordering ( & fast_graph) ;
498
538
prepare_algo (
499
- & mut |input_graph| fast_graph = prepare_with_order ( input_graph, & order) . unwrap ( ) ,
539
+ & mut |input_graph| {
540
+ fast_graph =
541
+ prepare_with_order_with_params ( input_graph, & order, params_with_order) . unwrap ( )
542
+ } ,
500
543
& input_graph,
501
544
) ;
502
545
print_fast_graph_stats ( & fast_graph) ;
0 commit comments