Ejemplo n.º 1
0
 private static void PrintEndPopulationStats(Population finalPopulation, EvolveConfig config, IndividualConfig individualConfig)
 {
     Console.WriteLine("Final population fitness {0}", finalPopulation.Grade());
     Console.WriteLine("Accepted values:");
     finalPopulation.Individuals.Where(i => Math.Round((i as Individual).Sum, config.Precision) == Math.Round(individualConfig.Target, config.Precision))
                                .GroupBy(i => i.ToString())
                                .ForEach(i => Console.WriteLine("{0} indiviuals {1} sum to {2}", i.Count(), i.First(), (i.First() as Individual).Sum));
 }
Ejemplo n.º 2
0
        private bool ShouldEvolve(Population population)
        {
            var grade = population.Grade();

            Console.WriteLine(grade);

            return Math.Round(grade, Config.Precision) != Math.Round(0.0, Config.Precision);
        }
Ejemplo n.º 3
0
        public Population Evolve()
        {
            var population = new Population(Config);

            while(ShouldEvolve(population))
            {
                population = Evolve(population);
            }

            return population;
        }
Ejemplo n.º 4
0
 private Population Evolve(Population current)
 {
     return new Population(current.NextGeneration(), Config);
 }