Fixed method names and added some crossover methods and tests for floats
This commit is contained in:
@ -6,22 +6,22 @@ class Survivor_Selection:
|
||||
def fill_in_best(ga, next_population):
|
||||
"""Fills in the next population with the best chromosomes from the last population"""
|
||||
|
||||
ga.population.set_all_chromosomes(ga.population.get_all_chromosomes()[:ga.population.size()-next_population.size()] + next_population.get_all_chromosomes())
|
||||
ga.population.set_chromosome_list(ga.population.get_chromosome_list()[:ga.population.size()-next_population.size()] + next_population.get_chromosome_list())
|
||||
|
||||
|
||||
def fill_in_random(ga, next_population):
|
||||
"""Fills in the next population with random chromosomes from the last population"""
|
||||
|
||||
ga.population.set_all_chromosomes([
|
||||
random.choice(ga.population.get_all_chromosomes())
|
||||
ga.population.set_chromosome_list([
|
||||
random.choice(ga.population.get_chromosome_list())
|
||||
for n in range(ga.population.size()-next_population.size())]
|
||||
+ next_population.get_all_chromosomes())
|
||||
+ next_population.get_chromosome_list())
|
||||
|
||||
|
||||
def fill_in_parents_then_random(ga, next_population):
|
||||
"""Fills in the next population with all parents followed by random chromosomes from the last population"""
|
||||
|
||||
ga.population.set_all_chromosomes([
|
||||
random.choice(ga.population.get_all_chromosomes())
|
||||
ga.population.set_chromosome_list([
|
||||
random.choice(ga.population.get_chromosome_list())
|
||||
for n in range(ga.population.size()-len(ga.population.get_mating_pool())-next_population.size())]
|
||||
+ ga.population.get_mating_pool() + next_population.get_all_chromosomes())
|
||||
+ ga.population.get_mating_pool() + next_population.get_chromosome_list())
|
||||
|
||||
Reference in New Issue
Block a user