Class gpjpp.GPObject
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpjpp.GPObject

java.lang.Object
   |
   +----gpjpp.GPObject

public class GPObject
extends Object
implements Cloneable
Abstract class used to define cloning and streaming capabilities. All gpjpp classes that can be streamed are subclasses of GPObject.
Version:
1.0

Variable Index

 o ADFNODESETID
An ID code used to identify GPAdfNodeSet references in gpjpp streams.
 o CONTAINERID
An ID code used to identify GPContainer references in gpjpp streams.
 o GENEID
An ID code used to identify GPGene references in gpjpp streams.
 o GENEPRINTID
An ID code used to identify GPGenePrint references in gpjpp streams.
 o GPID
An ID code used to identify GP references in gpjpp streams.
 o NODEID
An ID code used to identify GPNode references in gpjpp streams.
 o NODESETID
An ID code used to identify GPNodeSet references in gpjpp streams.
 o NULLID
An ID code used to identify null object references in gpjpp streams.
 o OBJECTID
An ID code used to identify GPObject references in gpjpp streams.
 o POPULATIONID
An ID code used to identify GPPopulation references in gpjpp streams.
 o USERGENEID
An ID code normally used to identify the user subclass of GPGene.
 o USERGPID
An ID code normally used to identify the user subclass of GP.
 o USERPOPULATIONID
An ID code normally used to identify the user subclass of GPPopulation.
 o USERVARIABLESID
An ID code normally used to identify the user subclass of GPVariables.
 o VARIABLESID
An ID code used to identify GPVariables references in gpjpp streams.

Constructor Index

 o GPObject()
This do-nothing constructor gets called implicitly by subclasses of GPObject.

Method Index

 o clone()
Implements the Cloneable interface.
 o createRegisteredClassObject(byte)
Creates an object of specified ID and returns it.
 o findRegisteredClass(byte)
Returns index of existing registered class, -1 if not found.
 o isA()
Returns a code identifying the class in a stream file.
 o load(DataInputStream)
Loads a GPObject subclass from the specified stream.
 o printOn(PrintStream, GPVariables)
Writes a GPObject subclass in text format to a PrintStream.
 o registerClass(byte, Class)
Registers a single class.
 o registerClass(GPObject)
Registers the class of the specified object and all of its non-abstract superclasses up to but not including GPObject.
 o save(DataOutputStream)
Saves a GPObject subclass to the specified stream.

Variables

 o NULLID
  protected final static byte NULLID
An ID code used to identify null object references in gpjpp streams.
 o OBJECTID
  protected final static byte OBJECTID
An ID code used to identify GPObject references in gpjpp streams. This code is not written to streams under normal circumstances, since GPObject is an abstract class.
 o CONTAINERID
  protected final static byte CONTAINERID
An ID code used to identify GPContainer references in gpjpp streams. This code is not written to streams under normal circumstances, since GPContainer subclasses provide their own ID codes.
 o NODEID
  protected final static byte NODEID
An ID code used to identify GPNode references in gpjpp streams. A GPNode defines the identifying code, number of arguments, and string representation for every function and terminal in a genetic program.
 o NODESETID
  protected final static byte NODESETID
An ID code used to identify GPNodeSet references in gpjpp streams. A GPNodeSet contains all the GPNode values for a particular branch (main result-producing or ADF) of a genetic program.
 o ADFNODESETID
  protected final static byte ADFNODESETID
An ID code used to identify GPAdfNodeSet references in gpjpp streams. A GPAdfNodeSet contains all the GPNodeSet containers for a genetic program.
 o VARIABLESID
  protected final static byte VARIABLESID
An ID code used to identify GPVariables references in gpjpp streams. A GPVariables contains all the settings that specify the behavior of a genetic programming test. A user subclass of GPVariables is often, but not always, defined to specify additional problem-specific variables.
 o GENEID
  protected final static byte GENEID
An ID code used to identify GPGene references in gpjpp streams. A GPGene is one node of a genetic program parse tree and includes a reference to a GPNode and a container holding references to the arguments of the node, if any. This ID code may appear hundreds of thousands of times in a stream. A user subclass of GPGene is almost always defined to implement a problem-specific fitness calculation for each gene tree.
 o GPID
  protected final static byte GPID
