static void Main(string[] args)
        {
            // int numberVariables, numberRestrictions;
            //
            // Console.WriteLine("Enter number of variables");
            // numberVariables = int.Parse(Console.ReadLine());
            //
            // Console.WriteLine("Enter number of restrictions");
            // numberRestrictions = int.Parse(Console.ReadLine());

            double[,] simplexTable;

            // simplexTable = GetTable(numberVariables, numberRestrictions);

            // simplexTable = new double[,] {
            //     {4, 1, 1, 0, 8},
            //     {-1, 1, 0, 1, 3},
            //     {3, 4, 0, 0, 0},
            // };

            simplexTable = new double[, ] {
                { 1, 2, 1, 0, 0, 4 },
                { 1, 1, 0, 1, 0, 3 },
                { 1, 1, 0, 0, 1, 8 },
                { 3, 4, 0, 0, 0, 0 },
            };

            SimplexMethod simplexMethod = new SimplexMethod(simplexTable);

            simplexMethod.Calculate();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double[] coefs = new double[varsCount];
            double[,] conditionsMatrix = new double[condsCount, varsCount + 1];

            for (int i = 0; i < varsCount; i++)
            {
                coefs[i] = Convert.ToDouble(dataGridView1.Rows[0].Cells[i].Value);
            }
            for (int i = 0; i < condsCount; i++)
            {
                for (int j = 0; j <= varsCount; j++)
                {
                    conditionsMatrix[i, j] = Convert.ToDouble(dataGridView2.Rows[i].Cells[j].Value);
                }
            }

            SimplexMethod method = new SimplexMethod(conditionsMatrix, coefs, basisIndexes.ToArray(), comboBox1.SelectedIndex == 0);

            method.Solve("result.txt");
        }