public void SetResult(LppResult result) { coordinatesDataGrid.Rows.Clear(); coordinatesDataGrid.Columns.Clear(); if (result.Coordinates == null) { tfUnlimitedRadio.Select(); return; } if (result.Value == null) { setIncompatibleRadio.Select(); return; } successRadio.Select(); foreach (var variable in result.Coordinates.Keys) coordinatesDataGrid.Columns.Add(variable, variable); coordinatesDataGrid.Rows.Add(); var i = 0; foreach (var variable in result.Coordinates.Keys) coordinatesDataGrid.Rows[0].Cells[i++].Value = result.Coordinates[variable]; tfValueTextBox.Text = result.Value.ToString(); }
/// <summary> /// Returs true if result is whole /// </summary> protected bool IsWhole(LppResult result, ProblemForGomory problem) { foreach (var variable in result.Coordinates) if (variable.Value.Denominator != 1 && problem.WholeConstraints.Contains(variable.Key)) return false; return true; }
/// <summary> /// Returns true if result of weakened problem solving is result of initial problem solving /// </summary> public bool IsEnd(LppResult result, ProblemForGomory problem) { return result.Value == null || IsWhole(result, problem); }
private Fraction GetReplacedVariableValue(string label, LppResult normalizedProblemResult) { var positiveLab = Replacements[label].Key; var negativeLab = Replacements[label].Value; var positive = new Fraction(); var negative = new Fraction(); if (normalizedProblemResult.Coordinates.Keys.Contains(positiveLab)) positive += normalizedProblemResult.Coordinates[positiveLab]; if (normalizedProblemResult.Coordinates.Keys.Contains(negativeLab)) negative += normalizedProblemResult.Coordinates[negativeLab]; return positive - negative; }