Ensure sorted not needed.

The problem was not appending old chromosomes to the front of the next population during survivor selection.
This commit is contained in:
SimpleArt
2020-11-27 19:13:37 -05:00
parent 1197447d7e
commit e54824238b

View File

@ -35,17 +35,6 @@ def check_gene_mutation_rate(individual_method):
return new_method
def ensure_sorted(population_method):
"""Sorts the population by fitness before running."""
def new_method(ga):
ga.population.sort_by_best_fitness(ga)
population_method(ga)
return new_method
def loop_selections(population_method):
"""Runs the population method until enough chromosomes are mutated."""
@ -78,7 +67,6 @@ class Mutation_Methods:
# Private method decorators, see above.
_check_chromosome_mutation_rate = check_chromosome_mutation_rate
_check_gene_mutation_rate = check_gene_mutation_rate
_ensure_sorted = ensure_sorted
_loop_selections = loop_selections
_loop_mutations = loop_mutations
@ -96,7 +84,6 @@ class Mutation_Methods:
@check_chromosome_mutation_rate
@ensure_sorted
@loop_selections
def random_avoid_best(ga):
"""Selects random chromosomes while avoiding the best chromosomes. (Elitism)"""