//Вычисления значения ограничения protected double calculateRestrictFunction(MatrixItem item, Chromosome Chr) { double value = 0; for (int i = 0; i < _countGenChromosome; i++) { value += item.items[i] * Chr.gens[i]; } return value; }
private bool readMassive() { _container = new ContainerFunction(); for (int i = 1; i <= _countValueRestrict; i++) { MatrixItem item = new MatrixItem(); for (int j = 1; j <= _countValueVariable; j++) { if (_masTextRestrict[i, j].Text == "") { MessageBox.Show(MESSAGE_EMPTY_TEXT); return false; } if (!(validateDouble(_masTextRestrict[i, j].Text))) { MessageBox.Show(MESSAGE_CORRECT_NUM); return false; } item.addItem(Convert.ToDouble(_masTextRestrict[i, j].Text)); item.Sign = _masTextRestrictSignBut[i].Text; } if (_masTextRestrictResult[i].Text == "") { MessageBox.Show(MESSAGE_EMPTY_TEXT); return false; } if (!(validateDouble(_masTextRestrictResult[i].Text))) { MessageBox.Show(MESSAGE_CORRECT_NUM); return false; } item.restriction = Convert.ToDouble(_masTextRestrictResult[i].Text); _container.matrix.Add(item); } for (int i = 1; i <= _countValueVariable; i++) { if (_masTextFunction[i].Text == "") { MessageBox.Show(MESSAGE_EMPTY_TEXT); return false; } if (!(validateDouble(_masTextFunction[i].Text))) { MessageBox.Show(MESSAGE_EMPTY_TEXT); return false; } _container.fitness.Add(Convert.ToDouble(_masTextFunction[i].Text)); } _container.cursor = this.butMaxMin.Text ; return true; }