예제 #1
0
        public void SolutionTest2()
        {
            var matrix = new[]
            {
                new [] { 20.0, 29.0, 6.0 },
                new [] { 23.0, 15.0, 11.0 },
                new [] { 20.0, 16.0, 10.0 },
                new [] { 15.0, 19.0, 9.0 },
                new [] { 24.0, 29.0, 8.0 },
            };

            double[] need = { 150.0, 140.0, 110.0, 230.0, 220.0 };
            double[] have = { 320.0, 280.0, 250.0 };

            double[,] actual = { { 120.0, 0.0, 30.0 }, { 0.0, 140.0, 0.0 }, { 0.0, 110.0, 0.0 }, { 200.0, 30.0, 0.0 }, { 0.0, 0.0, 220.0 } };

            var table = new TransportTable(matrix, have, need);

            var pythonSolver = new PythonSimplexSolver();

            var solution = table.SolveTable(pythonSolver);

            Assert.AreEqual(table.FunctionValue(pythonSolver), 11770);
            Assert.AreEqual(solution.ToArray(), actual);
        }
예제 #2
0
        public void SolutionTest1()
        {
            var matrix = new[]
            {
                new [] { 2.0, 3.0, 1.0 },
                new [] { 4.0, 2.0, 5.0 }
            };

            double[] need = { 30.0, 200.0 };
            double[] have = { 20.0, 50.0, 100.0 };

            double[,] actual = { { 0, 0, 30, 0 }, { 20, 50, 70, 60 } };

            var table = new TransportTable(matrix, have, need);

            var solver   = new PythonSimplexSolver();
            var solution = table.SolveTable(solver);

            Assert.AreEqual(table.FunctionValue(solver), 920);
            Assert.AreEqual(solution.ToArray(), actual);
        }
예제 #3
0
        public void SolutionTest3()
        {
            var matrix = new[]
            {
                new [] { 4.0, 4.0, 3.0 },
                new [] { 3.0, 2.0, 4.0 },
            };

            double[] need = { 26.0, 33.0 };
            double[] have = { 22.0, 21.0, 24.0 };

            double[,] actual = { { 2.0, 0.0, 24.0 }, { 12.0, 21.0, 0.0 }, { 8.0, 0.0, 0.0 } };

            var table = new TransportTable(matrix, have, need);

            var pythonSolver = new PythonSimplexSolver();

            var solution = table.SolveTable(pythonSolver);

            Assert.AreEqual(table.FunctionValue(pythonSolver), 158);
            Assert.AreEqual(solution.ToArray(), actual);
        }