Hi all,


Does ECJ supply full support for Strongly-Typed Genetic Programming?
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,


GPTree is of DoubleData; and I implement the eval() function of a specific GPNode as follows,


public class BikeShopGetTheRightBike extends GPNode {
        ...
        public void eval(final EvolutionState state, final int thread,
final GPData input, final ADFStack stack,
final GPIndividual individual, final Problem problem) {


Bike ret = new Bike();


children[0].eval(state, thread, input, stack, individual, problem);


CharData arg0Data = (CharData)input; // at runtime, throws an java.lang.ClassCastException:
                                                                             // testdatagen.bike.gp.DoubleData cannot be cast to testdatagen.bike.gp.CharData
                Character arg0 = arg0Data.value;


// get the return value through invoking the method by name (reflection)
try {
Class cls = Class.forName("BikeShop");
Method m = cls.getMethod("getTheRightBike", char.class);
ret = (Bike) m.invoke("BikeShop", arg0);
// System.out.println(retval.doubleValue());
} catch (Throwable e) {
System.err.println(e);
}


BikeData result = (BikeData)input; // the return data of Bike type
// set the value of the result
result.value = ret;
}

 


However, a runtime ClassCastException is thrown.


I've read the tuturials and online stuffs. But it seems that all the examples use the compatable data types for both input and return data (such as DoubleData for both boolean, int and double). So I am confused about how to define a method with different input and return data types as a GPNode.


Is there anyone who can give me some suggestion or hint on this issue?


Thanks,
Wei