blaww
This commit is contained in:
@ -53,4 +53,7 @@ class GA:
|
|||||||
return create_gene(value)
|
return create_gene(value)
|
||||||
|
|
||||||
def make_chromosome(self):
|
def make_chromosome(self):
|
||||||
pass
|
return create_chromosome()
|
||||||
|
|
||||||
|
def make_population(self):
|
||||||
|
return create_population()
|
||||||
|
|||||||
@ -4,12 +4,32 @@ import EasyGA
|
|||||||
# Create the Genetic algorithm
|
# Create the Genetic algorithm
|
||||||
ga = EasyGA.GA()
|
ga = EasyGA.GA()
|
||||||
|
|
||||||
# Start the population
|
|
||||||
ga.initialize()
|
|
||||||
|
|
||||||
|
def user_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")
|
new_gene = ga.make_gene("Hello")
|
||||||
print(new_gene.get_value())
|
print(new_gene.get_value())
|
||||||
print(new_gene.get_fitness())
|
print(new_gene.get_fitness())
|
||||||
|
|
||||||
|
print(ga.population)
|
||||||
|
|
||||||
for chromosome in ga.population.chromosomes:
|
for chromosome in ga.population.chromosomes:
|
||||||
print(chromosome.genes[0].__dict__)
|
print(chromosome.genes[0].__dict__)
|
||||||
|
|||||||
Reference in New Issue
Block a user