Hi all,

I am trying to implement a unique subclass of ERC and have run into
a few road blocks. Based on the archives it look like some have tried
something similar but I was not able to find the answer I was looking for.

I've created TERC a subclass of ERC (see code below). I would like
the subclass to retrieve its data from Problem every time its evaluated.

As I understand ECJ it looks like each individual in a population has his
own deep cloned copy of Problem. So with the way (TestProblem)problem
is set up each problem will have different data and the data will change
at each fitness evaluation.

I would like to know if anyone has any idea on how to correctly set
up resetNode(). As I understand the function is called every time a new
instance of TERC is created within an individual. By biggest concern
is accessing the correct problem, the problem beloning to the individial
of this.node so I can get to the right data. Also how would this work
with multi threaded runs???

If anyone has any ideas please let me know??



=============================

public class TERC extends ERC {

// holds the value
public GPVariable gpVarialble;

@Override
public void resetNode(EvolutionState state, int thread) {

// state.evaluator.

}

@Override
public boolean nodeEquals(final GPNode node) {

// see RegERC.java for more info
if(this.getClass() != node.getClass()) return false;
return (((TickERC)node).gpVarialble.value == gpVarialble.value);
}

@Override
public String encode() {
return Code.encode(gpVarialble.value);
}

@Override
public String toStringForHumans() {
return gpVarialble.id;
}

@Override
public void eval(EvolutionState state, int thread, GPData input,
ADFStack stack, GPIndividual individual, Problem problem) {

gpVarialble = ((TestProblem)problem).testRun.
get(((TestProblem)problem).testRunIndex).getVar(gpVarialble.id);

TData td = ((TData)(input));
td.x = gpVarialble.value;
}
}

===============================

public class GPVariable {

/** used in ECJ toString() to identify the variable */
public String id = "";

/** value held by variable */
public double value = 0;
}

 
Vlad Palnik