From 454edb13d18845bfdfe21e6cede4aae8909e7992 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 19 Nov 2020 16:48:02 -0500 Subject: [PATCH] Avoid overwriting initial population --- src/EasyGA.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/EasyGA.py b/src/EasyGA.py index eb77bb9..ebc7bde 100644 --- a/src/EasyGA.py +++ b/src/EasyGA.py @@ -46,16 +46,20 @@ class GA(Attributes): cond3 = lambda: cond2() or self.active() # check termination conditions. while cond1() and cond3(): + # If its the first generation if self.current_generation == 0: - # Create the database here to allow the user to change - # the database name and structure before running the function. + # Create the database here to allow the user to change the + # database name and structure before running the function. self.database.create_all_tables(self) + # Add the current configuration to the config table self.database.insert_config(self) + # Create the initial population - self.initialize_population() + if self.population is None: + self.initialize_population() # Otherwise evolve the population else: