Changed some hard-coded stuf to GA attribute
Changed some hard-coded stuf to GA attribute
This commit is contained in:
@ -27,6 +27,7 @@ class GA:
|
||||
|
||||
# Selection variables
|
||||
self.parent_ratio = 0.1
|
||||
self.selection_probablity = 0.95
|
||||
|
||||
# Termination variables
|
||||
self.current_generation = 0
|
||||
@ -51,6 +52,7 @@ class GA:
|
||||
# The type of termination to impliment
|
||||
self.termination_impl = Termination_Methods().generation_based
|
||||
|
||||
|
||||
def evolve_generation(self, number_of_generations = 1, consider_termination = True):
|
||||
"""Evolves the ga the specified number of generations."""
|
||||
while(number_of_generations > 0 and (consider_termination == False or self.termination_impl(self))):
|
||||
|
||||
@ -17,7 +17,7 @@ class Selection_Methods:
|
||||
tournament_size = int(len(ga.population.get_all_chromosomes())*ga.parent_ratio/3)
|
||||
|
||||
# Probability used for determining if a chromosome should enter the mating pool.
|
||||
selection_probability = 0.95
|
||||
selection_probability = ga.selection_probability
|
||||
|
||||
# Repeat tournaments until the mating pool is large enough.
|
||||
while (len(ga.population.mating_pool) < len(ga.population.get_all_chromosomes())*ga.parent_ratio):
|
||||
|
||||
Reference in New Issue
Block a user