Evolution/Evolution/Alterers/SwapAlterer.cs
/// <summary>
/// Returns the result of applying the alterer over the individuals.
/// This alterer returns al list of the parents, modified or not.
/// </summary>
/// <param name="parents">The parents.</param>
/// <returns></returns>
Returns the result of applying the alterer over the individuals.
This alterer returns al list of the parents, modified or not.
Returns the result of applying the alterer over the individuals . This alterer returns al list of the parents modified or not .
public IList<Individual<G, F>> Apply(IList<Individual<G, F>> parents)
        {
            List<G> offspring = new List<G>(parents.Select(g => g.Genotype));
            int numberOfMutations = (int) (parents.Count*Probability);
            foreach (
                int location in RandomGenerator.GetInstance().IntSequence(0, offspring.Count).Take(numberOfMutations))
            {
                offspring[location] = Mutate(offspring[location]);
            }
            return Individual<G, F>.FromGenotypes(offspring).ToList();
        }
public IList < Individual < G , F > > Apply ( IList < Individual < G , F > > parents ) { List < G > offspring = new List < G > ( parents . Select ( g => g . Genotype ) ) ; int numberOfMutations = ( int ) ( parents . Count * Probability ) ; foreach ( int location in RandomGenerator . GetInstance ( ) . IntSequence ( 0 , offspring . Count ) . Take ( numberOfMutations ) ) { offspring [ location ] = Mutate ( offspring [ location ] ) ; } return Individual < G , F > . FromGenotypes ( offspring ) . ToList ( ) ; }
Returns the result of applying the alterer over the individuals.
Returns the result of applying the alterer over the individuals .
None
parents
IList<Individual<G, F>>
None