From 965ad352a66b407ee17b3a78bc76fe53e84cea54 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 19 Nov 2020 23:25:33 -0500 Subject: [PATCH] Added copies for external access of function decorators --- src/crossover/crossover_methods.py | 6 ++++++ src/mutation/mutation_methods.py | 6 ++++++ src/parent_selection/parent_selection_methods.py | 7 +++++++ src/survivor_selection/survivor_selection_methods.py | 12 ++++++------ 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/crossover/crossover_methods.py b/src/crossover/crossover_methods.py index 96590be..8691493 100644 --- a/src/crossover/crossover_methods.py +++ b/src/crossover/crossover_methods.py @@ -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.""" diff --git a/src/mutation/mutation_methods.py b/src/mutation/mutation_methods.py index 911d7df..b4b2453 100644 --- a/src/mutation/mutation_methods.py +++ b/src/mutation/mutation_methods.py @@ -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""" diff --git a/src/parent_selection/parent_selection_methods.py b/src/parent_selection/parent_selection_methods.py index 4763e17..41e0433 100644 --- a/src/parent_selection/parent_selection_methods.py +++ b/src/parent_selection/parent_selection_methods.py @@ -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: diff --git a/src/survivor_selection/survivor_selection_methods.py b/src/survivor_selection/survivor_selection_methods.py index 8a75120..48d9128 100644 --- a/src/survivor_selection/survivor_selection_methods.py +++ b/src/survivor_selection/survivor_selection_methods.py @@ -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"""