public virtual void UpdateTestMeasure(IECChromosome chromosome, ECTestMeasure testMeasure)
        {
            //checks and gets chromosome history
            if (!this.Contains(chromosome))
            {
                return;
            }
            var prevTestMeasure = (ECTestMeasure)this.testMeasures[chromosome];

            //updates generation number (sets to the youngest between the two)
            if (chromosome.Population != null)
            {
                prevTestMeasure.GenerationNumber =
                    Math.Min(prevTestMeasure.GenerationNumber, chromosome.Population.GenerationNumber);
            }

            //averages chromosome fitness with new quantity info
            if (testMeasure != null)
            {
                prevTestMeasure.Value = 0.5f * (prevTestMeasure.Value + testMeasure.Value);
            }

            //increases generation counter
            prevTestMeasure.TimesGenerated++;
        }
Пример #2
0
 public ECOptimizationTest(
     string id, IECTestsConfig testsConfig, IECChromosome ancestor, FitnessFunction fitnessFunction)
     : base(id, testsConfig)
 {
     this.population = new ECPopulation(testsConfig, ancestor, fitnessFunction);
     this.RandomProportionProgress = new StatisticalQuantity(testsConfig.MaxIterations);
 }
Пример #3
0
 public virtual int CompareTo(IECChromosome chromosome)
 {
     if (!(chromosome is ECChromosome))
     {
         return(-1);
     }
     return(this.Population == chromosome.Population ? 0 : -1);
 }
 public int CompareTo(IECChromosome chromosome)
 {
     if (!(chromosome is SocialGPChromosome))
     {
         return(-1);
     }
     return(this.Population == chromosome.Population
         ? -this.Fitness.CompareTo(chromosome.Fitness)
         : -1);
 }
Пример #5
0
 public override int CompareTo(IECChromosome chromosome)
 {
     if (!(chromosome is GPChromosome))
     {
         return(-1);
     }
     return
         (this.Population == chromosome.Population
             ? this.Length.CompareTo(((GPChromosome)chromosome).Length)
             : -1);
 }
 public void Add(IECChromosome chromosome, ECTestMeasure testMeasure)
 {
     //locks from outside access
     lock (this.locker)
     {
         //changes some parameters of the stored chromosome history
         if (!this.Contains(chromosome))
         {
             base.Add(chromosome, testMeasure);
         }
         else
         {
             this.UpdateTestMeasure(chromosome, testMeasure);
         }
     }
 }
Пример #7
0
        public ECPopulation(
            IECTestsConfig testsConfig, IECChromosome ancestor, FitnessFunction fitnessFunction) :
            base(testsConfig.NumTestsPerIteration, ancestor, fitnessFunction, testsConfig.SelectionMethod)
        {
            this.testsConfig = testsConfig;

            //sets population ref to all chromosomes
            ancestor.Population = this;
            for (var i = 0; i < this.Size; i++)
            {
                ((IECChromosome)this[i]).Population = this;
            }

            //default values
            this.CrossoverRate          = DEFAULT_CROSSOVER_RATE;
            this.MutationRate           = DEFAULT_MUTATION_RATE;
            this.RandomSelectionPortion = testsConfig.RandomSelectionPortion;
        }
 public void UpdateTestMeasure(IECChromosome chromosome)
 {
     this.UpdateTestMeasure(chromosome, null);
 }