public SelectBasIndForm(int varCount, int eqCount, MsMethod method) { InitializeComponent(); this.varCount = varCount; this.eqCount = eqCount; this.method = method; for (int i = 0; i < varCount; i++) { bool chkState = false; if (i < eqCount) { chkState = true; } clbBasInd.Items.Add(i, chkState); } }
private void doCalculateToolStripMenuItem_Click(object sender, EventArgs e) { if (ReadData() == false) { return; } if (cbMax.Checked == false) { for (int i = 0; i < varCount; i++) { C.Elements[0, i] *= -1; } cCoeff *= -1; } lbIters.Items.Clear(); webBrowser1.DocumentText = "<P>Вычисления прерваны</P>"; MsMethod m = new MsMethod(Ps, b, C, cCoeff); SelectBasIndForm sForm = new SelectBasIndForm(varCount, eqCount, m); if (sForm.ShowDialog() == DialogResult.Cancel) { return; } int[] basInd = sForm.GetBasInd(); m = new MsMethod(Ps, b, C, cCoeff); try { m.SetBasis(basInd); while (m.DoIteration()) { ; } } catch (Exception ex) { MessageBox.Show("Вычисления прерваны: " + ex.Message, "Прерывание вычислений", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } states = m.states; lbIters.SuspendLayout(); for (int i = 0; i < states.Count; i++) { IterationState s = states[i] as IterationState; int iterNum = i + 1; string str = iterNum.ToString(); if (s.isDecisionLegal) { str += " (F = " + s.GetFuncValue().ToString() + ", допустимое решение)"; } else { str += " (F = " + s.GetFuncValue().ToString() + ", недопустимое решение)"; } lbIters.Items.Add(str); } lbIters.ResumeLayout(); webBrowser1.DocumentText = (m.states[0] as IterationState).GetReport(); tabControl1.SelectedIndex = 1; if (cbMax.Checked == false) { MessageBox.Show("Поскольку требуется минимизация, " + "целевая функция была умножена на -1, и далее " + "произведена максимизация", "Целевая функция умножена на -1", MessageBoxButtons.OK, MessageBoxIcon.Information); } }