Every generation, or (if doing steady-state evaluation) every N evaluations, ECJ may terminate under one of three conditions:
- Evaluator.runComplete() returns true
- The run is over: EvolutionState completes all of it generations or requested evaluations
- Another island tells IslandExchange that it found the optimum and so all processes should quit
The easiest for you to hook into is Evaluator.runComplete(). Just subclass SimpleEvaluator to do:
public boolean runComplete(final EvolutionState state)
if (super.runComplete(state)) return true;
// here you return true or false depending on whether
// you want to quit
This will be called after evaluation of your population and before breeding.
If you want to quit IMMEDIATELY upon some discovery, ECJ doesn't have many options for that -- it has to shut itself down gracefully and cleanly.
On Apr 21, 2015, at 5:54 AM, Nihamata Fashoti <[log in to unmask]> wrote:
> I am using GP section of ECJ. During execution at some points in the code if some conditions are true, I want to terminate GP process and print the best result so far.
> Individual bestSoFar = ((SimpleStatistics)state.statistics).getBestSoFar();
> Please let me know what is the safe way to do this?