I'm attempting to do something similar with limited success.
My approach is to treat the array as a terminal GPNode. Then I include two
functions: one called "length" that takes the array as its one parameter and
returns the length of the array, and a second called "get" that takes the
array and an index value and returns the specific value at that index.
Is there a motivation to use ERC instead of GPNode? Is there a benefit to
be gained, or does it perhaps not matter?
On Sun, 6 Jan 2013 18:39:32 -0500, Sean Luke <[log in to unmask]> wrote:
>Hi Jerry. So having a truly arbitrary and variable number of variables is
an interesting issue but I think you can do it fairly easily actually.
>What I'd do is first create an *array* of doubles in your Problem class.
The array size would be the number of variables. You'd define this size in
the parameter file.
>Next you need to define a function in your function set. You'd think that
you need one function for each variable, and that'd be a problem for an
arbitrary number of variables of course. But there's another option: make a
subclass of ERC.
>ERCs aren't just for constants. They can be variables, nonterminal
functions, you name it. An ERC subclass is appropriate whenever you have an
arbitrarily large and variable number of options for a single kind of
function node. Like the set of constants. Or in your case, the set of
>So your ERC would be a terminal -- it'd have no children -- and you'd have
it provide a name that seems appropriate for variables in general (X1, X2,
etc. maybe), and then based on its internal "value" (an integer which you'd
set at reset time) it'd determine which slot to look up in that array and