public static Offspring <TIndividual> Eagerly <TIndividual>(this Offspring <TIndividual> offspring) { if (offspring is null) { throw new ArgumentNullException(nameof(offspring)); } return(offspring.WithChildren(offspring.Children.ToArray())); }
public static Offspring <TIndividual> SelectSurvivors <TIndividual>(this Offspring <TIndividual> offspring, int count) { if (offspring is null) { throw new ArgumentNullException(nameof(offspring)); } var fitness = offspring.ParentPopulation.Fitness; var children = offspring.Children .OrderBy(fitness) .Take(count); return(offspring.WithChildren(children)); }
public static Offspring <TIndividual> AddChildren <TIndividual>(this Offspring <TIndividual> offspring, IEnumerable <TIndividual> children) { if (offspring is null) { throw new ArgumentNullException(nameof(offspring)); } if (children is null) { throw new ArgumentNullException(nameof(children)); } var c = offspring .Children .Concat(children); return(offspring.WithChildren(c)); }