public SimplexTable(Decomposition decomposition, ObjectiveFunction objectiveFunction, ILogger logger = null, UserChoice userChoice = null, bool isDecimalFractions = false) { _decomposition = decomposition; _logger = logger; _userChoice = userChoice; _isDecimalFractions = isDecimalFractions; _shortObjectiveFunction = ConvertToShortObjectiveFunction(decomposition, objectiveFunction); }
public SimplexMethodSolver(ObjectiveFunction objectiveFunction, Matrix augmentedConstraintList, IEnumerable<int> cornerPoint = null, ILogger logger = null, ILogger loggerForArtBasic = null, UserChoice userChoice = null, UserChoice userChoiceForArtBasic = null, bool isDecimalFractions = false) { _objectiveFunction = objectiveFunction; _augmentedConstraintList = augmentedConstraintList; _logger = logger; _loggerForArtBasic = loggerForArtBasic; _userChoice = userChoice; _userChoiceForArtBasic = userChoiceForArtBasic; _isDecimalFractions = isDecimalFractions; _cornerPoint = cornerPoint as IReadOnlyList<int>; }
private void solveBtn_Click(object sender, EventArgs e) { _label.Text = string.Empty; _labelArtBasic.Text = string.Empty; // Получение коэффициентов целевой функции var objFunc = new List<Fraction>(); for (var i = 0; i < taskGridView.ColumnCount; i++) objFunc.Add(new Fraction(taskGridView.Rows[0].Cells[i].Value.ToString())); if (_isMaximize) objFunc = objFunc.Select(x => -1*x).ToList(); // Получение коэффициентов матрицы ограничений var matrix = new Fraction[constraintsGridView.RowCount, constraintsGridView.ColumnCount]; for (var i = 0; i < constraintsGridView.RowCount; i++) for (var j = 0; j < constraintsGridView.ColumnCount; j++) matrix[i, j] = new Fraction(constraintsGridView.Rows[i].Cells[j].Value.ToString()); // Получение опорных элементов заданных пользователем для симлекс метода var userChoice = new UserChoice(); for (var i = 0; i < bearingElemsTextBox.Lines.Length; i++) { var coords = bearingElemsTextBox.Lines[i].Split(' ', ',', ';'); userChoice.Choices.Add(i, coords.Select(s => Convert.ToInt32(s)).ToArray()); } // Получение опорных элементов заданных пользователем для искусственного базиса var userChoiceForArtBasic = new UserChoice(); for (var i = 0; i < bearingElemsArtBasicTextBox.Lines.Length; i++) { var coords = bearingElemsArtBasicTextBox.Lines[i].Split(' ', ',', ';'); userChoiceForArtBasic.Choices.Add(i, coords.Select(s => Convert.ToInt32(s)).ToArray()); } // Получение коэффициентов угловой точки var cornerPoint = new List<int>(); for (var i = 0; i < cornerPointGridView.ColumnCount; i++) { if (cornerPointGridView.Rows[0].Cells[i].Value != null) cornerPoint.Add((int) cornerPointGridView.Rows[0].Cells[i].Value); } // Решение задачи var solver = new SimplexMethodSolver( new ObjectiveFunction(objFunc), new Matrix(matrix), cornerPoint, new LabelLoger(_label), new LabelLoger(_labelArtBasic), userChoice, userChoiceForArtBasic, _isDecimalFractions); if (artBasicCheckBox.Checked) solver.SolveWithArtificialBasic(); else solver.Solve(); }