The hard way was ugly! I decided it was simpler to just roll a new
release that added a clearCache() method, especially since I had a bug
fix to add anyway. So, now what you should be able to do is clear each
program's cache at the start of each generation, like this:
Life.get().addGenerationListener(new GenerationAdapter() {
public void onGenerationStart() {
List<CandidateProgram> pop = (List<CandidateProgram>)
Stats.get().getStat(StatField.GEN_POP);
if (pop != null) {
for (CandidateProgram p: pop) {
((GPCandidateProgram) p).clearCache();
}
}
}
});
You need the check for null because at the start of initialisation
(which is considered to be a generation for the sake of events), there
will be no population. Then you should be able to enable cache fitness
and change the fitness function. If you're not changing the fitness
function every generation you could of course get clever and clear the
caches only when the fitness function changes.
Hope this helps!
Tom