private void оптимизироватьToolStripMenuItem_Click(object sender, EventArgs e) { try { DowndateGrid(); } catch { return; } Fraction F; Fraction[] solution; SimplexSolver solver = new SimplexSolver(); solver.DebugNewSimplexTable += new SimplexSolver.DebugSimplexTableHandler(solver_DebugNewSimplexTable); formTables = null; for (int i = 0; i < m; i++) { solver.AddLimtation(A[i], S[i], B[i]); } solver.SetTargetFunctionCoefficients(C); // решаем solution = solver.Solve(); F = 0; for (int i = 0; i < C.Length; i++) { F += C[i] * solution[i]; } formTables.AddLine("Решение (max):", solution); formTables.AddLine("Значение Fmax:", new Fraction[] { F }); // переделываем под минимизацию for (int i = 0; i < C.Length; i++) { C[i] = -C[i]; } solver.SetTargetFunctionCoefficients(C); formTables.ResetIterationCounter(); // снова решаем solution = solver.Solve(); F = 0; for (int i = 0; i < C.Length; i++) { F -= C[i] * solution[i]; } formTables.AddLine("Решение (min):", solution); formTables.AddLine("Значение Fmin:", new Fraction[] { F }); formTables.UpdateGrid(); }