Added copies for external access of function decorators

This commit is contained in:
SimpleArt
2020-11-19 23:25:33 -05:00
parent 3d10adb2d9
commit 965ad352a6
4 changed files with 25 additions and 6 deletions

View File

@ -18,6 +18,12 @@ def values_to_chromosome(crossover_method):
class Crossover_Methods:
def __append_children_from_mating_pool(crossover_method):
return append_children_from_mating_pool(crossover_method)
def __values_to_chromosome(crossover_method):
return values_to_chromosome(crossover_method)
class Population:
"""Methods for selecting chromosomes to crossover."""

View File

@ -23,6 +23,12 @@ def loop_mutations(mutation_method):
class Mutation_Methods:
def __loop_selections(selection_method):
return loop_selections(selection_method)
def __loop_mutations(mutation_method):
return loop_mutations(mutation_method)
class Population:
"""Methods for selecting chromosomes to mutate"""

View File

@ -27,6 +27,13 @@ def ensure_sorted(selection_method):
class Parent_Selection:
def __check_selection_probability(selection_method):
return check_selection_probability(selection_method)
def __check_positive_fitness(selection_method):
return check_positive_fitness(selection_method)
def __ensure_sorted(selection_method):
return ensure_sorted(selection_method)
class Rank:

View File

@ -1,13 +1,13 @@
import random
def append_to_next_population(survivor_method):
return lambda ga: ga.population.append_children(survivor_method(ga))
class Survivor_Selection:
"""Survivor selection determines which individuals should be brought to the next generation"""
def __append_to_next_population(survivor_method):
return lambda ga: ga.population.append_children(survivor_method(ga))
@append_to_next_population
@__append_to_next_population
def fill_in_best(ga):
"""Fills in the next population with the best chromosomes from the last population"""
@ -15,7 +15,7 @@ class Survivor_Selection:
return ga.population[:needed_amount]
@append_to_next_population
@__append_to_next_population
def fill_in_random(ga):
"""Fills in the next population with random chromosomes from the last population"""
@ -23,7 +23,7 @@ class Survivor_Selection:
return [random.choice(ga.population) for n in range(needed_amount)]
@append_to_next_population
@__append_to_next_population
def fill_in_parents_then_random(ga):
"""Fills in the next population with all parents followed by random chromosomes from the last population"""