Thanks Sean,

I see where I made my mistake.  I didn't realize newIndividual() was actually reading in the network.


Myron Tuttle

-----Original Message-----
From: Sean Luke <[log in to unmask]>
Reply-To: ECJ Evolutionary Computation Toolkit <[log in to unmask]>
To: [log in to unmask]
Subject: Re: ECJ18: Issue with ec.Subpopulation.readSubpopulation(EvolutionState, LineNumberReader)
Date: Sat, 6 Sep 2008 10:54:10 -0400

On Sep 5, 2008, at 5:46 PM, Myron Tuttle wrote:

> 1) When Subpopulation.setup() first creates the array of individuals  
> each individual is null.  This isn't a problem when creating new  
> individuals, but when reading on line 270  
> Subpopulation.readSubpopulation() first checks to see if the  
> individual in the individual array is null which it's always going  
> to be.  So instead of reading in the individual it will always  
> create new individuals.  It appears that this check was done to  
> avoid an invalid element error since readIndividual() is an instance  
> function.  A dummy individual seems like the easiest way to fix this  
> issue.

My quick scan of the code suggests this isn't what you are thinking.   
I think it's correct.  If the slot is null, instead of using the  
readIndividual(state, reader) method, it's supposed to resort to using  
the merely "less efficient" newIndividual(state, reader) method, which  
creates the dummy individual for you, calls  
readIndividual(state,reader) on it, and sticks it in.

> 2) Even after this fix though there is still a problem if the  
> individual has a custom printIndividual() method (for instance, if  
> the class is a child of Individual with additional information that  
> is printed and needs to be read in).  It would be necessary then to  
> create a dummy individual that is the same type of individual  
> specified in the subpop's species before calling readIndividual() on  
> it.

newIndividual does that.  But if you wanted to, it's easy:  grab the  
Species's prototype and clone it.

> 3) Tutorial 3 should be updated to reflect the changes to  
> printSubpopulation() and readSubpopulation() that include the number  
> of individuals and individual index preambles.

Thanks, I missed that.