コード例 #1
0
 /// <summary>
 /// not-implemented yet subroutine of getting a problem to solve
 /// and transforming it into the byte data
 /// </summary>
 /// <returns></returns>
 public void GetProblem()
 {
     Console.WriteLine("Provide path to problem instance please..");
     var problemPath = Console.ReadLine();
     var problemParser = new DVRPProblemParser(problemPath);
     var problem = problemParser.Parse();
     data = _problemConverter.ToByteArray(problem);
     type = "DVRP";
 }
コード例 #2
0
        public void ProblemFromGeneratorParsingTest2()
        {
            var parser = new DVRPProblemParser("io2_5_plain_a_D.vrp");
            DVRPProblemInstance problem = parser.Parse();

            Assert.AreEqual(problem.Visits.Count, 5);
            Assert.AreEqual(problem.Visits[3].Location.Y, -10);
            Assert.AreEqual(problem.Visits.First().Duration, 20);
            Assert.AreEqual(problem.VehicleNumber, 5);
            Assert.AreEqual(problem.Depots.First().Location.X, 0);
        }
コード例 #3
0
        public void DvrpAlgorithmTest()
        {
            var parser    = new DVRPProblemParser("io2_11_plain_a_D.vrp");
            var problem   = parser.Parse();
            var converter = new ProblemToBytesConverter();

            problem.VehicleSpeed = 7;
            var data   = converter.ToByteArray(problem);
            var solver = new DVRPTaskSolver(data);

            var divides             = solver.DivideProblem(0);
            var solvePartialProblem = new ConcurrentQueue <byte[]>();

            Parallel.ForEach(divides, element =>
            {
                solvePartialProblem.Enqueue(solver.Solve(element, TimeSpan.Zero));
            });
            var final    = solver.MergeSolution(solvePartialProblem.ToArray());
            var finalObj = (DVRPPartialProblemInstance)converter.FromBytesArray(final);

            Assert.AreEqual(820.23, Round(finalObj.PartialResult, 2), 2f);
        }