Closed schrum2 closed 2 years ago
NEAT-Python has many examples of how to evolve in different domains: https://github.com/CodeReclaimers/neat-python/tree/master/examples several of these either save the whole population or save specific champion results.
I think what we want to do is save the whole population. This is sort of connected to an issue @alejmedinajr is working on, specifically #43 .
Basically, we need a framework for running experiments. If an experiment is launched, a base directory for the experiment should be specified where all results are saved. All in all, I think we need the following:
--BASE_DIR
: directory where results from several experiments can be stored.
--EXPERIMENT_PREFIX
: subdir in the BASE_DIR where directories from different runs are stored. The actual directory would be the EXPERIMENT_PREFIX combined with the RANDOM_SEED (we will repeat experiments multiple times with different seeds).
The specific experiment sub-dir is where another directory simply named "population" can be created to store the final evolved CPPNs. This dir is also where fitness logs will be stored from #43 .
As of now, there are no conflicts in the code, but I would like @richeyme and @alejmedinajr to work together on this (on a single machine) so that we don't get weird merge conflicts later. Once the details of the BASE_DIR and EXPERIMENT_PREFIX are done, then you can split up and return to working on this separately.
Now a population can be saved and then loaded again with a change of command line parameters. A population can either be saved or loaded, not both at same time.
It seems as though a save directory named "None" is created when no save directory is specified. However, no saving at all should happen if either or the needed directories are None
Now the saving only happens when both directories are not "None" and when SAVE_POPULATION
is true.
Change "SAVE_POPULATION" to "SAVE_FITNESS_LOG"
"SAVE_POPULATION" is now "SAVE_FITNESS_LOG".
The import
pickle
provides a way of saving Python objects, and there exist examples in the NEAT Python codebase of the population of CPPNs being saved. Add command line parameter for whether or not CPPN populations should be saved. If so, then a directory is set up and initialization and sub directories for each generation save the pickled CPPNs.Once this works, we need a way of loading such a population. For example, a population could be the starting population instead of a random starting point. This could be specified by a command line parameter that points to a directory to load from (default value of None would mean to not do this).