Cache Fitness question

34 views
Skip to first unread message

Ian Clarke

unread,
Jun 16, 2011, 11:10:38 AM6/16/11
to epo...@googlegroups.com
Can I set cacheFitness() to true if my fitness function changes
between generations, but not within a generation?

Ian.

--
Ian Clarke
Blog: http://blog.locut.us/

Tom Castle

unread,
Jun 16, 2011, 12:12:51 PM6/16/11
to EpochX
No, and unfortunately there's no easy way of clearing a program's
cache. That has just been added to the todo list! There is however a
hard way, so if this is a real issue then I can suggest a work around?

Tom

Ian Clarke

unread,
Jun 16, 2011, 2:07:20 PM6/16/11
to epo...@googlegroups.com
so if this is a real issue then I can suggest a work around?
Please do!

Ian. 

Tom Castle

unread,
Jun 16, 2011, 9:38:04 PM6/16/11
to EpochX
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
Reply all
Reply to author
Forward
0 new messages