Пример #1
0
        public void basic_test()
        {
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream);

            writer.Write(str);
            writer.Flush();
            stream.Position = 0;
            loader          = new FileLoader(stream);

            Problem p = loader.LoadProblem();

            DvrpTaskSolver.FixClientsStartTimes(p);
            stream.Position = 0;
            double sol = loader.LoadSolution();

            ProblemDivider       divider = new ProblemDivider();
            PartialProblemSolver solver  = new PartialProblemSolver();
            SolutionMerger       merger  = new SolutionMerger();

            var partproblmes = divider.DivideProblem(p);

            List <PartialSolution> soluts = new List <PartialSolution>();

            foreach (var part in partproblmes /*.Where(ee => ee.SetId == 17)*/)
            {
                soluts.Add(solver.SolvePartialProblem(part, p));
            }

            var ssss = merger.MergeSolution(soluts, p);

            ssss.Result.ShouldBeInRange(sol - 5, sol + 5);
        }
Пример #2
0
        public override byte[] Solve(byte[] partialData, TimeSpan timeout)
        {
            logger.Warn("Starting solving partial problem");
            PartialProblemSolver solver = new PartialProblemSolver();
            var partialProblemData      = serializer.DeserializePartialProblem(partialData);
            var result = solver.SolvePartialProblem(partialProblemData, problem);

            logger.Warn($"Finished solving partial problem, result: {result.Result}");
            return(serializer.SerializePartialSolution(result));
        }
        public void SimpleProblem()
        {
            PartialProblem pp = new PartialProblem
            {
                Id      = 1,
                SetId   = 1,
                Clients = new HashSet <Client>
                {
                    new Client
                    {
                        RequestSize = 5,
                        StartTime   = 14,
                        UnloadTime  = 1,
                        X           = 0,
                        Y           = 0
                    }
                }
            };
            Problem p = new Problem
            {
                VehiclesCapacity = 10,
                VehicleSpeed     = 1,
                Depots           = new HashSet <Depot>
                {
                    new Depot
                    {
                        StartTime = 12,
                        EndTime   = 18,
                        X         = 1,
                        Y         = 1
                    }
                }
            };
            var ret = problemSolver.SolvePartialProblem(pp, p);

            ret.Result.ShouldBe(2 * Math.Sqrt(2));
        }