public void Test7()
        {
            AdjacencyMatrix testMatrix = new AdjacencyMatrix("test7.txt");
            DynamicTSP      solver     = new DynamicTSP(testMatrix, 0);

            solver.Solve();
            Assert.AreEqual(solver.minTourCost, 291);
        }
Exemple #2
0
        public void Test9()
        {
            AdjacencyMatrix testMatrix = new AdjacencyMatrix("test9.txt");
            BranchAndBound  solver     = new BranchAndBound(); solver.SetVariables(testMatrix);

            solver.Solve();
            DynamicTSP dynamicSolver = new DynamicTSP(testMatrix, 0);

            dynamicSolver.Solve();
            Assert.AreEqual(dynamicSolver.minTourCost, solver.max);
        }
Exemple #3
0
        public void ManualTest()
        {
            AdjacencyMatrix testMatrix    = new AdjacencyMatrix("manualTest.txt");
            DynamicTSP      dynamicSolver = new DynamicTSP(testMatrix, 0);
            BranchAndBound  solver        = new BranchAndBound(); solver.SetVariables(testMatrix);

            solver.Solve();
            dynamicSolver.Solve();
            for (int i = 0; i < solver.finalPath.Length; i++)
            {
                Console.WriteLine(solver.finalPath[i]);
            }
            Assert.AreEqual(dynamicSolver.minTourCost, solver.max);
        }
Exemple #4
0
        public void RandomTest()
        {
            for (int i = 0; i < 5; i++)
            {
                AdjacencyMatrix testMatrix = new AdjacencyMatrix(8);
                BranchAndBound  solver     = new BranchAndBound();
                testMatrix.GenerateRandomMatrix();
                DynamicTSP dynamicSolver = new DynamicTSP(testMatrix, 0);
                dynamicSolver.SetVariables(testMatrix);
                dynamicSolver.Solve();
                solver.SetVariables(testMatrix);
                solver.Solve();

                if (((int)dynamicSolver.minTourCost != solver.max))
                {
                    testMatrix.print();
                }
                Assert.AreEqual((int)dynamicSolver.minTourCost, solver.max);
            }
        }
Exemple #5
0
        public void FirstBoundTest()
        {
            AdjacencyMatrix testMatrix = new AdjacencyMatrix(4);

            for (int i = 0; i < 100000; i++)
            {
                BranchAndBound solver = new BranchAndBound();
                testMatrix.GenerateRandomMatrix();
                DynamicTSP dynamicSolver = new DynamicTSP(testMatrix, 0);
                solver.SetVariables(testMatrix);
                dynamicSolver.Solve();
                solver.Solve();
                if (dynamicSolver.minTourCost < solver.firstBound)
                {
                    Console.WriteLine("BestTour :" + dynamicSolver.minTourCost + "<= To bound" + solver.firstBound);
                    testMatrix.print();
                    dynamicSolver.printTour();
                    Assert.Fail();
                }
            }
        }