AForge.Genetic.Population.Selection C# (CSharp) Метод

Selection() публичный Метод

Do selection.
The method applies selection operator to the current population. Using specified selection algorithm it selects members to the new generation from current generates and adds certain amount of random members, if is required (see RandomSelectionPortion).
public Selection ( ) : void
Результат void
        public virtual void Selection( )
        {
            // amount of random chromosomes in the new population
            int randomAmount = (int) ( randomSelectionPortion * size );

            // do selection
            selectionMethod.ApplySelection( population, size - randomAmount );

            // add random chromosomes
            if ( randomAmount > 0 )
            {
                IChromosome ancestor = population[0];

                for ( int i = 0; i < randomAmount; i++ )
                {
                    // create new chromosome
                    IChromosome c = ancestor.CreateNew( );
                    // calculate it's fitness
                    c.Evaluate( fitnessFunction );
                    // add it to population
                    population.Add( c );
                }
            }

            FindBestChromosome( );
        }