Added copies for external access of function decorators
This commit is contained in:
@ -18,6 +18,12 @@ def values_to_chromosome(crossover_method):
|
|||||||
|
|
||||||
class Crossover_Methods:
|
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:
|
class Population:
|
||||||
"""Methods for selecting chromosomes to crossover."""
|
"""Methods for selecting chromosomes to crossover."""
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,12 @@ def loop_mutations(mutation_method):
|
|||||||
|
|
||||||
class Mutation_Methods:
|
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:
|
class Population:
|
||||||
"""Methods for selecting chromosomes to mutate"""
|
"""Methods for selecting chromosomes to mutate"""
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,13 @@ def ensure_sorted(selection_method):
|
|||||||
|
|
||||||
class Parent_Selection:
|
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:
|
class Rank:
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
def append_to_next_population(survivor_method):
|
|
||||||
return lambda ga: ga.population.append_children(survivor_method(ga))
|
|
||||||
|
|
||||||
class Survivor_Selection:
|
class Survivor_Selection:
|
||||||
"""Survivor selection determines which individuals should be brought to the next generation"""
|
"""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):
|
def fill_in_best(ga):
|
||||||
"""Fills in the next population with the best chromosomes from the last population"""
|
"""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]
|
return ga.population[:needed_amount]
|
||||||
|
|
||||||
|
|
||||||
@append_to_next_population
|
@__append_to_next_population
|
||||||
def fill_in_random(ga):
|
def fill_in_random(ga):
|
||||||
"""Fills in the next population with random chromosomes from the last population"""
|
"""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)]
|
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):
|
def fill_in_parents_then_random(ga):
|
||||||
"""Fills in the next population with all parents followed by random chromosomes from the last population"""
|
"""Fills in the next population with all parents followed by random chromosomes from the last population"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user