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

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

Mutation operator.

The method performs chromosome's mutation, adding random number to chromosome's gene or multiplying the gene by random number. These random numbers are generated with help of mutation multiplier and mutation addition generators.

The exact type of mutation applied to the particular gene is selected randomly each time and depends on MutationBalancer. Before mutation is done a random number is generated in [0, 1] range - if the random number is smaller than MutationBalancer, then multiplication mutation is done, otherwise addition mutation.

public Mutate ( ) : void
Результат void
        public override void Mutate( )
        {
            int mutationGene = rand.Next( length );

            if ( rand.NextDouble( ) < mutationBalancer )
            {
                val[mutationGene] *= mutationMultiplierGenerator.Next( );
            }
            else
            {
                val[mutationGene] += mutationAdditionGenerator.Next( );
            }
        }