diff --git a/src/EasyGA.py b/src/EasyGA.py index d94fca4..575d5b3 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -27,6 +27,7 @@ class GA: # Selection variables self.parent_ratio = 0.1 + self.selection_probablity = 0.95 # Termination variables self.current_generation = 0 @@ -50,6 +51,7 @@ class GA: self.mutation_impl = Mutation_Methods().per_gene_mutation # 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.""" diff --git a/src/selection/selection_methods.py b/src/selection/selection_methods.py index 75c7928..c8476a6 100644 --- a/src/selection/selection_methods.py +++ b/src/selection/selection_methods.py @@ -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):