Print

Print


It's a bug triggered by our changes of deep and light cloning to get  
rid of protoClone.

In GPTree.java, try changing the line
	newtree.child = (GPNode)(child.cloneReplacing());  // force a deep copy
to
	if (child!=null) newtree.child = (GPNode)(child.cloneReplacing 
());  // force a deep copy

The situation: when you read in an individual, ECJ clones a  
prototypical individual and then fills its trees.  The prototypical  
individual doesn't have any trees yet; thus the clone needs to be a  
light clone which avoids trying to copy the (nonexisting) trees.  We  
forgot to make it a light clone, and it's a little complicated at  
this stage.  I'll Think Deeply about what the right way is to fix  
this, but I think the fix above may do it for you.

Sean


On May 23, 2006, at 1:03 PM, Michael Solano wrote:

> Hello Everyone,
>
> I'm attempting to move some experiments from version 13 to version  
> 15 and I've run into a problem. One of my custom problems requires  
> I read an individual into the evaluator and compare it to the  
> individuals in the population. I use the newIndividual 
> (EvolutionState state, Subpopulation _population, Fitness -fitness,  
> LineNumberReader reader) method in Species.java to accomplish this.  
> This worked perfectly in version 13 but I get the following  
> NullPointerException in version 15:
>
> Exception in thread "main" java.lang.NullPointerException
>         at ec.gp.GPTree.clone(GPTree.java:212)
>         at ec.gp.GPIndividual.clone(GPIndividual.java:295)
>         at ec.Species.newIndividual(Species.java:114)
>         at ec.app.solano_projects.unimodal_trap.Unimodal.evaluate 
> (Unimodal.java:234)
>         at ec.simple.SimpleEvaluator.evalPopChunk 
> (SimpleEvaluator.java:126)
>         at ec.simple.SimpleEvaluator.evaluatePopulation 
> (SimpleEvaluator.java:76)        at  
> ec.simple.SimpleEvolutionState.evolve(SimpleEvolutionState.java:75)
>         at ec.EvolutionState.run(EvolutionState.java:427)
>         at ec.Evolve.main(Evolve.java:599)
>
>
> Here is the code_segment that reads the individual into the evaluator:
>
> perfect_ind = (GPIndividual)state.population.subpops 
> [0].species.newIndividual(
>                        state,
>                        state.population.subpops[0],
>                        (Fitness)(state.population.subpops 
> [0].f_prototype.clone()),
>                        reader);
>
> Below are the contents of the file I'm attempting to read into the  
> individual:
>
> Evaluated: F
> Fitness: f1064971090|0.9772235|i0|
> Tree 0:
>  (D (C (B (A x) (A x)) (B (A x) (A x)) (B (A x) (A x))) (C (B (A x)  
> (A x)) (B (A x) (A x)) (B (A x) (A x))) (C (B (A x) (A x)) (B (A x)  
> (A x)) (B (A x) (A x))) (C (B (A x) (A x)) (B (A x) (A x)) (B (A x)  
> (A x))))
>
>
> Does anyone know what might be causing this error? Thanks :)
>
> -Mike