Esempio n. 1
0
 def test_mu_plus_lambda(self):
     """ Tests that replacement 'mu plus lambda' works as expected """
     self.config.replacement_type = ReplacementType.MU_PLUS_LAMBDA
     p = Population(self.samples, self.grammar, self.stats)
     mating_pool = p.selection(p.generation)
     p.offspring = p.recombination(mating_pool, p.generation)
     p.generation, p.offspring = p.replacement(p.generation, p.offspring)
     super().assertListEqual(p.offspring, [])
Esempio n. 2
0
 def test_mu_lambda_no_elite(self):
     """ Tests that replacement 'mu lambda without elitism' works as expected """
     self.config.replacement_type = ReplacementType.MU_LAMBDA_WITHOUT_ELITISM
     p = Population(self.samples, self.grammar, self.stats)
     mating_pool = p.selection(p.generation)
     p.offspring = p.recombination(mating_pool, p.generation)
     p.generation, p.offspring = p.replacement(p.generation, p.offspring)
     super().assertListEqual(p.offspring, [])
Esempio n. 3
0
 def test_random_one_point_crossover(self):
     """ Test that crossover 'random one point' works as expected """
     self.config.max_generations = 3
     self.config.fitness_function_type = FitnessType.BASIC
     self.config.selection_type = SelectionType.BINARY_TOURNAMENT
     self.config.recombination_type = RecombinationType.RANDOM_ONE_POINT_CROSSOVER
     p = Population(self.samples, self.grammar, self.stats)
     mating_pool = p.selection(p.generation)
     p.offspring = p.recombination(mating_pool, p.generation)
     super().assertNotEqual(p.generation, p.offspring)