コード例 #1
0
ファイル: Program.cs プロジェクト: agasinsk/MPK.Connect
        private static void RunTestWithMultipleRoutes(HarmonySearchTester tester, HarmonySearchTestScenario scenarios)
        {
            var testRoutes = new List <Tuple <Location, Location> >
            {
                new Tuple <Location, Location>(new Location("Grunwaldzka"), new Location("Ogród Botaniczny")),
                new Tuple <Location, Location>(new Location("Rynek"), new Location("Pl. Grunwaldzki")),
                new Tuple <Location, Location>(new Location("Bajana"), new Location("FAT")),
                new Tuple <Location, Location>(new Location("Biskupin"), new Location("Port Lotniczy"))
            };

            tester.RunTestsWithLocations(testRoutes, scenarios, new DateTime(2019, 05, 14, 15, 0, 0));
        }
コード例 #2
0
        /// <summary>
        /// Runs the tests with scenario.
        /// </summary>
        /// <param name="scenario">The scenario.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="dateTime">The date time.</param>
        public void RunTestsWithScenario(HarmonySearchTestScenario scenario, Location source, Location destination, DateTime?dateTime = null)
        {
            var graph = _graphBuilder.GetGraph(dateTime ?? DateTime.Now);

            var topResultDirectory = $"Tests_{DateTime.Now:ddMMyyyy_HHmm}_{source.Name.Trim()}_{destination.Name.Trim()}";

            var infoDataTable = DataTableUtils.GetCommonInfoDataTable(source, destination);
            var harmonySearchAverageTestResults = RunTests(scenario, source, destination, graph, topResultDirectory, infoDataTable);

            var aStarAverageTestResults = RunAStarTests(graph, source, destination, topResultDirectory, infoDataTable);

            ExportAverageTestResults(harmonySearchAverageTestResults, aStarAverageTestResults, infoDataTable, topResultDirectory);
        }
コード例 #3
0
        /// <summary>
        /// Runs the tests.
        /// </summary>
        /// <param name="scenario">The scenario.</param>
        /// <param name="source">The source.</param>
        /// <param name="destination">The destination.</param>
        /// <param name="graph">The graph.</param>
        /// <param name="topResultDirectory">The top result directory.</param>
        /// <param name="infoDataTable">The information data table.</param>
        /// <returns></returns>
        private List <HarmonySearchAverageTestResult> RunTests(HarmonySearchTestScenario scenario, Location source, Location destination, Graph <int, StopTimeInfo> graph, string topResultDirectory, DataTable infoDataTable)
        {
            var averageTestResults = new List <HarmonySearchAverageTestResult>();

            foreach (var harmonySearchTestSettings in scenario.Settings)
            {
                var harmonySearcher = harmonySearchTestSettings.GetHarmonySearcher(graph, source, destination);

                var testsResult = RunTests(harmonySearcher, infoDataTable, topResultDirectory);

                averageTestResults.Add(testsResult);
            }

            return(averageTestResults);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: agasinsk/MPK.Connect
        private static void Main(string[] args)
        {
            // Create service collection
            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);

            using (var scope = Container.BeginLifetimeScope())
            {
                var tester = scope.Resolve <HarmonySearchTester>();

                var scenarios = new HarmonySearchTestScenario(ObjectiveFunctionType.Comprehensive);

                RunTestWithMultipleRoutes(tester, scenarios);
            }
        }
コード例 #5
0
        /// <summary>
        /// Runs the harmony search tests with scenario and locations.
        /// </summary>
        /// <param name="locations">The locations.</param>
        /// <param name="scenario">The test scenario.</param>
        /// <param name="dateTime">The date time.</param>
        public void RunTestsWithLocations(List <Tuple <Location, Location> > locations, HarmonySearchTestScenario scenario, DateTime?dateTime = null)
        {
            foreach (var(source, destination) in locations)
            {
                RunTestsWithScenario(scenario, source, destination, dateTime);

                _logger.LogInformation($"Finished testing Harmony Search: {source.Name} --> {destination.Name}");
            }
        }