public void setup(final EvolutionState state, final Parameter base) {
// very important, remember this super.setup(state, base); //ISinitilized = false; XXX ss = new XXX(); ClassPool
pool = ClassPool.getDefault();
String dirname = (new File("")).getAbsolutePath();
File file = new File(dirname);
recursiveTraversal(file, pool); //get all the classes path that we could use
// get the superclass from the pool
CtClass exprClass = pool.get("ec.gp.GPNode");
String myclass = "ec.app.JSwarmGP.func.PTerm{"+System.currentTimeMillis()+"}";
// the class name is 'Eval'
CtClass evalClass = pool.makeClass(myclass); //{"+System.currentTimeMillis()+"}");
evalClass.setSuperclass(exprClass);
// Since we don't really care about the class name, we'll append the current milliseconds as a minimal guard against multi-threading problems
// the interface implemented by the new class
//evalClass.setInterfaces(new CtClass[] { pool.makeClass("XTerm") });
// add the eval method to the class
evalClass.addMethod(CtNewMethod.make("public void eval (EvolutionState state, int thread, GPData input, ADFStack stack, GPIndividual individual, Problem problem){System.out.println(\"PTerm\");}",
evalClass));
//public String toString() { return "XTerm"; }
evalClass.addMethod(CtNewMethod.make("public String toString() { return \"PTerm\"; }",
evalClass));
s = "public void checkConstraints( ec.EvolutionState state," +
" int tree," +
" ec.gp.GPIndividual typicalIndividual," +
" ec.util.Parameter individualBase)" +
"{" +
"super.checkConstraints(state,tree,typicalIndividual,individualBase);" +
"if (children.length!=0)" +
" state.output.error(\"Incorrect number of children for node \" + " +
" toStringForError() + \" at \" + " +
" individualBase);"+
"}";
evalClass.addMethod(CtNewMethod.make(s, evalClass));
Class clazz = evalClass.toClass();
// instantiate it and cast it to Evaluator
//obj = (XTerm) clazz.newInstance();
///
//gp.fs.0.func.1 = ec.app.JSwarmGP.func.PTerm
//gp.fs.0.func.1.nc = nc0
s = "ec.app.JSwarmGP.func." + myclass;
base.param = "gp.fs.0.func.2";
state.parameters.set(base, s);
s = "nc0";
base.param = "gp.fs.0.func.2.nc";
state.parameters.set(base, s);
///gp.fs.0.size = 2
s = "3";
base.param = "gp.fs.0.size";
state.parameters.set(base, s);