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

Variable Index

 o nodeIndex
A unique index value used to stream genes efficiently.
 o nodeValue
Indicates a node's purpose to a user fitness evaluation method.
 o numOfArgs
The number of arguments used by the node, 0 if the node is a terminal instead of a function.
 o representation
The string usually printed by printOn when displaying s-expressions and when drawing graphic tree images.

Constructor Index

 o GPNode()
Public null constructor used during stream loading only.
 o GPNode(GPNode)
A constructor that can be called to clone a GPNode.
 o GPNode(int, String)
The constructor called by user code to describe the terminals for the genetic programming problem.
 o GPNode(int, String, int)
The constructor called by user code to describe the functions for the genetic programming problem.

Method Index

 o arguments()
Returns the number of arguments to the node.
 o clone()
Implements the Cloneable interface.
 o equals(Object)
Determines whether this GPNode equals another object.
 o getIndex()
Returns the node index used for streaming.
 o isA()
Returns a code identifying the class in a stream file.
 o isFunction()
Returns true if the node is a function, that is, has more than zero arguments.
 o isTerminal()
Returns true if the node is a terminal, that is, has zero arguments.
 o load(DataInputStream)
Loads a GPNode from the specified stream.
 o printOn(PrintStream, GPVariables)
Writes a GPNode in text format to a PrintStream.
 o rep()
Returns the string representation of the node.
 o save(DataOutputStream)
Saves a GPNode to the specified stream.
 o setIndex(byte)
Sets the node index used for streaming.
 o value()
Returns the integer node value.

Variables

 o 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.
 o 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.
 o representation
  protected String representation
The string usually printed by printOn when displaying s-expressions and when drawing graphic tree images.
 o 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

Constructors

 o GPNode
  public GPNode()
Public null constructor used during stream loading only.
 o 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
 o 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
 o GPNode
  public GPNode(GPNode gpo)
A constructor that can be called to clone a GPNode. Normally not used.

Methods

 o 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
 o isA
  public byte isA()
Returns a code identifying the class in a stream file.
Returns:
the ID code NODEID.
Overrides:
isA in class GPObject
 o value
  public int value()
Returns the integer node value.
 o rep
  public String rep()
Returns the string representation of the node.
 o isFunction
  public boolean isFunction()
Returns true if the node is a function, that is, has more than zero arguments.
 o isTerminal
  public boolean isTerminal()
Returns true if the node is a terminal, that is, has zero arguments.
 o arguments
  public int arguments()
Returns the number of arguments to the node.
 o setIndex
  public void setIndex(byte index)
Sets the node index used for streaming.
See Also:
createNodeIndex
 o getIndex
  public byte getIndex()
Returns the node index used for streaming.
See Also:
createNodeIndex, save
 o 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
 o 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
 o 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
 o 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