Fixed all jacks code

This commit is contained in:
danielwilczak101
2020-09-23 21:58:48 -04:00
parent eaa90ecd2a
commit 994bdb164c
7 changed files with 87 additions and 58 deletions

View File

@ -3,19 +3,18 @@ from .population_structure.population import population as create_population
from .chromosome_structure.chromosome import chromosome as create_chromosome
from .gene_structure.gene import gene as create_gene
class random_initialization:
def initialize(self,chromosome_length,population_size,gene_function):
# I dont understand why python needs this in its scope but it does.
global population
global chromosome
global gene
# Create the population object
population = create_population()
# Fill the population with chromosomes
for i in range(population_size):
chromosome = create_chromosome()
#Fill the Chromosome with genes
for j in range(chromosome_length):
chromosome.add_gene(create_gene(gene_function()))
population.add_chromosome(chromosome)
return population
def random_initialization(chromosome_length,population_size,gene_function):
# I dont understand why python needs this in its scope but it does.
global population
global chromosome
global gene
# Create the population object
population = create_population()
# Fill the population with chromosomes
for i in range(population_size):
chromosome = create_chromosome()
#Fill the Chromosome with genes
for j in range(chromosome_length):
chromosome.add_gene(create_gene(gene_function()))
population.add_chromosome(chromosome)
return population