KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > gp > GPTestCase


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap.gp;
11
12 import org.jgap.*;
13 import org.jgap.impl.*;
14 import org.jgap.gp.function.*;
15 import org.jgap.gp.terminal.*;
16 import org.jgap.gp.impl.*;
17
18 /**
19  * Abstract test case class for GP-related tests
20  *
21  * @author Klaus Meffert
22  * @since 3.0
23  */

24 public abstract class GPTestCase
25     extends JGAPTestCase {
26
27   protected GPConfiguration m_gpconf;
28
29   protected RandomGeneratorForTest rn;
30
31   protected Constant CMD_CONST0, CMD_CONST1, CMD_CONST2, CMD_CONST3, CMD_CONST4;
32
33   protected Add CMD_ADD;
34
35   protected ForLoop CMD_FOR;
36   protected ForXLoop CMD_FORX;
37
38   protected SubProgram CMD_SUB_V_I, CMD_SUB_V_V_V, CMD_SUB_V_V;
39
40   protected NOP CMD_NOP;
41
42
43   public void setUp() {
44     super.setUp();
45     try {
46       GPConfiguration.reset();
47       m_gpconf = new GPConfiguration();
48       rn = new RandomGeneratorForTest(3);
49       m_gpconf.setRandomGenerator(rn);
50       m_gpconf.setPopulationSize(10);
51       //
52
CMD_CONST0 = new Constant(m_gpconf, CommandGene.IntegerClass,
53                                 new Integer JavaDoc(0));
54       CMD_CONST1 = new Constant(m_gpconf, CommandGene.IntegerClass,
55                                 new Integer JavaDoc(1));
56       CMD_CONST2 = new Constant(m_gpconf, CommandGene.IntegerClass,
57                                 new Integer JavaDoc(2));
58       CMD_CONST3 = new Constant(m_gpconf, CommandGene.IntegerClass,
59                                 new Integer JavaDoc(3));
60       CMD_CONST4 = new Constant(m_gpconf, CommandGene.IntegerClass,
61                                 new Integer JavaDoc(4));
62       CMD_NOP = new NOP(m_gpconf);
63       CMD_FOR = new ForLoop(m_gpconf, CommandGene.IntegerClass, 15);
64       CMD_FORX = new ForXLoop(m_gpconf, CommandGene.IntegerClass);
65       CMD_SUB_V_I = new SubProgram(m_gpconf,
66                                    new Class JavaDoc[] {CommandGene.VoidClass,
67                                    CommandGene.IntegerClass});
68       CMD_SUB_V_V = new SubProgram(m_gpconf,
69                                    new Class JavaDoc[] {CommandGene.VoidClass,
70                                    CommandGene.VoidClass});
71       CMD_SUB_V_V_V = new SubProgram(m_gpconf,
72                                    new Class JavaDoc[] {CommandGene.VoidClass,
73                                    CommandGene.VoidClass,
74                                    CommandGene.VoidClass});
75       CMD_ADD = new Add(m_gpconf, CommandGene.IntegerClass);
76     }
77     catch (Exception JavaDoc ex) {
78       throw new RuntimeException JavaDoc(ex);
79     }
80   }
81
82
83   /** String containing the CVS revision. Read out via reflection!*/
84   private static final String JavaDoc CVS_REVISION = "$Revision: 1.3 $";
85 }
86
Popular Tags