neat-python icon indicating copy to clipboard operation
neat-python copied to clipboard

Update fitness_threshold from a checkpoint

Open keenhon opened this issue 4 years ago • 1 comments

Hi,

I would like to know if there is a way to change the fitness_threshold for a saved checkpoint?

Thanks

keenhon avatar Nov 09 '21 23:11 keenhon

Hello -- a few months ago, I needed to adjust some config values on a checkpoint. I made the following change in 'checkpoint.py'. It allows to substitute an updated config when restoring a checkpoint.

NOTE: I'm unsure if this causes adverse conditions for the algorithm. It's handy to be able to make changes mid-evolution, so I'd be grateful if anyone could provide insights, and improvements if required.

def restore_checkpoint(filename, update_config=None):
        """Resumes the simulation from a previous saved point"""
        with gzip.open(filename) as f:
            generation, config, population, species_set, rndstate = pickle.load(f)
            random.setstate(rndstate)            
            if update_config==None:
                return Population(config, (population, species_set, generation))
            else:
                return Population(update_config, (population, species_set, generation))

luke-saunders avatar Aug 01 '22 00:08 luke-saunders