|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.groovyj.jgprog.Chromosome
Represents a single chromosome.
Copyright (c) 2000 Robert Baruch. This code is released under the GNU General Public License (GPL).
| Constructor Summary | |
Chromosome()
Construct an empty chromosome |
|
Chromosome(Chromosome c)
Perform a deep copy of a chromosome. |
|
| Method Summary | |
boolean |
execute_boolean()
Executes this node as a boolean. |
boolean |
execute_boolean(int n,
int child)
|
double |
execute_double()
Executes this node as a double. |
double |
execute_double(int n,
int child)
|
float |
execute_float()
Executes this node as a float. |
float |
execute_float(int n,
int child)
|
int |
execute_int()
Executes this node as an integer. |
int |
execute_int(int n,
int child)
|
long |
execute_long()
Executes this node as a long. |
long |
execute_long(int n,
int child)
|
java.lang.Object |
execute_object()
Executes this node as an object. |
java.lang.Object |
execute_object(int n,
int child)
|
void |
execute_void()
Executes this node, returning nothing. |
void |
execute_void(int n,
int child)
|
java.lang.Object |
execute()
Executes this node without knowing its return type. |
java.lang.Object |
execute(int n,
int child)
|
void |
full(int num,
int depth,
Type type,
Type[] argTypes,
Function[] functionSet)
Initialize this chromosome using the full method. |
int |
getChild(int n,
int child)
|
int |
getDepth(int n)
|
int |
getFunction(int i)
Gets the i'th function in this chromosome. |
int |
getFunction(int i,
Type type)
Gets the i'th function of the given type in this chromosome. |
Function |
getNode(int i)
Gets the i'th node in this chromosome. |
int |
getNode(int i,
Type type)
Gets the i'th node of the given type in this chromosome. |
int |
getParentNode(int child)
Gets the node which is the parent of the given node in this chromosome. |
int |
getSize(int n)
|
int |
getTerminal(int i)
Gets the i'th terminal in this chromosome. |
int |
getTerminal(int i,
Type type)
Gets the i'th terminal of the given type in this chromosome. |
void |
grow(int num,
int depth,
Type type,
Type[] argTypes,
Function[] functionSet)
Initialize this chromosome using the grow method. |
boolean |
isPossible(Function f)
|
static boolean |
isPossible(Type type,
Function[] nodeSet,
boolean function)
Determines whether there exists a function or terminal in the given node set with the given type. |
static void |
main(java.lang.String[] args)
|
int |
numFunctions()
Counts the number of functions in this chromosome. |
int |
numFunctions(Type type)
Counts the number of functions of the given type in this chromosome. |
int |
numTerminals()
Counts the number of terminals in this chromosome. |
int |
numTerminals(Type type)
Counts the number of terminals of the given type in this chromosome. |
void |
redepth()
|
protected int |
redepth(int n)
|
static Function |
selectNode(Type type,
Function[] functionSet,
boolean function,
boolean growing)
Randomly chooses a node from the node set. |
java.lang.String |
toString()
Returns the string representing this chromosome. |
protected java.lang.String |
toString(int n)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Chromosome(Chromosome c)
c - the chromosome to copypublic Chromosome()
| Method Detail |
public static boolean isPossible(Type type,
Function[] nodeSet,
boolean function)
type - the type to look fornodeSet - the array of nodes to look throughfunction - true to look for a function, false to look for a terminalpublic boolean isPossible(Function f)
public static Function selectNode(Type type,
Function[] functionSet,
boolean function,
boolean growing)
type - the type of node to choosenodeSet - the array of nodes to choose fromfunction - true to choose a function, false to choose a terminalgrowing - true to ignore the function parameter, false otherwise
public void full(int num,
int depth,
Type type,
Type[] argTypes,
Function[] functionSet)
num - the number of this chromosomedepth - the depth of the chromosome to createtype - the type of the chromosome to createargTypes - the array of types of arguments for this chromosomefunctionSetSet - the set of nodes valid to pick from
public void grow(int num,
int depth,
Type type,
Type[] argTypes,
Function[] functionSet)
num - the chromosome number of this chromosomedepth - the maximum depth of the chromosome to createtype - the type of the chromosome to createargTypes - the array of types of arguments for this chromosomefunctionSet - the set of nodes valid to pick fromprotected java.lang.String toString(int n)
public java.lang.String toString()
toString in class java.lang.Objectpublic void redepth()
protected int redepth(int n)
public int numTerminals()
public int numFunctions()
public int numTerminals(Type type)
type - the type of terminal to countpublic int numFunctions(Type type)
type - the type of function to countpublic Function getNode(int i)
i - the node number to get
public int getChild(int n,
int child)
public int getNode(int i,
Type type)
i - the node number to gettype - the type of node to getpublic int getTerminal(int i)
i - the terminal number to getpublic int getFunction(int i)
i - the function number to get
public int getTerminal(int i,
Type type)
i - the terminal number to gettype - the type of terminal to get
public int getFunction(int i,
Type type)
i - the function number to gettype - the type of function to getpublic int getSize(int n)
public int getDepth(int n)
public int getParentNode(int child)
child - the child nodepublic boolean execute_boolean()
UnsupportedOperationException - if the type of this node is not boolean
public boolean execute_boolean(int n,
int child)
public void execute_void()
UnsupportedOperationException - if the type of this node is not void
public void execute_void(int n,
int child)
public int execute_int()
UnsupportedOperationException - if the type of this node is not integer
public int execute_int(int n,
int child)
public long execute_long()
UnsupportedOperationException - if the type of this node is not long
public long execute_long(int n,
int child)
public float execute_float()
UnsupportedOperationException - if the type of this node is not float
public float execute_float(int n,
int child)
public double execute_double()
UnsupportedOperationException - if the type of this node is not double
public double execute_double(int n,
int child)
public java.lang.Object execute_object()
UnsupportedOperationException - if the type of this node is not object
public java.lang.Object execute_object(int n,
int child)
public java.lang.Object execute()
public java.lang.Object execute(int n,
int child)
public static void main(java.lang.String[] args)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||