/// <summary> /// Runs A* tests. /// </summary> /// <param name="graph">The graph.</param> /// <param name="source">The source.</param> /// <param name="destination">The destination.</param> /// <param name="resultPath">The result path.</param> /// <param name="infoDataTable">The information data table.</param> /// <returns>Average results</returns> private AverageTestResult RunAStarTests(Graph <int, StopTimeInfo> graph, Location source, Location destination, string resultPath, DataTable infoDataTable) { var testResults = new List <TestResult>(IterationCount); var pathSearcher = new StopTimePathSearcher(new StopTimePathFinder(), graph, source, destination); for (var iteration = 1; iteration <= IterationCount; iteration++) { var singleIterationTestResult = RunSingleAStarTest(pathSearcher); testResults.Add(singleIterationTestResult); _logger.LogInformation($"Finished testing A*, iteration {iteration} in {singleIterationTestResult.Time.TotalSeconds} s."); } var solutionsDataTable = DataTableUtils.GetSolutionsDataTable(testResults); // Export test results to file var filePath = Path.Combine(resultPath, "details", "AStar_TestResults"); _excelExportService.ExportToExcel(infoDataTable, null, solutionsDataTable, filePath); _logger.LogInformation($"Saved file under path: {filePath}"); // Return the average results return(new AverageTestResult(testResults)); }
/// <summary> /// Runs the single A* test. /// </summary> /// <param name="pathSearcher">The path searcher.</param> /// <returns></returns> private TestResult RunSingleAStarTest(StopTimePathSearcher pathSearcher) { Harmony <StopTimeInfo> shortestPath = null; var elapsedTime = _actionTimer.MeasureTime(() => { shortestPath = pathSearcher.GetShortestPath(); }); return(new TestResult { Solution = shortestPath, Time = elapsedTime }); }