示例#1
0
        public bool ValidPivotColRow(int pivotCol, int pivotRow)
        {
            bool result = true;

            if ((currentSimplexTable >= 0) & (currentSimplexTable < SimplexTables.Count))
            {
                SimplexTable currentsmptbl = SimplexTables[currentSimplexTable];

                currentsmptbl.CalcMeritRestrictions(pivotCol);

                result = currentsmptbl.MRVector(pivotRow) >= 0;
            }

            return(result);
        }
示例#2
0
        public void SetPivotColRow(int col, int row)
        {
            if (SimplexGrid.Visible)
            {
                for (int i = 0; i < SimplexGrid.RowCount; i++)
                {
                    for (int j = 0; j < SimplexGrid.ColumnCount; j++)
                    {
                        SimplexGrid[j, i].Style.BackColor = Color.White;
                    }
                }

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

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

                    if ((currentSimplexTable >= 0) & (currentSimplexTable < SimplexTables.Count))
                    {
                        SimplexTable currentsmptbl = SimplexTables[currentSimplexTable];

                        int PivotCol = col + 1;
                        int PivotRow = row + 1;

                        currentsmptbl.CalcMeritRestrictions(PivotCol);

                        if ((PivotRow != -1) & (PivotCol != -1))
                        {
                            for (int i = 0; i < currentsmptbl.M; i++)
                            {
                                if (currentsmptbl.MRVector(i) < 0)
                                {
                                    SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = "Не огр.";
                                }
                                else
                                {
                                    SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = currentsmptbl.MRVector(i);
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < currentsmptbl.M; i++)
                            {
                                SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = "";
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < SimplexGrid.RowCount - 1; i++)
                    {
                        SimplexGrid[SimplexGrid.ColumnCount - 1, i].Value = "";
                    }
                }
            }
        }
示例#3
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);
            }
        }