/// <summary> /// Копирование значений объекта родительского класса /// </summary> /// <param name="_algorithmSetting">Объект родительского класса</param> public void RefreshValues(AlgorithmSetting _algorithmSetting) { foreach (var prop in _algorithmSetting.GetType().GetProperties()) { if (this.GetType().GetProperty(prop.Name).Name != "IsOnlyPositive") { this.GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue(_algorithmSetting, null), null); } } }
/// <summary> /// Получение средней особи для метода селекции /// </summary> /// <returns>Средняя особь</returns> public Candidate GetAvgBestCandidate(List <Candidate> candidateList) { var avgBestCandidate = new Candidate(); var avgDecValue = Convert.ToInt32(candidateList.Average(c => c.DecValue)); avgBestCandidate.DecValue = avgDecValue; avgBestCandidate.Chromosome = new Chromosome(MathConvert.ConvertFromDecToBin(avgDecValue, AlgorithmSetting.IsOnlyPositive)); avgBestCandidate.Fitness = AlgorithmSetting.CalcFunction(Convert.ToDouble(avgDecValue)); return(avgBestCandidate); }
public AnalysisSetting(AlgorithmSetting _algorithmSetting) : base() { RefreshValues(_algorithmSetting); }