Print

Print


Hi Sean,

Thanks for your quick response.

In the ECJ manual, the self-defined GPData is as follows,

public class MyData extends GPData {
         public double val;
         public GPData copyTo(GPData other) {
                   ((MyData)other).val = val;
                   return other;
         }
}

In the STGP example of the manual, the val variable can store both boolean
and real-valued data. However, in my case, the input from the child (char
data) and the the result (Bike data) of a GPNode can not use the same val
variable. Should I allocate different fields for them as below?

public class MyData extends GPData {
         public char char_val;
         public Bike Bike_val;
         public GPData copyTo(GPData other) {
                   ((MyData)other).char_val = char_val;
                   ((MyData)other).Bike_val = Bike_val;
                   return other;
         }
}

And in the eval() method of GPNodes, use char_val as input data and Bike_val
as return data separately. Is it right?

Wei



2010/11/25 Sean Luke <[log in to unmask]>

> On Nov 22, 2010, at 10:13 AM, Wei He wrote:
>
>  Does ECJ supply full support for Strongly-Typed Genetic Programming?
>>
>>
> Yep, though not polymorphic typing.
>
>
>  To be more specific, if I want to define a Java method with a char type
>> input data and a self-defined Bike type return data as a GPNode,
>>
>>
> The example you provided assumes you're casting data.  That's not the right
> way to think of it.  ECJ's GPNode objects hand data back and forth to one
> another using a GPData class you have specified.  I would just include in
> that GPData instance all the instance variables for possible kinds of data
> you might need to transfer from one GPNode to the other.
>
> See the Strongly Typed GP section of the ECJ Manual
>        http://cs.gmu.edu/~sean/temp/manual.pdf
>
> Sean
>