From 645f704b199456ab01497b307e40f32ed75d198e Mon Sep 17 00:00:00 2001 From: danielwilczak101 <44122838+danielwilczak101@users.noreply.github.com> Date: Tue, 13 Oct 2020 00:10:06 -0400 Subject: [PATCH] Fixed broken defaults and changed fitness function to is_it_5 --- src/EasyGA.py | 6 +++--- src/run_testing.py | 7 +------ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index a755d49..aca6929 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -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 diff --git a/src/run_testing.py b/src/run_testing.py index b4abb47..bcb9568 100644 --- a/src/run_testing.py +++ b/src/run_testing.py @@ -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()