Changed some hard-coded stuf to GA attribute

Changed some hard-coded stuf to GA attribute
This commit is contained in:
RyleyGG
2020-10-06 20:58:20 -04:00
parent 2f78c9f464
commit af88e4c348
2 changed files with 3 additions and 1 deletions

View File

@ -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."""

View File

@ -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):