Beispiel #1
0
        //when we merge populations together, often the population will overflow, and we need to cut
        //it down. to do so, we just remove the last x individuals, which will be in the less significant
        //pareto fronts
        public GenomeList truncatePopulation(int size)
        {
            int to_remove = population.Count - size;

            Console.WriteLine("population size before: " + population.Count);
            Console.WriteLine("removing " + to_remove);
            if (to_remove > 0)
            {
                population.RemoveRange(size, to_remove);
            }
            Console.WriteLine("population size after: " + population.Count);

            return(population);
        }
        //when we merge populations together, often the population will overflow, and we need to cut
        //it down. to do so, we just remove the last x individuals, which will be in the less significant
        //pareto fronts
        // JUSTIN: Is that true? Is the population sorted before this point? I hope so.
        // TODO: Check that.
        public GenomeList truncatePopulation(int size)
        {
            int to_remove = population.Count - size;

            //Console.WriteLine("population size before: " + population.Count);
            //Console.WriteLine("removing " + to_remove);
            if (to_remove > 0)
            {
                population.RemoveRange(size, to_remove);
            }
            //Console.WriteLine("population size after: " + population.Count);

            /*foreach (IGenome aye in population)
             * {
             *  Console.Write(aye.Fitness + " : [" + aye.RealFitness + "] : ");
             *  foreach (double d in aye.objectives) Console.Write(d + " ");
             *  Console.WriteLine();
             * }//*/
            return(population);
        }