Fixed broken defaults and changed fitness function to is_it_5

This commit is contained in:
danielwilczak101
2020-10-13 00:10:06 -04:00
parent 2485af795a
commit 645f704b19
2 changed files with 4 additions and 9 deletions

View File

@ -24,9 +24,9 @@ class GA:
"""Initialize the GA."""
# Initilization variables
self.chromosome_length = 10
self.population_size = 150
self.population_size = 10
self.chromosome_impl = None
self.gene_impl = None
self.gene_impl = [random.randint,1,10]
self.population = None
self.target_fitness_type = 'maximum'
self.update_fitness = True
@ -48,7 +48,7 @@ class GA:
# Default EasyGA implimentation structure
self.initialization_impl = Initialization_Methods.random_initialization
self.fitness_function_impl = Fitness_Examples.index_dependent_values
self.fitness_function_impl = Fitness_Examples.is_it_5
self.make_population = create_population
self.make_chromosome = create_chromosome
self.make_gene = create_gene

View File

@ -4,12 +4,7 @@ import EasyGA
# Create the Genetic algorithm
ga = EasyGA.GA()
ga.population_size = 100
ga.chromosome_length = 10
ga.generation_goal = 100
ga.gene_impl = [random.randint,1,10]
ga.parent_selection_impl = EasyGA.Parent_Selection.Roulette.roulette_selection
ga.evolve()
print(f"Current Generation: {ga.current_generation}")
ga.population.print_all()