@@ -295,7 +295,9 @@ private void multiModalBenchmark() throws IOException {
295
295
LOGGER .info ("Starting multi modal" );
296
296
final LocalDateTime depDateTime = DATE_TO_BENCHMARK .atTime (TIME_TO_BENCHMARK );
297
297
final long depTime = depDateTime .atZone (ZoneId .systemDefault ()).toInstant ().toEpochMilli ();
298
- final Set <ETransportationMode > modes = EnumSet .of (ETransportationMode .BIKE , ETransportationMode .TRAM );
298
+ final Set <ETransportationMode > baseLineModes = EnumSet .of (ETransportationMode .CAR , ETransportationMode .BIKE ,
299
+ ETransportationMode .FOOT , ETransportationMode .TRAM );
300
+ final Set <ETransportationMode > restrictedModes = EnumSet .of (ETransportationMode .BIKE , ETransportationMode .TRAM );
299
301
300
302
LOGGER .info ("Computing Dijkstra ranks" );
301
303
// Determine the query pairs by computing Dijkstra ranks
@@ -339,28 +341,84 @@ private void multiModalBenchmark() throws IOException {
339
341
}
340
342
341
343
// Start measurements
342
- LOGGER .info ("Starting measurements" );
344
+ LOGGER .info ("Starting measurements, base line modes" );
345
+ // Base line modes
346
+ writeLine ("#Multi-modal, size " + mQueryGraph .size () + ", measuring for "
347
+ + depDateTime .format (DateTimeFormatter .ofPattern ("dd.MM.yyyy HH:mm" )) + ", with modes " + baseLineModes
348
+ + ", averaged over " + MULTI_MODAL_AVERAGING );
349
+
350
+ BenchmarkSuite .cleanup ();
351
+
352
+ final IShortestPathComputation <ICoreNode , ICoreEdge <ICoreNode >> baseLineComputation ;
353
+ if (mModel .getMode () == ERoutingModelMode .GRAPH_WITH_TIMETABLE ) {
354
+ // Measuring Hybrid
355
+ LOGGER .info ("Measuring Hybrid" );
356
+ writeLine ("#Hybrid" );
357
+ writeLine ("DijkstraRank(2^i)\t Time(ns)" );
358
+
359
+ baseLineComputation = mFactory .createAlgorithmHybridRoadTimetable (depTime , restrictedModes );
360
+ } else if (mModel .getMode () == ERoutingModelMode .LINK_GRAPH ) {
361
+ // Measuring LinkGraph
362
+ LOGGER .info ("Measuring LinkGraph" );
363
+ writeLine ("#LinkGraph" );
364
+ writeLine ("DijkstraRank(2^i)\t Time(ns)" );
365
+
366
+ baseLineComputation = mFactory .createAlgorithmLinkGraph (depTime , restrictedModes );
367
+ } else {
368
+ throw new IllegalStateException ("Unknown routing model mode: " + mModel .getMode ());
369
+ }
370
+
371
+ // Measure for all exponents
372
+ for (int i = UNI_MODAL_TIME_INDEPENDENT_STARTING_RANK ; i <= greatestCommonExponent ; i ++) {
373
+ final int exponentIndex = i - UNI_MODAL_TIME_INDEPENDENT_STARTING_RANK ;
374
+ // Get source-destination queries with this Dijkstra rank
375
+ final long [] durationsNanos = new long [querySourceToDestination .size ()];
376
+ int averagingCounter = 0 ;
377
+ for (final Entry <ICoreNode , List <ICoreNode >> sourceToDestinations : querySourceToDestination .entrySet ()) {
378
+ final ICoreNode source = sourceToDestinations .getKey ();
379
+ final ICoreNode destination = sourceToDestinations .getValue ().get (exponentIndex );
380
+
381
+ // Measure this query
382
+ final long startTime = System .nanoTime ();
383
+ baseLineComputation .computeShortestPath (source , destination );
384
+ final long endTime = System .nanoTime ();
385
+ final long duration = endTime - startTime ;
386
+ durationsNanos [averagingCounter ] = duration ;
387
+ averagingCounter ++;
388
+ }
389
+ final long durationNanosAverage = (long ) Arrays .stream (durationsNanos ).average ().getAsDouble ();
390
+ writeLine (i + "\t " + durationNanosAverage );
391
+
392
+ if (exponentIndex % 3 == 0 ) {
393
+ LOGGER .info ("Steps to go: " + (greatestCommonExponent - i ));
394
+ }
395
+ }
396
+
397
+ writeSeparator ();
398
+
399
+ // Restricted modes
400
+ LOGGER .info ("Starting measurements, restricted modes" );
343
401
writeLine ("#Multi-modal, size " + mQueryGraph .size () + ", measuring for "
344
- + depDateTime .format (DateTimeFormatter .ofPattern ("dd.MM.yyyy HH:mm" )) + ", with modes " + modes
402
+ + depDateTime .format (DateTimeFormatter .ofPattern ("dd.MM.yyyy HH:mm" )) + ", with modes " + restrictedModes
345
403
+ ", averaged over " + MULTI_MODAL_AVERAGING );
346
404
347
405
BenchmarkSuite .cleanup ();
348
406
349
- final IShortestPathComputation <ICoreNode , ICoreEdge <ICoreNode >> computation ;
407
+ final IShortestPathComputation <ICoreNode , ICoreEdge <ICoreNode >> restrictedComputation ;
350
408
if (mModel .getMode () == ERoutingModelMode .GRAPH_WITH_TIMETABLE ) {
351
409
// Measuring Hybrid
352
410
LOGGER .info ("Measuring Hybrid" );
353
411
writeLine ("#Hybrid" );
354
412
writeLine ("DijkstraRank(2^i)\t Time(ns)" );
355
413
356
- computation = mFactory .createAlgorithmHybridRoadTimetable (depTime , modes );
414
+ restrictedComputation = mFactory .createAlgorithmHybridRoadTimetable (depTime , restrictedModes );
357
415
} else if (mModel .getMode () == ERoutingModelMode .LINK_GRAPH ) {
358
416
// Measuring LinkGraph
359
417
LOGGER .info ("Measuring LinkGraph" );
360
418
writeLine ("#LinkGraph" );
361
419
writeLine ("DijkstraRank(2^i)\t Time(ns)" );
362
420
363
- computation = mFactory .createAlgorithmLinkGraph (depTime , modes );
421
+ restrictedComputation = mFactory .createAlgorithmLinkGraph (depTime , restrictedModes );
364
422
} else {
365
423
throw new IllegalStateException ("Unknown routing model mode: " + mModel .getMode ());
366
424
}
@@ -377,7 +435,7 @@ private void multiModalBenchmark() throws IOException {
377
435
378
436
// Measure this query
379
437
final long startTime = System .nanoTime ();
380
- computation .computeShortestPath (source , destination );
438
+ restrictedComputation .computeShortestPath (source , destination );
381
439
final long endTime = System .nanoTime ();
382
440
final long duration = endTime - startTime ;
383
441
durationsNanos [averagingCounter ] = duration ;
0 commit comments