Alejandro, your code looks just fine to me.
Every generation, the Evaluator creates some N threads, then creates N clones from the problem prototype and hands each one to a thread and gives it a part of the population to work on. It then joins the threads and gets rid of the problem clones.
So if your goal is to modify fitness cases each generation prior to evaluation, modifying them in the problem and then calling super.evaluatePopulation(...) should do the trick.
On Jan 21, 2013, at 10:56 PM, J. Alejandro Zepeda CortÚs wrote:
> I am trying to change my fitness cases after some generations.
> I overwrote SimpleEvaluator.evaluatePopulation, and given some conditions, the change is made as it is needed. But it seems that I just touched the cloned version of my problem, which owns the fitness cases. The change is made and repeated over the original version always.
> How must I correctly update the prototypical problem so the cloned versions, used in the several threads, get the fitness cases modified along the generations?
> I think I have to change the prototypical problem so the changes be accumulated along the time.
> Here is my class:
> public class NGCPEvaluator extends SimpleEvaluator
> private static final Logger logger = Logger.getLogger(
> NGCPEvaluator.class);//Debugging instrumentation
> private static final long serialVersionUID = -2194721194631360445L;
> public void evaluatePopulation(final EvolutionState state)
> GPProblem gpProblem = (GPProblem) p_problem;
> NGCProblem ngcp = (NGCProblem) gpProblem;
> FitnessCases fitnessCases = ngcp.fitnessCases;
> fitnessCases.setCurrentGeneration(state.generation);//Update is triggered here, eventually.