src/GenFx/ElitismStrategy.cs
/// <summary>
/// Returns the collection of <see cref="GeneticEntity"/> objects from the <paramref name="population"/>
/// that are to be treated as elite and move on to the next generation unchanged.
/// </summary>
/// <param name="population"><see cref="Population"/> containing the <see cref="GeneticEntity"/> objects
/// from which to select.</param>
/// <returns>The collection of <see cref="GeneticEntity"/> objects from the <paramref name="population"/>
/// that are to be treated as elite.</returns>
/// <remarks>
/// <para>
/// The default implementation of this method is to use the <see cref="ElitismStrategy.ElitistRatio"/>
/// property to determine how many <see cref="GeneticEntity"/> objects are chosen to be elite.  Those <see cref="GeneticEntity"/>
/// objects with the highest <see cref="GeneticEntity.ScaledFitnessValue"/> are chosen.
/// </para>
/// </remarks>
/// <exception cref="ArgumentNullException"><paramref name="population"/> is null.</exception>
Returns the collection of  objects from the
that are to be treated as elite and move on to the next generation unchanged.
Returns the collection of objects from the that are to be treated as elite and move on to the next generation unchanged .
protected virtual IList<GeneticEntity> GetEliteGeneticEntitiesCore(Population population)
        {
            if (population == null)
            {
                throw new ArgumentNullException(nameof(population));
            }
            this.AssertIsInitialized();
            int elitistCount = Convert.ToInt32(Math.Round(this.ElitistRatio * population.Entities.Count));
            List<GeneticEntity> geneticEntities = new List<GeneticEntity>();
            if (elitistCount > 0)
            {
                GeneticEntity[] sorted = population.Entities.GetEntitiesSortedByFitness(
                    this.Algorithm!.SelectionOperator!.SelectionBasedOnFitnessType,
                    this.Algorithm!.FitnessEvaluator!.EvaluationMode).ToArray();
                for (int i = sorted.Length - elitistCount; i < sorted.Length; i++)
                {
                    geneticEntities.Add(sorted[i]);
                }
            }
            return geneticEntities;
        }
protected virtual IList < GeneticEntity > GetEliteGeneticEntitiesCore ( Population population ) { if ( population == null ) { throw new ArgumentNullException ( nameof ( population ) ) ; } this . AssertIsInitialized ( ) ; int elitistCount = Convert . ToInt32 ( Math . Round ( this . ElitistRatio * population . Entities . Count ) ) ; List < GeneticEntity > geneticEntities = new List < GeneticEntity > ( ) ; if ( elitistCount > 0 ) { GeneticEntity [ ] sorted = population . Entities . GetEntitiesSortedByFitness ( this . Algorithm ! . SelectionOperator ! . SelectionBasedOnFitnessType , this . Algorithm ! . FitnessEvaluator ! . EvaluationMode ) . ToArray ( ) ; for ( int i = sorted . Length - elitistCount ; i < sorted . Length ; i ++ ) { geneticEntities . Add ( sorted [ i ] ) ; } } return geneticEntities ; }
Returns the collection of  objects from the
that are to be treated as elite and move on to the next generation unchanged.
Returns the collection of objects from the that are to be treated as elite and move on to the next generation unchanged .
The collection of  objects from the
that are to be treated as elite.
The collection of objects from the that are to be treated as elite .
None
population
Population
containing the  objects
from which to select.
containing the objects from which to select .
remarks
The default implementation of this method is to use the
property to determine how many  objects are chosen to be elite.  Those
objects with the highest  are chosen.
The default implementation of this method is to use the property to determine how many objects are chosen to be elite . Those objects with the highest are chosen .