Class gpjpp.GPNode
All Packages Class Hierarchy This Package Previous Next Index
Class gpjpp.GPNode
java.lang.Object
|
+----gpjpp.GPObject
|
+----gpjpp.GPNode
- public class GPNode
- extends GPObject
Stores information about one function or terminal type in
a particular genetic programming problem. GPNode objects are
stored within the container of a
GPNodeSet object,
representing all the node types allowed within one branch
of a genetic program.
- Version:
- 1.0
-
nodeIndex
- A unique index value used to stream genes efficiently.
-
nodeValue
- Indicates a node's purpose to a user fitness evaluation method.
-
numOfArgs
- The number of arguments used by the node, 0 if the node is
a terminal instead of a function.
-
representation
- The string usually printed by printOn when displaying
s-expressions and when drawing graphic tree images.
-
GPNode()
- Public null constructor used during stream loading only.
-
GPNode(GPNode)
- A constructor that can be called to clone a GPNode.
-
GPNode(int, String)
- The constructor called by user code to describe the terminals
for the genetic programming problem.
-
GPNode(int, String, int)
- The constructor called by user code to describe the functions
for the genetic programming problem.
-
arguments()
- Returns the number of arguments to the node.
-
clone()
- Implements the Cloneable interface.
-
equals(Object)
- Determines whether this GPNode equals another object.
-
getIndex()
- Returns the node index used for streaming.
-
isA()
- Returns a code identifying the class in a stream file.
-
isFunction()
- Returns true if the node is a function, that is, has more
than zero arguments.
-
isTerminal()
- Returns true if the node is a terminal, that is, has zero
arguments.
-
load(DataInputStream)
- Loads a GPNode from the specified stream.
-
printOn(PrintStream, GPVariables)
- Writes a GPNode in text format to a PrintStream.
-
rep()
- Returns the string representation of the node.
-
save(DataOutputStream)
- Saves a GPNode to the specified stream.
-
setIndex(byte)
- Sets the node index used for streaming.
-
value()
- Returns the integer node value.
nodeValue
protected int nodeValue
- Indicates a node's purpose to a user fitness evaluation method.
The nodeValue is often the integer value of a character such
as '+' or '-', or is assigned a symbolic constant such as
FROG or MOW.
numOfArgs
protected int numOfArgs
- The number of arguments used by the node, 0 if the node is
a terminal instead of a function. numOfArgs must be in the
range from 0 to 255 when streaming is used, since the
number of arguments is stored on the stream in a single byte.
representation
protected String representation
- The string usually printed by printOn when displaying
s-expressions and when drawing graphic tree images.
nodeIndex
protected byte nodeIndex
- A unique index value used to stream genes efficiently. Its
value is set by the static method
GPGene.createNodeIndex which must be called by the stream
manager before genes are streamed.
- See Also:
- setIndex
GPNode
public GPNode()
- Public null constructor used during stream loading only.
GPNode
public GPNode(int nVal,
String str,
int args)
- The constructor called by user code to describe the functions
for the genetic programming problem.
- Parameters:
- nVal - an arbitrary integer value used to identify
the node type. Must be unique within the branch
(within its GPNodeSet).
- str - a string that is usually written out to
represent the node in s-expressions and
tree diagrams.
- args - the number of arguments to the function.
- See Also:
- nodeValue, numOfArgs
GPNode
public GPNode(int nVal,
String str)
- The constructor called by user code to describe the terminals
for the genetic programming problem.
- Parameters:
- nVal - an arbitrary integer value used to identify
the node type. Must be unique within the branch
(within its GPNodeSet).
- str - a string that is usually written out to
represent the node in s-expressions and
tree diagrams.
- See Also:
- nodeValue, numOfArgs
GPNode
public GPNode(GPNode gpo)
- A constructor that can be called to clone a GPNode. Normally
not used.
clone
protected synchronized Object clone()
- Implements the Cloneable interface.
This clones a GPNode but is normally not used.
- Returns:
- the cloned object.
- Overrides:
- clone in class GPObject
isA
public byte isA()
- Returns a code identifying the class in a stream file.
- Returns:
- the ID code NODEID.
- Overrides:
- isA in class GPObject
value
public int value()
- Returns the integer node value.
rep
public String rep()
- Returns the string representation of the node.
isFunction
public boolean isFunction()
- Returns true if the node is a function, that is, has more
than zero arguments.
isTerminal
public boolean isTerminal()
- Returns true if the node is a terminal, that is, has zero
arguments.
arguments
public int arguments()
- Returns the number of arguments to the node.
setIndex
public void setIndex(byte index)
- Sets the node index used for streaming.
- See Also:
- createNodeIndex
getIndex
public byte getIndex()
- Returns the node index used for streaming.
- See Also:
- createNodeIndex, save
equals
public boolean equals(Object obj)
- Determines whether this GPNode equals another object. It returns
true if obj is not null, is an instance of a GPNode (or a
descendant), and has the same value, number of arguments,
and string representation. This function is called when a
checkpoint is loaded by GPRun, to determine whether the
program and the checkpoint are consistent.
- Parameters:
- obj - any Java object reference, including null.
- Returns:
- true if this and obj are equivalent.
- Overrides:
- equals in class Object
load
protected synchronized void load(DataInputStream is) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
- Loads a GPNode from the specified stream. Reads the
nodeValue, numOfArgs, and representation fields from the
stream.
- Throws: ClassNotFoundException
- if the class indicated by the stream's ID code
is not registered with GPObject.
- Throws: InstantiationException
- if an error occurs while calling new or the null
constructor of the specified class.
- Throws: IllegalAccessException
- if the specified class or its null constructor is
not public.
- Throws: IOException
- if an error occurs while reading the stream.
- Overrides:
- load in class GPObject
save
protected void save(DataOutputStream os) throws IOException
- Saves a GPNode to the specified stream. Writes the
nodeValue, numOfArgs, and representation fields to the
stream.
- Throws: IOException
- if an error occurs while writing the stream.
- Overrides:
- save in class GPObject
printOn
public void printOn(PrintStream os,
GPVariables cfg)
- Writes a GPNode in text format to a PrintStream.
The node is printed simply as its representation string.
- Overrides:
- printOn in class GPObject
All Packages Class Hierarchy This Package Previous Next Index