src/GenFx.Components/SelectionOperators/RankSelectionOperator.cs
/// <summary>
/// Selects the specified number of <see cref="GeneticEntity"/> objects from <paramref name="population"/>.
/// </summary>
/// <param name="entityCount">Number of <see cref="GeneticEntity"/> objects to select from the population.</param>
/// <param name="population"><see cref="Population"/> containing the <see cref="GeneticEntity"/> objects from which to select.
/// objects from which to select.</param>
/// <returns>The <see cref="GeneticEntity"/> object that was selected.</returns>
Selects the specified number of  objects from .
Selects the specified number of objects from .
protected override IEnumerable<GeneticEntity> SelectEntitiesFromPopulation(int entityCount, Population population)
        {
            if (population == null)
            {
                throw new ArgumentNullException(nameof(population));
            }
            this.AssertIsInitialized();
            GeneticEntity[] sortedEntities = population.Entities.GetEntitiesSortedByFitness(
                this.SelectionBasedOnFitnessType,
                this.Algorithm!.FitnessEvaluator!.EvaluationMode).ToArray();
            List<WheelSlice> wheelSlices = new List<WheelSlice>(sortedEntities.Length);
            for (int i = 0; i < sortedEntities.Length; i++)
            {
                wheelSlices.Add(new WheelSlice(sortedEntities[i], i + 1));
            }
            List<GeneticEntity> result = new List<GeneticEntity>();
            for (int i = 0; i < entityCount; i++)
            {
                result.Add(RouletteWheelSampler.GetEntity(wheelSlices));
            }
            return result;
        }
protected override IEnumerable < GeneticEntity > SelectEntitiesFromPopulation ( int entityCount , Population population ) { if ( population == null ) { throw new ArgumentNullException ( nameof ( population ) ) ; } this . AssertIsInitialized ( ) ; GeneticEntity [ ] sortedEntities = population . Entities . GetEntitiesSortedByFitness ( this . SelectionBasedOnFitnessType , this . Algorithm ! . FitnessEvaluator ! . EvaluationMode ) . ToArray ( ) ; List < WheelSlice > wheelSlices = new List < WheelSlice > ( sortedEntities . Length ) ; for ( int i = 0 ; i < sortedEntities . Length ; i ++ ) { wheelSlices . Add ( new WheelSlice ( sortedEntities [ i ] , i + 1 ) ) ; } List < GeneticEntity > result = new List < GeneticEntity > ( ) ; for ( int i = 0 ; i < entityCount ; i ++ ) { result . Add ( RouletteWheelSampler . GetEntity ( wheelSlices ) ) ; } return result ; }
Selects the specified number of  objects from .
Selects the specified number of objects from .
The  object that was selected.
The object that was selected .
entityCount
int
Number of  objects to select from the population.
Number of objects to select from the population .
population
Population
containing the  objects from which to select.
objects from which to select.
containing the objects from which to select . objects from which to select .