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
|
# Selection variables
|
||||||
self.parent_ratio = 0.1
|
self.parent_ratio = 0.1
|
||||||
|
self.selection_probablity = 0.95
|
||||||
|
|
||||||
# Termination variables
|
# Termination variables
|
||||||
self.current_generation = 0
|
self.current_generation = 0
|
||||||
@ -50,6 +51,7 @@ class GA:
|
|||||||
self.mutation_impl = Mutation_Methods().per_gene_mutation
|
self.mutation_impl = Mutation_Methods().per_gene_mutation
|
||||||
# The type of termination to impliment
|
# The type of termination to impliment
|
||||||
self.termination_impl = Termination_Methods().generation_based
|
self.termination_impl = Termination_Methods().generation_based
|
||||||
|
|
||||||
|
|
||||||
def evolve_generation(self, number_of_generations = 1, consider_termination = True):
|
def evolve_generation(self, number_of_generations = 1, consider_termination = True):
|
||||||
"""Evolves the ga the specified number of generations."""
|
"""Evolves the ga the specified number of generations."""
|
||||||
|
|||||||
@ -17,7 +17,7 @@ class Selection_Methods:
|
|||||||
tournament_size = int(len(ga.population.get_all_chromosomes())*ga.parent_ratio/3)
|
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.
|
# 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.
|
# Repeat tournaments until the mating pool is large enough.
|
||||||
while (len(ga.population.mating_pool) < len(ga.population.get_all_chromosomes())*ga.parent_ratio):
|
while (len(ga.population.mating_pool) < len(ga.population.get_all_chromosomes())*ga.parent_ratio):
|
||||||
|
|||||||
Reference in New Issue
Block a user