An ID code used to identify GP references in gpjpp streams. GP is a container holding references to a GPGene for each branch of the genetic program, including one for the main result-producing branch and zero or more for the ADFs of the program. There is a GP for each member of the population. A user subclass of GP is always defined to implement a problem-specific fitness calculation for each genetic program.
 o POPULATIONID
  protected final static byte POPULATIONID
An ID code used to identify GPPopulation references in gpjpp streams. GPPopulation is a container holding references to a GP for each individual in the population. A user subclass of GPPopulation is always defined to create GP subclass instances when the program needs them.
 o GENEPRINTID
  protected final static byte GENEPRINTID
An ID code used to identify GPGenePrint references in gpjpp streams. This code is not written to streams under normal circumstances, and the GPGenePrint load and save methods do nothing.
 o USERGENEID
  public final static byte USERGENEID
An ID code normally used to identify the user subclass of GPGene.
 o USERGPID
  public final static byte USERGPID
An ID code normally used to identify the user subclass of GP.
 o USERPOPULATIONID
  public final static byte USERPOPULATIONID
An ID code normally used to identify the user subclass of GPPopulation.
 o USERVARIABLESID
  public final static byte USERVARIABLESID
An ID code normally used to identify the user subclass of GPVariables. For any stream classes besides those discussed here, use ID codes larger than USERVARIABLESID.

Constructors

 o GPObject
  protected GPObject()
This do-nothing constructor gets called implicitly by subclasses of GPObject.

Methods

 o clone
  protected synchronized abstract Object clone()
Implements the Cloneable interface. GPGene and GP classes are cloned during reproduction and crossover.
Returns:
the cloned object.
Overrides:
clone in class Object
 o isA
  public abstract byte isA()
Returns a code identifying the class in a stream file. Every class in a streamed gpjpp program must override isA() and return a unique byte. Predefined ID values are provided for the built-in gpjpp classes and the classes a user is expected to provide.
Returns:
the unique ID code.
See Also:
OBJECTID
 o load
  protected synchronized abstract void load(DataInputStream is) throws ClassNotFoundException, IOException, InstantiationException, IllegalAccessException
Loads a GPObject subclass from the specified stream. The object calling this method should have been previously constructed using its null constructor.
Parameters:
is - a formatted input 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.
 o save
  protected abstract void save(DataOutputStream os) throws IOException
Saves a GPObject subclass to the specified stream.
Parameters:
os - a formatted output stream.
Throws: IOException
if an error occurs while writing the stream.
 o printOn
  public abstract void printOn(PrintStream os,
                               GPVariables cfg)
Writes a GPObject subclass in text format to a PrintStream. Every gpjpp subclass overrides this method to print a text representation of the class' current state. Because printOn writes to a PrintStream, it does not generate IOExceptions. PrintStream traps exceptions, which can be checked via its checkError() method.
Parameters:
os - a PrintStream.
cfg - the set of gpjpp configuration variables, sometimes used to control the output.
 o findRegisteredClass
  protected static int findRegisteredClass(byte id)
Returns index of existing registered class, -1 if not found. For internal use.
 o createRegisteredClassObject
  public static GPObject createRegisteredClassObject(byte id) throws InstantiationException, IllegalAccessException
Creates an object of specified ID and returns it. This method is called by appropriate load() methods in the gpjpp class hierarchy.
Parameters:
id - the registered ID code for the class type to create.
Returns:
an object of the specified type, created via its null constructor. Returns null if the ID code does not specify a registered type.
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.
 o registerClass
  protected static void registerClass(byte id,
                                      Class c)
Registers a single class. For internal use.
 o registerClass
  public static void registerClass(GPObject gpo) throws IllegalAccessException
Registers the class of the specified object and all of its non-abstract superclasses up to but not including GPObject.
Parameters:
gpo - an instance of the class to register
Throws: IllegalAccessException
if a superclass of the specified class or its null constructor is not public.

All Packages  Class Hierarchy  This Package  Previous  Next  Index