Evolution/Evolution/Alterers/BaseMutator.cs
/// <summary>
/// Returns the result of applying the alterer over the individuals.
/// </summary>
/// <param name="individuals">Input individuals</param>
/// <returns>
/// Output individuals
/// </returns>
Returns the result of applying the alterer over the individuals.
Returns the result of applying the alterer over the individuals .
public IList<Individual<G, F>> Apply(IList<Individual<G, F>> individuals)
        {
            IList<G> genotypes = individuals.Select(i => i.Genotype).ToList();
            int numberOfMutations = (int) Math.Round(genotypes.Sum(g => g.Count)*Probability);
            List<int> targets =
                RandomGenerator.GetInstance().IntSequence(0, genotypes.Count).Take(numberOfMutations).ToList();
            foreach (int genotypeNumber in targets)
            {
                G genotype = genotypes[genotypeNumber];
                G mutatedGenotype = MutateGene(genotype);
                genotypes[genotypeNumber] = mutatedGenotype;
            }
            return Individual<G, F>.FromGenotypes(genotypes);
        }
public IList < Individual < G , F > > Apply ( IList < Individual < G , F > > individuals ) { IList < G > genotypes = individuals . Select ( i => i . Genotype ) . ToList ( ) ; int numberOfMutations = ( int ) Math . Round ( genotypes . Sum ( g => g . Count ) * Probability ) ; List < int > targets = RandomGenerator . GetInstance ( ) . IntSequence ( 0 , genotypes . Count ) . Take ( numberOfMutations ) . ToList ( ) ; foreach ( int genotypeNumber in targets ) { G genotype = genotypes [ genotypeNumber ] ; G mutatedGenotype = MutateGene ( genotype ) ; genotypes [ genotypeNumber ] = mutatedGenotype ; } return Individual < G , F > . FromGenotypes ( genotypes ) ; }
Returns the result of applying the alterer over the individuals.
Returns the result of applying the alterer over the individuals .
None
individuals
IList<Individual<G, F>>
None