Major structural changes
This commit is contained in:
@ -1,20 +1,23 @@
|
||||
from initialization.population import population
|
||||
from initialization.chromosome import chromosome
|
||||
from initialization.gene import gene
|
||||
# Import the data structure
|
||||
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
|
||||
|
||||
from initialization.initialization import initialization
|
||||
from .initialization import initialization
|
||||
|
||||
class random_initialization(initialization):
|
||||
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 = population.population()
|
||||
population = create_population()
|
||||
# Fill the population with chromosomes
|
||||
for i in range(population_size):
|
||||
chromosome = chromosome.chromosome()
|
||||
chromosome = create_chromosome()
|
||||
#Fill the Chromosome with genes
|
||||
for j in range(chromosome_length):
|
||||
gene = gene.gene(gene_function)
|
||||
chromosome.add_gene(gene)
|
||||
|
||||
chromosome.add_gene(create_gene(gene_function()))
|
||||
population.add_chromosome(chromosome)
|
||||
return population
|
||||
|
||||
Reference in New Issue
Block a user