Example #1
0
        public IEnumerable <TravelPlan> GetTravelPlans(TravelOptions travelOptions)
        {
            var source      = travelOptions.Source;
            var destination = travelOptions.Destination;

            ValidateLocations(source, destination);

            var startDate = travelOptions.StartDate ?? DateTime.Now;
            var graph     = _graphBuilder.GetGraph(startDate);

            // Get the names of the closest stops by location coordinates
            if (string.IsNullOrEmpty(source.Name) || string.IsNullOrEmpty(destination.Name))
            {
                UpdatedLocationsWithNamesOfTheClosestStops(source, destination, graph);
            }

            // Get available paths from source to destination
            var availablePaths = _pathProvider.GetAvailablePaths(graph, source, destination);

            availablePaths.ForEach(p => p.StartDate = startDate);
            var travelPlans  = _mapper.Map <List <TravelPlan> >(availablePaths);
            var travelPlanId = 1;

            travelPlans?.ForEach(t =>
            {
                t.Id = travelPlanId;
                travelPlanId++;
            });

            return(travelPlans?.OrderBy(t => t.Transfers).ThenBy(t => t.StartTime).ThenBy(t => t.Duration));
        }
Example #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);
        }