Fixed to explain
This commit is contained in:
@ -4,30 +4,14 @@ import EasyGA
|
|||||||
# Create the Genetic algorithm
|
# Create the Genetic algorithm
|
||||||
ga = EasyGA.GA()
|
ga = EasyGA.GA()
|
||||||
|
|
||||||
|
# Makes a new gene
|
||||||
|
new_gene = ga.make_gene("HelloWorld")
|
||||||
|
# Makes a chromosome to store genes in
|
||||||
|
new_chromosome = ga.make_chromosome()
|
||||||
|
# Makes a Population to store chromosomes in
|
||||||
|
new_population = ga.make_population()
|
||||||
|
|
||||||
def user_initialize():
|
ga.initialize()
|
||||||
|
|
||||||
population_size = 1
|
|
||||||
chromosome_length = 3
|
|
||||||
|
|
||||||
population = ga.make_population()
|
|
||||||
# Fill the population with chromosomes
|
|
||||||
for i in range(population_size):
|
|
||||||
chromosome = ga.make_chromosome()
|
|
||||||
#Fill the Chromosome with genes
|
|
||||||
for j in range(chromosome_length):
|
|
||||||
chromosome.add_gene(ga.make_gene("hello"))
|
|
||||||
population.add_chromosome(chromosome)
|
|
||||||
return population
|
|
||||||
|
|
||||||
|
|
||||||
# Start the population
|
|
||||||
ga.initialization_impl = user_initialize()
|
|
||||||
|
|
||||||
#make gene
|
|
||||||
new_gene = ga.make_gene("Hello")
|
|
||||||
print(new_gene.get_value())
|
|
||||||
print(new_gene.get_fitness())
|
|
||||||
|
|
||||||
print(ga.population)
|
print(ga.population)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user