GA gives graph the database

This commit is contained in:
SimpleArt
2020-11-07 13:32:34 -05:00
parent f1f9d70c26
commit c959f44fd5
3 changed files with 18 additions and 20 deletions

View File

@ -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