Example #1
0
        public Individual reproduceBest(Individual[] pop)
        {
            /*
             * apply crossover and mutation to top individuals in the population
             * return the new individual
             */
            Individual p1        = selectBest(pop);
            Individual prototype = new Individual(p1);

            if (rnd.NextDouble() < crossoverProb)
            {
                Individual p2 = selectBest(pop);
                prototype = prototype.crossover2(p2);
            }

            if (rnd.NextDouble() < mutationProb)
            {
                prototype = prototype.mutate();
            }
            return(prototype);
        }