-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAnd.java
51 lines (35 loc) · 1.36 KB
/
And.java
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import ec.*;
import ec.gp.*;
public class And extends GPNode{
/**
*
*/
private static final long serialVersionUID = -3809619002033827584L;
public String toString() { return "And"; }
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)
{
MyGPData result = (MyGPData)(input);
MyProblem myproblem = (MyProblem)problem;
//We evaluate our left children.
children[0].eval(state,thread,input,stack,individual,myproblem);
MyGPData leftdata = (MyGPData)(input);
if (leftdata.condicion == false)//Short circuit for AND, we must not continue evaluating the boolean expression (left AND right).
{
result.condicion = false;
result.punto = null;
return;
}
//We evaluate our right children.
children[1].eval(state,thread,input,stack,individual,myproblem);
MyGPData rightdata = (MyGPData)(input);
if (rightdata.condicion == false)//Short circuit for AND, we must not continue evaluating the boolean expression (left AND right).
{
result.condicion = false;
result.punto = null;
return;
}
result.condicion = true;
result.punto = null;
}
}