Evolution/Evolution/Alterers/CrossoverBase.cs
/// <summary>
/// Applies the crossover on the parents.
/// Is used to perform some basic validation before the implemented virtual method <see cref="GetOffspring"/> is called
/// </summary>
/// <param name="parents">The parents.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentException">
/// Parents should have same length
/// or
/// </exception>
Applies the crossover on the parents.
Is used to perform some basic validation before the implemented virtual method  is called
Applies the crossover on the parents . Is used to perform some basic validation before the implemented virtual method is called
public IList<Individual<G, F>> Apply(IList<Individual<G, F>> parents)
        {
            if (parents.Count() != NumberOfParentsNeeded)
                throw new ArgumentException($"Input expected {NumberOfParentsNeeded} parents");
            int count = parents[0].Genotype.Count;
            foreach (Individual<G, F> individual in parents)
            {
                if (SameLengthParentsNeeded && parents.Any(p => p.Genotype.Count != count))
                    throw new ArgumentException("Parents should have same length");
                if (MinimumGenesRequired > individual.Genotype.Count)
                    throw new ArgumentException($"Parents should have at least {MinimumGenesRequired} genes");
            }
            return Individual<G, F>.FromGenotypes(GetOffspring(parents.Select(g => g.Genotype)));
        }
public IList < Individual < G , F > > Apply ( IList < Individual < G , F > > parents ) { if ( parents . Count ( ) != NumberOfParentsNeeded ) throw new ArgumentException ( $" Input expected  { NumberOfParentsNeeded }  parents " ) ; int count = parents [ 0 ] . Genotype . Count ; foreach ( Individual < G , F > individual in parents ) { if ( SameLengthParentsNeeded && parents . Any ( p => p . Genotype . Count != count ) ) throw new ArgumentException ( " " ) ; if ( MinimumGenesRequired > individual . Genotype . Count ) throw new ArgumentException ( $" Parents should have at least  { MinimumGenesRequired }  genes " ) ; } return Individual < G , F > . FromGenotypes ( GetOffspring ( parents . Select ( g => g . Genotype ) ) ) ; }
Applies the crossover on the parents.
Applies the crossover on the parents .
None
Parents should have same length
or
Parents should have same length or
parents
IList<Individual<G, F>>
None