Best ways to recover an interrupted evolution?

55 views
Skip to first unread message

Alberto Tonda

unread,
Nov 21, 2016, 10:21:18 AM11/21/16
to Inspyred
Dear all,

I am currently working on a multi-objective problem with NSGA-II, with computationally expensive evaluations. For several reasons, sometimes I need to stop and restart the evolutionary process: I was thus thinking about the best way to save and restore the current state of the population.

As far as I understand, just saving/loading the current random state and population is not enough, as several Pareto-optimal individuals might lie inside the "archive". I would thus need to save the "archive" and population at each generation. So, here are my questions:

a) is it possible to access NSGA-II's archive from an observer? I tried to pass the archive as a variable, like this:
final_pop = ea.evolve(
generator = nsga2generate,
pop_size = pop_size,
maximize = True,
max_generations = max_generations,
evaluator=inspyred.ec.evaluators.parallel_evaluation_mp,
mp_evaluator=nsga2evaluate, 
mp_num_cpus=4,
# extra arguments, will be passed to the functions in the "args" dictionary
archive = ea.archive
)
but it's not working, every time the archive is seen as "None"

b) what would be the best way to "recover" the evolution, starting from the content of the archive and the population at the last generation, plus the random state and all other relevant values?

I was thinking about overriding the "generator" by making it place the individuals from the last generation directly inside the "population zero", and do something similar for the archive.

Do you think it's feasible, or do you have other suggestions?

Thank you for your time, and best regards, 

Aaron Garrett

unread,
Nov 21, 2016, 11:34:40 AM11/21/16
to Inspyred
The actual EC object is stored in the args dictionary as args['_ec'], so you could say

archive = args['_ec'].archive

wherever you need that (with access to the args dictionary). Trying to pass it in like you're doing doesn't link them. I think you just get the snapshot at the beginning that is None. 

If you want to start an EC with specified candidates, you can seed the evolve method (https://aarongarrett.github.io/inspyred/reference.html#inspyred.ec.EvolutionaryComputation.evolve). Look at the seeds parameter. So if you stop and then restart, as long as you can save the candidate solutions and load them into the seeds parameter, it should start from there. Getting the PRNG to pick up where it left off is trickier. Restarting with the same seed as originally used will not recreate the set of random values that WOULD have occurred if it had kept going. I'm not sure that's a real issue for you, though. I don't see why it would matter much if you just reseeded a new PRNG for the resumed evolution.


Just as an example of reseeding:

keep_restarting = True
my_seeds
= None
while keep_restarting:
   final_pop
= ec.evolve(whatever, whatever, seeds=my_seeds, whatever, whatever,...)
   final_arc
= ec.archive
   
# Fill the seeds with the archive.
   my_seeds
= []
   for a in final_arc:
      my_seeds
.append(a.candidate)


Something like that should get you close to what you want.
Reply all
Reply to author
Forward
0 new messages