Added save_population
for easier front-end usage.
This commit is contained in:
@ -68,7 +68,7 @@ class GA(Attributes):
|
|||||||
self.population.sort_by_best_fitness(self)
|
self.population.sort_by_best_fitness(self)
|
||||||
|
|
||||||
# Save the population to the database
|
# Save the population to the database
|
||||||
self.database.insert_current_population(self)
|
self.save_population()
|
||||||
|
|
||||||
number_of_generations -= 1
|
number_of_generations -= 1
|
||||||
self.current_generation += 1
|
self.current_generation += 1
|
||||||
@ -76,7 +76,7 @@ class GA(Attributes):
|
|||||||
|
|
||||||
def evolve(self):
|
def evolve(self):
|
||||||
"""Runs the ga until the termination point has been satisfied."""
|
"""Runs the ga until the termination point has been satisfied."""
|
||||||
while(self.active()):
|
while self.active():
|
||||||
self.evolve_generation()
|
self.evolve_generation()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -125,6 +125,11 @@ class Attributes:
|
|||||||
self.graph = Graph(self.database)
|
self.graph = Graph(self.database)
|
||||||
|
|
||||||
|
|
||||||
|
def save_population(self):
|
||||||
|
"""Saves the current population to the database."""
|
||||||
|
self.database.insert_current_population(self)
|
||||||
|
|
||||||
|
|
||||||
# Getter and setters for all required varibles
|
# Getter and setters for all required varibles
|
||||||
@property
|
@property
|
||||||
def chromosome_length(self):
|
def chromosome_length(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user