Example #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);
        }
Example #2
0
        public static void Run(string[] args)
        {
            string source      = string.Empty;
            string target      = string.Empty;
            bool   overwrite   = false;
            bool   help        = false;
            bool   addFolder   = true;
            bool   addSameGuid = true;

            var options = new OptionSet
            {
                { "s|source=", "the glob pattern to match solution files", s => source = s },
                { "t|target=", "the target solution file", t => target = t },
                { "f|add-folder", "add relative solution folder", f => addFolder = f != null },
                { "g|add-same-guid", "add projects with same guid by creating new guid", g => addSameGuid = g != null },
                { "w|write", "overwrite project file(s)", w => overwrite = w != null },
                { "h|help", "show options", h => help = h != null },
            };

            try
            {
                options.Parse(args);
            }
            catch (OptionException e)
            {
                // output some error message
                Logger.Error(e.Message);
                Logger.Error("Try `--help' for more information.");
                return;
            }

            if (help)
            {
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            var merger = new SolutionMerger();

            try
            {
                var isDirty = merger.Execute(source, target, overwrite, addFolder, addSameGuid);
                if (isDirty)
                {
                    Logger.Info($"Merged solution {source} to {target}");
                }
            }
            catch (Exception e)
            {
                Logger.Error($"Error merging solutions {source} to {target}");
                Logger.Error(e.Message);
                Logger.Error(e.StackTrace);
            }
        }
Example #3
0
        public override byte[] MergeSolution(byte[][] solutions)
        {
            logger.Warn("Starting merging problem");
            SolutionMerger merger = new SolutionMerger();
            var            soluts = serializer.DeserializePartialSolutions(solutions);
            var            result = merger.MergeSolution(soluts, problem);

            logger.Warn($"Solution: {result.Result}");

            logger.Warn("Finished merging problem");
            return(serializer.SerializeSolution(result));
        }
 public SolutionMergerTests()
 {
     solutionMerger = new SolutionMerger();
 }