private static void WriteIntervalRuntimes(TextWriter tw, GraphTestResults results) { writeLineBreak(tw); string formatString = "{0,-20}\t{1,-20} "; tw.WriteLine(String.Format(formatString, "Interval", "Runtime")); writeLineBreak(tw); foreach (var algorithmTestResult in results.GetAlgorithmTestResults()) { tw.WriteLine(algorithmTestResult.AlgorithmName); for (int i = 0; i < AlgorithmTestResults.NUMBEROFINTERVALS; i++) { int start = (int)algorithmTestResult.GetIntervalLength() * i; int end = (int)algorithmTestResult.GetIntervalLength() * i + 1; string intervalString = "[" + i + "] (" + start + " - " + end + ")"; tw.WriteLine(String.Format(formatString, intervalString, algorithmTestResult.AverageIntervalRuntimes[i].ToString("N4"))); } writeLineBreak(tw); } }
/// <summary> /// runs path shortest path algorithm on each implementation /// </summary> /// <param name="graph"></param> internal static void TestPathFinders(RoutingGraph[] graphs) { GraphTestResults[] results = new GraphTestResults[graphs.Length]; //// get all types that inherit PathFinder for (int i = 0; i < graphs.Length; i++) { results[i] = new GraphTestResults(graphs[i].Name); results[i].Graph = graphs[i]; // run TestPathFinder on each type PathFinder ASBA = new AStarApproximateBucketPathFinder(graphs[i]); PathFinder ASH = new AStarMinHeapPathFinder(graphs[i]); PathFinder DIKBA = new DijkstraApproximateBucketPathFinder(graphs[i]); PathFinder DIKH = new DijkstraMinHeapPathFinder(graphs[i]); results[i].AddAlgorithmTestResult(TestPathFinder(ASBA)); results[i].AddAlgorithmTestResult(TestPathFinder(ASH)); results[i].AddAlgorithmTestResult(TestPathFinder(DIKBA)); results[i].AddAlgorithmTestResult(TestPathFinder(DIKH)); } ParseResults(results); }