OK, got it, thanks for the quick reply!
From: ECJ Evolutionary Computation Toolkit [mailto:[log in to unmask]] On Behalf Of Sean Luke
Sent: Thursday, November 07, 2013 10:02 PM
To: [log in to unmask]
Subject: Re: ECJ caching
On Nov 7, 2013, at 5:58 PM, Masek, Tudor wrote:
> We are working with ECJ to run a multi-objective optimization, and two questions have come up:
> 1. Does ECJ cache evaluation results such that if (via random mutations) an individual is generated with a genome that has already been evaluated, the expensive evaluation call is avoided in favor of a cache lookup?
No. It's assumed that you can do this very easily in your fitness assessment (assuming you're not running master-slave). For example if you have a SimpleFitness, you can do:
java.util.HashMap sharedHashMap = new java.util.HashMap();
public void evaluate(EvolutionState state, Individual ind, int subpopulation, int threadnum)
if (ind.evaluated) return;
Object result = sharedHashMap.get(ind);
if (result == null)
// Do your individual evaluation here
fitness = ... ;
// this won't fix race conditions but it should be fine
sharedHashMap.put(ind, new Float(fitness));
else fitness = ((Float)result).floatValue();
boolean isOptimal = ... ; // something based on fitness
((SimpleFitness)(ind.fitness)).setFitness( state, fitness, isOptimal );
Note that this won't work right with coevolution, any method which requires multiple distributed trials, or distributed evaluation. You have little choice in those cases but to reevaluate.