AForge.Genetic.Population.Mutate C# (CSharp) Метод

Mutate() публичный Метод

Do mutation in the population.
The method walks through the population and performs mutation operator taking each chromosome one by one. The total amount of mutated chromosomes is determined by mutation rate.
public Mutate ( ) : void
Результат void
        public virtual void Mutate( )
        {
            // mutate
            for ( int i = 0; i < size; i++ )
            {
                // generate next random number and check if we need to do mutation
                if ( rand.NextDouble( ) <= mutationRate )
                {
                    // clone the chromosome
                    IChromosome c = population[i].Clone( );
                    // mutate it
                    c.Mutate( );
                    // calculate fitness of the mutant
                    c.Evaluate( fitnessFunction );
                    // add mutant to the population
                    population.Add( c );
                }
            }
        }