Ejemplo n.º 1
0
        public static RouteCalculation[] CreateRouteCalculation(AlgorithmStarter starter)
        {
            switch (starter.Algorithm)
            {
            case AlgorithmType.Hybrid:
                return(new[]
                {
                    CreateRouteCalculationInternal(starter, AlgorithmType.GoogleRouting, 0.4 * starter.TimeLimitMinutes),
                    CreateRouteCalculationInternal(starter, AlgorithmType.GeneticAlgorithm, 0.6 * starter.TimeLimitMinutes),
                });

            default:
                return(new[] { CreateRouteCalculationInternal(starter) });
            }
        }
Ejemplo n.º 2
0
        public long StartRouteCalculation([FromBody] AlgorithmStarter algorithmStarter)
        {
            var routeCalculations = RouteCalculationFactory.CreateRouteCalculation(algorithmStarter);

            using (var dbSession = SessionFactory.Instance.OpenSession())
            {
                foreach (var routeCalculation in routeCalculations)
                {
                    var savedRouteCalculation = dbSession.Merge(routeCalculation);
                    routeCalculation.Id = savedRouteCalculation.Id;
                    RouteCalculator.EnqueueRouteCalculation(routeCalculation.Id);
                }
            }

            return(routeCalculations[0].Id);
        }
Ejemplo n.º 3
0
        private static RouteCalculation CreateRouteCalculationInternal(AlgorithmStarter starter, AlgorithmType type, double timeLimitMinutes)
        {
            const long minutesToMilliseconds = 60 * 1000;

            return(new RouteCalculation
            {
                Days = starter.Days,
                MaxNumberOfAdditionalSantas = starter.MaxNumberOfAdditionalSantas,
                SantaJson = "",
                VisitsJson = "",
                TimeLimitMiliseconds = (long)(timeLimitMinutes * minutesToMilliseconds),
                StarterVisitId = starter.StarterId,
                State = RouteCalculationState.Creating,
                TimePerChildMinutes = starter.TimePerChild,
                TimePerChildOffsetMinutes = starter.Beta0,
                Year = starter.Year,
                Algorithm = type,
            });
        }
Ejemplo n.º 4
0
 private static RouteCalculation CreateRouteCalculationInternal(AlgorithmStarter starter)
 {
     return(CreateRouteCalculationInternal(starter, starter.Algorithm, starter.TimeLimitMinutes));
 }