On May 12, 2006, at 7:14 AM, Alberto Cuesta wrote:
> I'm designing a GP problem that has "ephemeral random constants"
> between its terminals. An ephemeral random constant gets a random
> value when created which is maintained constant during the rest of
> the evolution.
> Can I implement this with ECJ? How?. I'm not sure if each node in
> each GPTree is an instance in its own (which could then store
> values different to other instances) or pointers to a common class
> (in that case, how could I differentiate each node?).
They are instances of their own.
ECJ can handle ephemeral random constants easily. The simplest
approach is to make a subclass of ERC.java. When ERC.resetNode(...)
is called, your node needs to randomize its internal constant value.
You also need t override the nodeEquals(...) and nodeHashCode()
methods to return values appropriate for your ERC. And you'll need
to override the encode() and decode(...) methods as well. The other
methods are optional.
You can see an example of how this is done in several of the apps;
Regression has an ERC subclass for example which just wraps a single
ERC's don't have to be terminals by the way. Just override the
> I have a similar problem also with the terminals, in the examples a
> different class is used for X and another for Y, in a two variable
> regression problem. I have vectors of data of size 64 (V), and I
> want to use a single class (namely, V[i]) and decide which value i
> has at creation time.
That's also not a big issue. You can either subclass from ERC or
from GPNode and override the resetNode method to set up your node
once he's been instantiated.