From 70bb03bc961bbd97cd2f3176a08f420210351aa3 Mon Sep 17 00:00:00 2001 From: Daniel Wilczak Date: Wed, 23 Sep 2020 18:23:29 -0400 Subject: [PATCH] blaww --- src/EasyGA.py | 5 ++++- src/run_testing.py | 24 ++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index d58b06e..c5fb804 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -53,4 +53,7 @@ class GA: return create_gene(value) def make_chromosome(self): - pass + return create_chromosome() + + def make_population(self): + return create_population() diff --git a/src/run_testing.py b/src/run_testing.py index 6af8b32..fa51016 100644 --- a/src/run_testing.py +++ b/src/run_testing.py @@ -4,12 +4,32 @@ import EasyGA # Create the Genetic algorithm ga = EasyGA.GA() -# Start the population -ga.initialize() +def user_initialize(): + + population_size = 1 + chromosome_length = 3 + + population = ga.make_population() + # Fill the population with chromosomes + for i in range(population_size): + chromosome = ga.make_chromosome() + #Fill the Chromosome with genes + for j in range(chromosome_length): + chromosome.add_gene(ga.make_gene("hello")) + population.add_chromosome(chromosome) + return population + + +# Start the population +ga.initialization_impl = user_initialize() + +#make gene new_gene = ga.make_gene("Hello") print(new_gene.get_value()) print(new_gene.get_fitness()) +print(ga.population) + for chromosome in ga.population.chromosomes: print(chromosome.genes[0].__dict__)