update functionality

This commit is contained in:
Daniel Wilczak
2020-09-21 15:26:24 -04:00
parent 365ae7eac6
commit 71e75e8682
3 changed files with 10 additions and 6 deletions

View File

@ -25,7 +25,7 @@ def user_gene_function():
return random.randint(1, 100) return random.randint(1, 100)
# The user defined Fitness Function # The user defined Fitness Function
def user_fitness_function(): def user_fitness_function(chromosome):
pass pass
# Standard user size requirements # Standard user size requirements
@ -33,7 +33,7 @@ Population_size = 10
Chromosome_length = 10 Chromosome_length = 10
# Create the Genetic algorithm # 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() ga.initialize()
``` ```

View File

@ -62,7 +62,8 @@ class population:
self.chromosomes.append(chromosome) self.chromosomes.append(chromosome)
class GA: 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 # User defined variables
self.population_size = population_size self.population_size = population_size
self.chromosome_length = chromosome_length self.chromosome_length = chromosome_length
@ -75,4 +76,6 @@ class GA:
def initialize(self): def initialize(self):
# Create the initial population # 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)

View File

@ -6,7 +6,7 @@ def user_gene_function():
return random.randint(1, 100) return random.randint(1, 100)
# The user defined Fitness Function # The user defined Fitness Function
def user_fitness_function(): def user_fitness_function(chromosome):
pass pass
# Standard user size requirements # Standard user size requirements
@ -14,7 +14,8 @@ Population_size = 10
Chromosome_length = 10 Chromosome_length = 10
# Create the Genetic algorithm # 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() ga.initialize()
# Looking to print the first Chromosome # Looking to print the first Chromosome