コード例 #1
0
        public void TestSolver2()
        {
            // create a problem with only one customer.
            var problem = TSPHelper.CreateTSP(0, 1, 2, 10);

            // create the solver.
            var solver   = new BruteForceSolver();
            var solution = solver.Solve(problem, new TSPObjective());

            // verify solution.
            Assert.AreEqual(new int[] { 0, 1 }, solution.ToArray());
        }
コード例 #2
0
        public void TestSolverClosed()
        {
            // create the problem and make sure 0->1->2->3->4 is the solution.
            var problem = TSPHelper.CreateTSP(0, 0, 5, 10);

            problem.Weights[0][1] = 1;
            problem.Weights[1][2] = 1;
            problem.Weights[2][3] = 1;
            problem.Weights[3][4] = 1;
            problem.Weights[4][0] = 1;

            // create the solver.
            var solver   = new BruteForceSolver();
            var solution = solver.Solve(problem, new TSPObjective());

            // verify solution.
            Assert.AreEqual(new int[] { 0, 1, 2, 3, 4 }, solution.ToArray());
        }