Example #1
0
        // Обновление UpdateGrid в соответствии с текущей симплекс таблицей
        private void UpdateSimplexGrid()
        {
            if ((currentSimplexTable >= 0) & (currentSimplexTable < SimplexTables.Count))
            {
                SimplexTable smptbl = SimplexTables[currentSimplexTable];

                Mainpanel.Visible = true;

                SimplexGrid.RowCount    = smptbl.M + 1;
                SimplexGrid.ColumnCount = smptbl.N + smptbl.M + 2;

                SimplexGrid.Columns[0].HeaderText = "b";

                for (int i = 1; i < SimplexGrid.ColumnCount - 1; i++)
                {
                    SimplexGrid.Columns[i].HeaderText = "x" + i.ToString();
                }

                SimplexGrid.Columns[SimplexGrid.ColumnCount - 1].HeaderText = "O.O";

                for (int i = 0; i < SimplexGrid.RowCount - 1; i++)
                {
                    SimplexGrid.Rows[i].HeaderCell.Value = "x" + smptbl.BaseVector(i);
                }

                if (TaskTypeComboBox.SelectedIndex == 0)
                {
                    SimplexGrid.Rows[SimplexGrid.RowCount - 1].HeaderCell.Value = "Fmax";
                }
                else
                {
                    SimplexGrid.Rows[SimplexGrid.RowCount - 1].HeaderCell.Value = "Fmin";
                }

                for (int i = 0; i < SimplexGrid.RowCount; i++)
                {
                    for (int j = 0; j < SimplexGrid.ColumnCount; j++)
                    {
                        SimplexGrid[j, i].Style.BackColor = Color.White;
                    }
                }

                if (smptbl.PivotRow != -1)
                {
                    for (int i = 0; i < SimplexGrid.ColumnCount; i++)
                    {
                        SimplexGrid[i, smptbl.PivotRow].Style.BackColor = Color.LightYellow;
                    }
                }

                if (smptbl.PivotCol != -1)
                {
                    for (int i = 0; i < SimplexGrid.RowCount; i++)
                    {
                        SimplexGrid[smptbl.PivotCol, i].Style.BackColor = Color.LightYellow;
                    }

                    smptbl.CalcMeritRestrictions(smptbl.PivotCol);
                }

                if ((smptbl.PivotRow != -1) & (smptbl.PivotCol != -1))
                {
                    for (int i = 0; i < smptbl.M; i++)
                    {
                        if (smptbl.MRVector(i) < 0)
                        {
                            SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = "Не огр.";
                        }
                        else
                        {
                            SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = smptbl.MRVector(i);
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < smptbl.M; i++)
                    {
                        SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = "";
                    }
                }

                smptbl.PrintTable(SimplexGrid);
            }
        }