Ejemplo n.º 1
0
        public static void ExampleDual1Mod()
        {
            var a = MatrixGenerator.From(new double[,] { { 1, 1, -3 }, { 1, -2, 1 } });
            var b = MatrixGenerator.From(new double[,] { { 0, 3 } }).Transpose();
            var c = MatrixGenerator.From(new double[,] { { 1, 1, -4 } }).Transpose();

            var dMin = MatrixGenerator.From(new double[,] {{-50, -50, -50}}).Transpose();
            var dMax = MatrixGenerator.From(new double[,] {{10, 10, 10}}).Transpose();
            List<int> baseIndexes = new List<int>(new[] { 0,1 });

            var sm = new SimplexMethodDualModification(a, b, c, baseIndexes, dMin, dMax);
            Matrix pseudo = null;
            bool isSolved = sm.Solve(out pseudo);
            PrintSolution(isSolved, c, pseudo);
        }
Ejemplo n.º 2
0
        public static void ExampleDual6Mod()
        {
            var a = MatrixGenerator.From(new double[,] { { -0.0114, -0.00741, -0.02541, 0, 1, 0 },
                                                         { 0.00138, 0.000375, -0.001625, -1, 0, 0 },
                                                         {  -0.0018, -0.00275, -0.00475, 0, 0, 1} });
            //var x = MatrixGenerator.From(new double[,] {{1,-1,-2,3.6,2,4,1.6}}).Transpose();
            var x = MatrixGenerator.From(new double[,] { { 1, 1, 1, 0, 0, 0 } }).Transpose();
            var b = a.Copy().Multiply(x);
            //var b = MatrixGenerator.From(new double[,] { { 4, 28, -4 } }).Transpose();
            var c = MatrixGenerator.From(new double[,] { { 7080, 5100, 4010,0,0,0 } }).Transpose();
            List<int> baseIndexes = new List<int>(new[] { 0, 1, 2 });
            //var dMin = MatrixGenerator.From(new double[,] { { -1, -1, -2, -3, -1, -2, -1 } }).Transpose().Multiply(10);
            var dMin = MatrixGenerator.From(new double[,] { { 0,0,0,0,0,0} }).Transpose();
            var dMax = MatrixGenerator.From(new double[,] { { 9,9,9,9,9,9 } }).Transpose();

            var sm = new SimplexMethodDualModification(a, b, c, baseIndexes, dMin, dMax);
            Matrix pseudo = null;
            bool isSolved = sm.Solve(out pseudo);
            PrintSolution(isSolved, c, pseudo);
        }
Ejemplo n.º 3
0
        public static void ExampleDual5Mod()
        {
            var a = MatrixGenerator.From(new double[,] { { 1,0,1,1,3,1,4 },
                                                         { 0, 1, 1, 0, 2, 0, 5 },
                                                         {  2,0,1,-4,1,1,-1} });
            //var x = MatrixGenerator.From(new double[,] {{1,-1,-2,3.6,2,4,1.6}}).Transpose();
            var x = MatrixGenerator.From(new double[,] {{3,-1,-2,4,1,3,2}}).Transpose();
            var b = a.Copy().Multiply(x);
            //var b = MatrixGenerator.From(new double[,] { { 4, 28, -4 } }).Transpose();
            var c = MatrixGenerator.From(new double[,] { { 10, 0, -1, 6, 6, 2, 8 } }).Transpose();
            List<int> baseIndexes = new List<int>(new[] { 1,2,3});
            //var dMin = MatrixGenerator.From(new double[,] { { -1, -1, -2, -3, -1, -2, -1 } }).Transpose().Multiply(10);
            var dMin = MatrixGenerator.From(new double[,] { { -1, -1, -2, -3, -1, 2, 1 } }).Transpose();
            var dMax = MatrixGenerator.From(new double[,] { { 3,4,5,4,2,4,5 } }).Transpose();

            var sm = new SimplexMethodDualModification(a, b, c, baseIndexes, dMin, dMax);
            Matrix pseudo = null;
            bool isSolved = sm.Solve(out pseudo);
            PrintSolution(isSolved, c, pseudo);
        }