示例#1
0
        public List <AlgorithmFirstStepModel> GenerateFirstStep()
        {
            _chartModel = new ChartModel();
            var model = new List <AlgorithmFirstStepModel>();

            _converter.SetParameters(_parameters);
            var generatedNumbers = GetRandomNumbers(_parameters.RangeFrom, _parameters.RangeTo, _parameters.PopulationSize, _parameters.Precision.IntValue);

            for (int i = 1; i <= _parameters.PopulationSize; i++)
            {
                model.Add(new AlgorithmFirstStepModel()
                {
                    Id = i, RealValue = generatedNumbers[i - 1]
                });
            }
            foreach (AlgorithmFirstStepModel data in model)
            {
                data.IntValue       = _converter.RealToIntConvert(data.RealValue);
                data.BinaryValue    = _converter.IntToBinaryConvert(data.IntValue);
                data.Int2Value      = _converter.BinaryToIntConvert(data.BinaryValue);
                data.Real2Value     = _converter.IntToRealConvert(data.Int2Value);
                data.FunctionResult = GetFunctionResult(data.RealValue);
            }
            return(model);
        }