示例#1
0
 /// <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);
         }
     }
 }
示例#2
0
        /// <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);
        }
示例#3
0
 public AnalysisSetting(AlgorithmSetting _algorithmSetting) : base()
 {
     RefreshValues(_algorithmSetting);
 }