KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.*;
13 import org.jgap.gp.impl.*;
14 /**
15  * Interface for GP chromosomes. See ProgramChromosome for an implementation.
16  *
17  * @author Klaus Meffert
18  * @since 3.01
19  */

20 public interface IGPChromosome
21     extends Serializable {
22   /** String containing the CVS revision. Read out via reflection!*/
23   final static String JavaDoc CVS_REVISION = "$Revision: 1.2 $";
24
25   /**
26    * @return the individual containing this chromosome
27    *
28    * @author Klaus Meffert
29    * @since 3.01
30    */

31   IGPProgram getIndividual();
32
33   /**
34    * Sets the individual the chromosome belongs to.
35    *
36    * @param a_ind the individual containing this chromosome
37    *
38    * @author Klaus Meffert
39    * @since 3.01
40    */

41   void setIndividual(IGPProgram a_ind);
42
43   /**
44    * Clean up the chromosome.
45    *
46    * @author Klaus Meffert
47    * @since 3.01
48    */

49   void cleanup();
50
51   /**
52    * Output program in "natural" notion (e.g.: "X + Y" for "X + Y")
53    * @param a_startNode the node to start with
54    * @return output in normalized notion
55    *
56    * @author Klaus Meffert
57    * @since 3.01
58    */

59   String JavaDoc toStringNorm(final int a_startNode);
60
61   /**
62    * Recalculate the depths of each node.
63    *
64    * @author Klaus Meffert
65    * @since 3.01
66    */

67   void redepth();
68
69   /**
70    * @return the number of terminals in this chromosome
71    *
72    * @author Klaus Meffert
73    * @since 3.01
74    */

75   int numTerminals();
76
77   /**
78    * @return the number of functions in this chromosome
79    *
80    * @author Klaus Meffert
81    * @since 3.01
82    */

83   int numFunctions();
84
85   /**
86    * Counts the number of terminals of the given type in this chromosome.
87    *
88    * @param a_type the type of terminal to count
89    * @param a_subType the subtype to consider
90    * @return the number of terminals in this chromosome
91    *
92    * @author Klaus Meffert
93    * @since 3.01
94    */

95   int numTerminals(Class JavaDoc a_type, int a_subType);
96
97   /**
98    * Counts the number of functions of the given type in this chromosome.
99    *
100    * @param a_type the type of function to count
101    * @param a_subType the subtype to consider
102    * @return the number of functions in this chromosome.
103    *
104    * @author Klaus Meffert
105    * @since 3.01
106    */

107   int numFunctions(Class JavaDoc a_type, int a_subType);
108
109   /**
110    * Gets the a_index'th node in this chromosome. The nodes are counted in a
111    * depth-first manner, with node 0 being the root of this chromosome.
112    *
113    * @param a_index the node number to get
114    * @return the node
115    *
116    * @author Klaus Meffert
117    * @since 3.01
118    */

119   CommandGene getNode(int a_index);
120
121   /**
122    * Gets the a_child'th child of the a_index'th node in this chromosome. This
123    * is the same as the a_child'th node whose depth is one more than the depth
124    * of the a_index'th node.
125    *
126    * @param a_index the node number of the parent
127    * @param a_child the child number (starting from 0) of the parent
128    * @return the node number of the child, or -1 if not found
129    *
130    * @author Klaus Meffert
131    * @since 3.01
132    */

133   int getChild(int a_index, int a_child);
134
135   /**
136    * Gets the i'th terminal in this chromosome. The nodes are counted in a
137    * depth-first manner, with node 0 being the first terminal in this
138    * chromosome.
139    *
140    * @param a_index the i'th terminal to get
141    * @return the terminal
142    *
143    * @author Klaus Meffert
144    * @since 3.01
145    */

146   int getTerminal(int a_index);
147
148   /**
149    * Gets the a_index'th function in this chromosome. The nodes are counted in a
150    * depth-first manner, with node 0 being the first function in this
151    * chromosome.
152    *
153    * @param a_index the a_index'th function to get
154    * @return the function
155    *
156    * @author Klaus Meffert
157    * @since 3.01
158    */

159   int getFunction(int a_index);
160
161   /**
162    * Gets the a_index'th terminal of the given type in this chromosome. The nodes
163    * are counted in a depth-first manner, with node 0 being the first terminal of
164    * the given type in this chromosome.
165    *
166    * @param a_index the a_index'th terminal to get
167    * @param a_type the type of terminal to get
168    * @param a_subType the subtype to consider
169    * @return the index of the terminal found, or -1 if no appropriate terminal
170    * was found
171    *
172    * @author Klaus Meffert
173    * @since 3.01
174    */

175   int getTerminal(int a_index, Class JavaDoc a_type, int a_subType);
176
177   /**
178    * Gets the i'th function of the given type in this chromosome. The nodes are
179    * counted in a depth-first manner, with node 0 being the first function of
180    * the given type in this chromosome.
181    *
182    * @param a_index the i'th function to get
183    * @param a_type the type of function to get
184    * @param a_subType the subtype to consider
185    * @return the index of the function found, or -1 if no appropriate function
186    * was found
187    *
188    * @author Klaus Meffert
189    * @since 3.01
190    */

191   int getFunction(int a_index, Class JavaDoc a_type, int a_subType);
192
193   CommandGene[] getFunctions();
194
195   GPConfiguration getGPConfiguration();
196 }
197
Popular Tags