Opted for single _ instead of double _
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
def append_children_from_mating_pool(crossover_method):
|
def append_children_to_next_population(crossover_method):
|
||||||
"""Appends the new chromosomes to the next population."""
|
"""Appends the new chromosomes to the next population."""
|
||||||
return lambda ga:\
|
return lambda ga:\
|
||||||
ga.population.append_children(
|
ga.population.append_children(
|
||||||
@ -29,11 +29,11 @@ def values_to_genes(crossover_method):
|
|||||||
class Crossover_Methods:
|
class Crossover_Methods:
|
||||||
|
|
||||||
# Private method decorators, see above.
|
# Private method decorators, see above.
|
||||||
def __append_children_from_mating_pool(crossover_method):
|
def _append_children_to_next_population(crossover_method):
|
||||||
return append_children_from_mating_pool(crossover_method)
|
return append_children_to_next_population(crossover_method)
|
||||||
def __genes_to_chromosome(crossover_method):
|
def _genes_to_chromosome(crossover_method):
|
||||||
return values_to_chromosome(crossover_method)
|
return values_to_chromosome(crossover_method)
|
||||||
def __values_to_genes(crossover_method):
|
def _values_to_genes(crossover_method):
|
||||||
return values_to_genes(crossover_method)
|
return values_to_genes(crossover_method)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,11 +22,11 @@ class Initialization_Methods:
|
|||||||
"""Initialization examples that are used as defaults and examples"""
|
"""Initialization examples that are used as defaults and examples"""
|
||||||
|
|
||||||
# Private method decorators, see above.
|
# Private method decorators, see above.
|
||||||
def __chromosomes_to_population(initialize):
|
def _chromosomes_to_population(initialize):
|
||||||
return chromosomes_to_population(initialize)
|
return chromosomes_to_population(initialize)
|
||||||
def __genes_to_chromosome(initialize):
|
def _genes_to_chromosome(initialize):
|
||||||
return genes_to_chromosome(initialize)
|
return genes_to_chromosome(initialize)
|
||||||
def __value_to_gene(initialize):
|
def _value_to_gene(initialize):
|
||||||
return value_to_gene(initialize)
|
return value_to_gene(initialize)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -25,9 +25,9 @@ def loop_mutations(mutation_method):
|
|||||||
class Mutation_Methods:
|
class Mutation_Methods:
|
||||||
|
|
||||||
# Private method decorators, see above.
|
# Private method decorators, see above.
|
||||||
def __loop_selections(selection_method):
|
def _loop_selections(selection_method):
|
||||||
return loop_selections(selection_method)
|
return loop_selections(selection_method)
|
||||||
def __loop_mutations(mutation_method):
|
def _loop_mutations(mutation_method):
|
||||||
return loop_mutations(mutation_method)
|
return loop_mutations(mutation_method)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ def check_selection_probability(selection_method):
|
|||||||
if 0 < ga.selection_probability < 1:
|
if 0 < ga.selection_probability < 1:
|
||||||
selection_method(ga)
|
selection_method(ga)
|
||||||
else:
|
else:
|
||||||
raise Exception("Selection probability must be greater than 0 to select parents.")
|
raise Exception("Selection probability must be between 0 and 1 to select parents.")
|
||||||
return helper
|
return helper
|
||||||
|
|
||||||
|
|
||||||
@ -39,11 +39,11 @@ def ensure_sorted(selection_method):
|
|||||||
class Parent_Selection:
|
class Parent_Selection:
|
||||||
|
|
||||||
# Private method decorators, see above.
|
# Private method decorators, see above.
|
||||||
def __check_selection_probability(selection_method):
|
def _check_selection_probability(selection_method):
|
||||||
return check_selection_probability(selection_method)
|
return check_selection_probability(selection_method)
|
||||||
def __check_positive_fitness(selection_method):
|
def _check_positive_fitness(selection_method):
|
||||||
return check_positive_fitness(selection_method)
|
return check_positive_fitness(selection_method)
|
||||||
def __ensure_sorted(selection_method):
|
def _ensure_sorted(selection_method):
|
||||||
return ensure_sorted(selection_method)
|
return ensure_sorted(selection_method)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ 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"""
|
||||||
|
|
||||||
# Private method decorator, see above.
|
# Private method decorator, see above.
|
||||||
def __append_to_next_population(survivor_method):
|
def _append_to_next_population(survivor_method):
|
||||||
return append_to_next_population(survivor_method)
|
return append_to_next_population(survivor_method)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -57,11 +57,11 @@ class Termination_Methods:
|
|||||||
"""Example functions that can be used to terminate the the algorithms loop"""
|
"""Example functions that can be used to terminate the the algorithms loop"""
|
||||||
|
|
||||||
# Private method decorators, see above.
|
# Private method decorators, see above.
|
||||||
def __add_by_fitness_goal(termination_impl):
|
def _add_by_fitness_goal(termination_impl):
|
||||||
return add_by_fitness_goal(termination_impl)
|
return add_by_fitness_goal(termination_impl)
|
||||||
def __add_by_generation_goal(termination_impl):
|
def _add_by_generation_goal(termination_impl):
|
||||||
return add_by_generation_goal(termination_impl)
|
return add_by_generation_goal(termination_impl)
|
||||||
def __add_by_tolerance_goal(termination_impl):
|
def _add_by_tolerance_goal(termination_impl):
|
||||||
return add_by_tolerance_goal(termination_impl)
|
return add_by_tolerance_goal(termination_impl)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user