Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/app/tutorial4/Add.java @ 9449

Last change on this file since 9449 was 6152, checked in by bfarka, 14 years ago

added ecj and custom statistics to communicate with the okb services #1441

File size: 1.3 KB
Line 
1/*
2  Copyright 2006 by Sean Luke
3  Licensed under the Academic Free License version 3.0
4  See the file "LICENSE" for more information
5*/
6
7
8package ec.app.tutorial4;
9import ec.*;
10import ec.gp.*;
11import ec.util.*;
12
13public class Add extends GPNode
14    {
15    public String toString() { return "+"; }
16
17    public void checkConstraints(final EvolutionState state,
18        final int tree,
19        final GPIndividual typicalIndividual,
20        final Parameter individualBase)
21        {
22        super.checkConstraints(state,tree,typicalIndividual,individualBase);
23        if (children.length!=2)
24            state.output.error("Incorrect number of children for node " +
25                toStringForError() + " at " +
26                individualBase);
27        }
28
29    public void eval(final EvolutionState state,
30        final int thread,
31        final GPData input,
32        final ADFStack stack,
33        final GPIndividual individual,
34        final Problem problem)
35        {
36        double result;
37        DoubleData rd = ((DoubleData)(input));
38
39        children[0].eval(state,thread,input,stack,individual,problem);
40        result = rd.x;
41
42        children[1].eval(state,thread,input,stack,individual,problem);
43        rd.x = result + rd.x;
44        }
45    }
46
Note: See TracBrowser for help on using the repository browser.