|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.epochx.representation.CandidateProgram<TYPE>
public class CandidateProgram<TYPE>
A CandidateProgram encapsulates an individual program within a
generation of a GP run.
Instances of CandidateProgram can be requested to evaluate themselves,
which will trigger an evaluation of each Node and their child
nodes recursively down the tree. As well as the program tree itself, each
CandidateProgram allows the retrieval of meta-data about the program.
| Constructor Summary | |
|---|---|
CandidateProgram(Node<TYPE> rootNode,
GPModel<TYPE> model)
Constructs a new program individual where rootNode is the
top most node in the program, and which may have 0 or more child nodes. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
Creates and returns a copy of this program. |
int |
compareTo(CandidateProgram<TYPE> o)
Compares this program to another based upon fitness. |
boolean |
equals(java.lang.Object obj)
This equals method compares the given object to this CandidateProgram to determine if they are equal. |
TYPE |
evaluate()
Evaluates the candidate program by triggering a recursive evaluation of the node tree from the root. |
double |
getFitness()
Requests the controlling model to calculate the fitness of this CandidateProgram. |
java.util.List<Node<TYPE>> |
getNodesAtDepth(int depth)
Retrieves all the nodes in the program tree at a specified depth. |
int |
getNoDistinctFunctions()
Returns a count of how many unique function nodes are in the program tree. |
int |
getNoDistinctTerminals()
Returns a count of how many unique terminal nodes are in the program tree. |
int |
getNoFunctions()
Returns a count of how many function nodes are in the program tree. |
int |
getNoTerminals()
Returns a count of how many terminal nodes are in the program tree. |
Node<TYPE> |
getNthNode(int n)
Returns the nth node in the CandidateProgram. |
int |
getProgramDepth()
Returns the depth of deepest node in the program tree. |
int |
getProgramLength()
Returns the number of nodes in the program tree. |
Node<TYPE> |
getRootNode()
Returns the root node of the node tree held by the candidate program. |
void |
setNthNode(int n,
Node<TYPE> newNode)
Replaces the node at the specified position in the CandidateProgram with the specified node. |
java.lang.String |
toString()
Return a string representation of the program node tree. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public CandidateProgram(Node<TYPE> rootNode,
GPModel<TYPE> model)
rootNode is the
top most node in the program, and which may have 0 or more child nodes.
rootNode - the Node of the program tree which is the parent to
all other nodes. It may be either a FunctionNode or a
TerminalNodemodel - the controlling model which provides the configuration
parameters for the run.| Method Detail |
|---|
public TYPE evaluate()
public Node<TYPE> getRootNode()
public Node<TYPE> getNthNode(int n)
CandidateProgram. The program
tree is traversed in pre-order (depth-first), indexed from 0 so that the
root node is at node 0.
n - The index of the node required. Indexes are from zero.
public void setNthNode(int n,
Node<TYPE> newNode)
n - index of the node to replace.newNode - node to be set at the specified position.public java.util.List<Node<TYPE>> getNodesAtDepth(int depth)
depth - the specified depth of the nodes.
public double getFitness()
CandidateProgram.
public int getNoTerminals()
public int getNoDistinctTerminals()
public int getNoFunctions()
public int getNoDistinctFunctions()
public int getProgramDepth()
public int getProgramLength()
public int compareTo(CandidateProgram<TYPE> o)
compareTo in interface java.lang.Comparable<CandidateProgram<TYPE>>o - the CandidateProgram to be compared.
public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - an object to be compared for equivalence.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||