Free cookie consent management tool by TermsFeed Policy Generator

source: branches/OKBJavaConnector/ECJClient/src/ec/app/edge/func/Reverse.java @ 10216

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

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

File size: 1.5 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.edge.func;
9import ec.*;
10import ec.app.edge.*;
11import ec.gp.*;
12import ec.util.*;
13
14/*
15 * Reverse.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 Reverse extends GPNode
27    {
28    public String toString() { return "reverse"; }
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!=1)
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        int edge = ((EdgeData)(input)).edge;
50        Edge prob = (Edge)problem;
51
52        int swap = prob.from[edge];
53        prob.from[edge] = prob.to[edge];
54        prob.to[edge] = swap;
55       
56        // pass the edge down
57
58        children[0].eval(state,thread,input,stack,individual,problem);
59        }
60    }
61
62
63
Note: See TracBrowser for help on using the repository browser.