From 71e75e86826b15d30a8a11156e3877697690ceaf Mon Sep 17 00:00:00 2001 From: Daniel Wilczak Date: Mon, 21 Sep 2020 15:26:24 -0400 Subject: [PATCH] update functionality --- README.md | 4 ++-- src/EasyGA.py | 7 +++++-- src/example.py | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e1b77ea..c4aef14 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ def user_gene_function(): return random.randint(1, 100) # The user defined Fitness Function -def user_fitness_function(): +def user_fitness_function(chromosome): pass # Standard user size requirements @@ -33,7 +33,7 @@ Population_size = 10 Chromosome_length = 10 # Create the Genetic algorithm -ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function) +ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function,user_fitness_function) ga.initialize() ``` diff --git a/src/EasyGA.py b/src/EasyGA.py index 20d6e68..a6f2b10 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -62,7 +62,8 @@ class population: self.chromosomes.append(chromosome) class GA: - def __init__(self, population_size, chromosome_length, user_gene_function): + def __init__(self, population_size, chromosome_length, + user_gene_function,user_fitness_function): # User defined variables self.population_size = population_size self.chromosome_length = chromosome_length @@ -75,4 +76,6 @@ class GA: def initialize(self): # Create the initial population - self.population = self.initialization_impl.initialize(self.population_size, self.chromosome_length, self.user_gene_function) + self.population = self.initialization_impl.initialize(self.population_size, + self.chromosome_length, + self.user_gene_function) diff --git a/src/example.py b/src/example.py index 98cb430..725cd78 100644 --- a/src/example.py +++ b/src/example.py @@ -6,7 +6,7 @@ def user_gene_function(): return random.randint(1, 100) # The user defined Fitness Function -def user_fitness_function(): +def user_fitness_function(chromosome): pass # Standard user size requirements @@ -14,7 +14,8 @@ Population_size = 10 Chromosome_length = 10 # Create the Genetic algorithm -ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function) +ga = EasyGA.GA(Population_size, Chromosome_length, + user_gene_function,user_fitness_function) ga.initialize() # Looking to print the first Chromosome