Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Hi after reviewing the documentation of Pyevolve there doesn't seem to be any way to resume an evolution base on what you stored in the database (strange behaviour).</p> <p>If you want to implement this type of mechanism, you could look at pickling your population once and a while and implementing the whole thing in Pyevolve.</p> <p>Or, you could try <a href="http://deap.googlecode.com" rel="nofollow">DEAP</a> a very open framework that let you see and manipulate every aspect of an evolutionary algorithm, transparently. And there is already some <em>checkpointing</em> mechanism implemented.</p> <p>Here is what your code would look like in DEAP.</p> <pre><code>import random from deap import algorithms, base, creator, tools # Create the needed types creator.create("FitnessMax", base.Fitness, weights=(1.0,)) creator.create("Individual", list, fitness=creator.FitnessMax) # Container for the evolutionary tools toolbox = base.Toolbox() toolbox.register("attr", random.random, 1, 15) toolbox.register("individual", tools.initRepeat, creator.Individual, toolbox.attr, 6) toolbox.register("population", tools.initRepeat, list, toolbox.individual) # Operator registering toolbox.register("evaluate", eval_func) toolbox.register("mate", tools.cxTwoPoints) toolbox.register("mutate", tools.mutGaussian, mu=0, sigma=1, indpb=0.05) toolbox.register("select", tools.selTournament, tournsize=3) population = toolbox.population(n=10) stats = tools.Statistics(key=lambda ind: ind.fitness.values) stats.register("Max", max) checkpoint = tools.Checkpoint(population=population) GEN, CXPB, MUTPB = 0, 0.5, 0.1 while stats.Max() &lt; CONDITION: # Apply standard variation (crossover followed by mutation) offspring = algorithms.varSimple(toolbox, population, cxpb=CXPB, mutpb=MUTPB) # Evaluate the individuals fits = toolbox.map(toolbox.evaluate, offspring) for fit, ind in zip(fits, offspring): ind.fitness.values = fit # Select the fittest individuals offspring = [toolbox.clone(ind) for ind in toolbox.select(offspring, len(offspring)] # The "[:]" is important to not replace the label but what it contains population[:] = offspring stats.update(population) if GEN % 20 == 0: checkpoint.dump("my_checkpoint") GEN += 1 </code></pre> <p>Note that the above code has not been tested. But it does everything you request for. Now how to load a checkpoint and restart an evolution.</p> <pre><code>checkpoint = tools.Checkpoint() checkpoint.load("my_checkpoint.ems") population = checkpoint["population"] # Continue the evolution has in before </code></pre> <p>Moreover, DEAP is very well documented and has over 25 diversified examples that help new user to ramp up very quickly, I also heard that developers answer to question very quickly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload