update functionality
This commit is contained in:
@ -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()
|
||||
```
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user