GA gives graph the database
This commit is contained in:
@ -50,15 +50,10 @@ class GA(Attributes):
|
||||
|
||||
# Create the database here to allow the user to change
|
||||
# the database name and structure in the running function.
|
||||
self.database = database.Database()
|
||||
self.database.create_data_table(self)
|
||||
|
||||
# Create the initial population
|
||||
self.initialize_population()
|
||||
self.set_all_fitness()
|
||||
self.population.sort_by_best_fitness(self)
|
||||
# Save the population to the database
|
||||
self.database.insert_current_population(self)
|
||||
|
||||
# Otherwise evolve the population
|
||||
else:
|
||||
@ -67,10 +62,13 @@ class GA(Attributes):
|
||||
self.survivor_selection_impl(self)
|
||||
self.population.update()
|
||||
self.mutation_population_impl(self)
|
||||
self.set_all_fitness()
|
||||
self.population.sort_by_best_fitness(self)
|
||||
# Save the population to the database
|
||||
self.database.insert_current_population(self)
|
||||
|
||||
# Update and sort fitnesses
|
||||
self.set_all_fitness()
|
||||
self.population.sort_by_best_fitness(self)
|
||||
|
||||
# Save the population to the database
|
||||
self.database.insert_current_population(self)
|
||||
|
||||
number_of_generations -= 1
|
||||
self.current_generation += 1
|
||||
|
||||
Reference in New Issue
Block a user