-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdd.java
More file actions
30 lines (25 loc) · 823 Bytes
/
Add.java
File metadata and controls
30 lines (25 loc) · 823 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ec.EvolutionState;
import ec.Problem;
import ec.gp.ADFStack;
import ec.gp.GPData;
import ec.gp.GPIndividual;
import ec.gp.GPNode;
public class Add extends GPNode
{
public String toString() { return "+"; }
public int expectedChildren() { return 2; }
public void eval(final EvolutionState state,
final int thread,
final GPData input,
final ADFStack stack,
final GPIndividual individual,
final Problem problem)
{
double result;
DoubleData data = ((DoubleData)(input));
children[0].eval(state,thread,input,stack,individual,problem);
result = data.x;
children[1].eval(state,thread,input,stack,individual,problem);
data.x = result + data.x;
}
}