Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/app/multiplexer/func/And.java @ 6152

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

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

File size: 2.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.multiplexer.func;
9import ec.*;
10import ec.app.multiplexer.*;
11import ec.gp.*;
12import ec.util.*;
13
14/*
15 * And.java
16 *
17 * Created: Wed Nov  3 18:26:37 1999
18 * By: Sean Luke
19 */
20
21/**
22 * @author Sean Luke
23 * @version 1.0
24 */
25
26public class And extends GPNode
27    {
28    public String toString() { return "and"; }
29
30    public void checkConstraints(final EvolutionState state,
31        final int tree,
32        final GPIndividual typicalIndividual,
33        final Parameter individualBase)
34        {
35        super.checkConstraints(state,tree,typicalIndividual,individualBase);
36        if (children.length!=2)
37            state.output.error("Incorrect number of children for node " +
38                toStringForError() + " at " +
39                individualBase);
40        }
41
42    public void eval(final EvolutionState state,
43        final int thread,
44        final GPData input,
45        final ADFStack stack,
46        final GPIndividual individual,
47        final Problem problem)
48        {
49        MultiplexerData md = (MultiplexerData)input;
50        long[] dat_11=null;  // quiets compiler complaints
51        long dat_6=0L;
52        byte dat_3=0;
53
54        // No shortcuts for now
55        children[0].eval(state,thread,input,stack,individual,problem);
56
57        if (md.status == MultiplexerData.STATUS_3)
58            dat_3 = md.dat_3;
59        else if (md.status == MultiplexerData.STATUS_6)
60            dat_6 = md.dat_6;
61        else // md.status == MultiplexerData.STATUS_11
62            {
63            dat_11 = md.popDat11();
64            System.arraycopy(md.dat_11,0,
65                dat_11,0,
66                MultiplexerData.MULTI_11_NUM_BITSTRINGS);
67            }
68
69        children[1].eval(state,thread,input,stack,individual,problem);
70
71        // modify
72
73        if (md.status == MultiplexerData.STATUS_3)
74            md.dat_3 &= dat_3;
75        else if (md.status == MultiplexerData.STATUS_6)
76            md.dat_6 &= dat_6;
77        else // md.status == MultiplexerData.STATUS_11
78            {
79            for(int x=0;x<MultiplexerData.MULTI_11_NUM_BITSTRINGS;x++)
80                md.dat_11[x] &= dat_11[x];
81            md.pushDat11(dat_11);
82            }
83        }
84    }
85   
86
87
Note: See TracBrowser for help on using the repository browser.