Updated gene creation
The gene creation process can now accept an arbitrary number of parameters.
This commit is contained in:
@ -8,6 +8,7 @@ def random_initialization(population_size, chromosome_length, chromosome_impl, g
|
|||||||
with the given parameters."""
|
with the given parameters."""
|
||||||
# Create the population object
|
# Create the population object
|
||||||
population = create_population()
|
population = create_population()
|
||||||
|
|
||||||
# Fill the population with chromosomes
|
# Fill the population with chromosomes
|
||||||
for i in range(population_size):
|
for i in range(population_size):
|
||||||
chromosome = create_chromosome()
|
chromosome = create_chromosome()
|
||||||
@ -21,7 +22,7 @@ def random_initialization(population_size, chromosome_length, chromosome_impl, g
|
|||||||
elif gene_impl != None:
|
elif gene_impl != None:
|
||||||
# gene_impl = [range function,lowerbound,upperbound]
|
# gene_impl = [range function,lowerbound,upperbound]
|
||||||
function = gene_impl[0]
|
function = gene_impl[0]
|
||||||
chromosome.add_gene(create_gene(function(gene_impl[1],gene_impl[2])))
|
chromosome.add_gene(create_gene(function(*gene_impl[1:])))
|
||||||
else:
|
else:
|
||||||
#Exit because either were not specified
|
#Exit because either were not specified
|
||||||
print("Your domain or range were not specified")
|
print("Your domain or range were not specified")
|
||||||
|
|||||||
Reference in New Issue
Block a user