AForge.Genetic.Population.RunEpoch C# (CSharp) Method

RunEpoch() public method

Run one epoch of the population.
The method runs one epoch of the population, doing crossover, mutation and selection by calling Crossover, Mutate and Selection.
public RunEpoch ( ) : void
return void
        public void RunEpoch( )
        {
            Crossover( );
            Mutate( );
            Selection( );

            if ( autoShuffling )
                Shuffle( );
        }

Usage Example

Example #1
0
        public static League sortTeamMembers(List<TeamMember> members, int numTeams)
        {
            League league = new League(members, numTeams);

            Population population = new Population(members.Count, league, new FitnessCalculator(), new EliteSelection());
            population.MutationRate = .5;
            population.CrossoverRate = .2;
            population.RunEpoch();
            //run epoch until you get the same best chromosome 10 times
            double bestFitness = -Double.MaxValue;
            int count = 0;
            while(count < 5000)
            {
                population.RunEpoch();
                double fitness = ((League)population.BestChromosome).getFitness();
                Console.WriteLine("Fitness: " + fitness);
                if (fitness > bestFitness)
                {
                    bestFitness = fitness;
                    count = 0;
                }
                else
                {
                    count++;
                }
            }

            //while (((League)population.BestChromosome).getFitness() != 80.0)
            //    population.RunEpoch();
            League best = ((League)population.BestChromosome);
            return best;
        }
All Usage Examples Of AForge.Genetic.Population::RunEpoch