Ejemplo n.º 1
0
        public TaskResponse CreateTask([FromBody] TaskRequest taskRequest)//ClientPoint clientPoint)
        {
            try
            {
                var parsedMode  = (RouteCalculationMode)(Enum.Parse(typeof(RouteCalculationMode), taskRequest.mode));
                var checkpoints = taskRequest.checkpoints.ConvertAll <PointF>(cp => new PointF(cp.x, cp.y));

                var routeCalculationRes = new RouteCalculation().Calculate(taskRequest.startPoint.toPointF(), checkpoints, parsedMode);
                var taskResponse        = new TaskResponse(routeCalculationRes);

                return(taskResponse);
            }catch (Exception e)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        public static ISolverConfig CreateSolverConfig(RouteCalculation routeCalculation, OptimizationInput input)
        {
            switch (routeCalculation.Algorithm)
            {
            case AlgorithmType.ILP:
                return
                    (new ILPConfig
                {
                    TimeSliceDuration = Properties.Settings.Default.TimeSliceDurationSeconds,
                    ClusteringMIPGap = Properties.Settings.Default.MIPGapClustering,
                    ClusteringTimeLimitMiliseconds = (long)(0.7 * routeCalculation.TimeLimitMiliseconds),
                    SchedulingMIPGap = Properties.Settings.Default.MIPGapScheduling,
                    SchedulingTimeLimitMiliseconds = (long)(0.3 * routeCalculation.TimeLimitMiliseconds),
                });

            case AlgorithmType.LocalSolver:
                return
                    (new LocalSolverConfig
                {
                    VrpTimeLimitFactor = 0.1,
                    VrptwTimeLimitFactor = 0.8,
                    MaxNumberOfAdditionalSantas = routeCalculation.MaxNumberOfAdditionalSantas,
                });

            case AlgorithmType.GeneticAlgorithm:
                return
                    (new ParallelGenAlgConfig(new GenAlgConfig(input, routeCalculation.MaxNumberOfAdditionalSantas), Properties.Settings.Default.NumberOfGARuns));

            case AlgorithmType.GoogleRouting:
                return(new GoogleRoutingConfig(routeCalculation.MaxNumberOfAdditionalSantas, SolvingMode.All));

            case AlgorithmType.Hybrid:
                throw new ArgumentException("Algorithm type Hybrid not allowed", nameof(routeCalculation.Algorithm));

            default:
                throw new ArgumentOutOfRangeException(nameof(routeCalculation), routeCalculation, "Unknown AlgorithmType. Cannot create a StartData.");
            }
        }