January 2010


Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sean Luke <[log in to unmask]>
Reply To:
ECJ Evolutionary Computation Toolkit <[log in to unmask]>
Fri, 22 Jan 2010 18:29:42 -0500
text/plain (53 lines)
Jake, I presume you're talking about GP.  GPNodes, GPTrees, and  
GPIndividuals all basically work like this: after a population is  
evaluated, typically the individuals undergo breeding to create new  
individuals, and then are usually eliminated.  Breeding works by  
cloning subtrees, and ultimately nodes, from the old individuals to  
form new individuals.  The clone method used is lightClone(), which  
ultimately calls clone() underneath.

So let's say you've made got a GPNode called 'foo' which has an  
ArrayList called  'foo' is located in some GPIndividual, and  
the GP system has decided to copy that individual, and the subtree  
where 'foo' is located, to create a new child for the next  
generation.  We call foo.clone().  This creates a new object (call it  
foo2). is pointing to the same ArrayList as now.   
Now we create another new child from foo (foo's lucky!) called foo3. and BOTH are pointing to the same ArrayList as is.

This may be what you want, but I'm guessing it's not.  Because now you  
evaluate the new child individual that holds foo2.  It adds something  
to the ArrayList.  When you get around to evaluating the  
individual that has foo3, it ALSO will have that thing added into its  
ArrayList because it's the same ArrayList.  You probably were hoping  
them to have separate ArrayLists is my guess.

To do that, you override the GPNode clone method for your particular  
GPNode subclass to call super.clone(), and then say something like:

	bar = (ArrayList)(bar.clone());

Now foo2 and foo3 have their own copies of the ArrayList, different  
from the original one in foo, each storing what had inside it,  
but able to add their own independent stuff without stepping on each  
others' toes.


On Jan 22, 2010, at 5:13 PM, Jake Pacheco wrote:

> Specifically, I have a node that is meant to calculate the zero lag
> exponential moving average of its child's value. This requires the  
> node
> having access to its own value on the previous evaluation, as well  
> as the
> child's value for several evaluations back. The way I implemented  
> this, the
> node stores its value in a variable after calculation, and adds the  
> child's
> value to an ArrayList. However, I am not sure if these are preserved  
> through
> to the next evaluation, or, if they are preserved through evaluations,
> whether they will be empty once the next generation starts.