Beispiel #1
0
        private Individual select(Individual[] pop)
        {
            /*
             * select random individual from the population for crossover operation
             */
            Individual i1 = pop[randomIndex(pop.Length)];
            Individual i2 = pop[randomIndex(pop.Length)];

            if (i1.compareTo(i2) <= 0)
            {
                return(i1);
            }
            else
            {
                return(i2);
            }
        }
Beispiel #2
0
        private Individual selectBest(Individual[] pop)
        {
            /*
             * select individuals from the top percentile of the population for crossover operation
             */
            Individual i1 = pop[randomIndex((int)(pop.Length * PERCENT))];
            Individual i2 = pop[randomIndex((int)(pop.Length * PERCENT))];

            if (i1.compareTo(i2) <= 0)
            {
                return(i1);
            }
            else
            {
                return(i2);
            }
        }