gpsys
Class Gene

java.lang.Object
  |
  +--gpsys.Gene
Direct Known Subclasses:
GeneFunction, GeneTerminal

public abstract class Gene
extends java.lang.Object
implements java.io.Serializable

A Gene is a node in a GP tree. A Gene can be either a function or a terminal, hence this abstract class has been subclassed to GeneFunction and GeneTerminal which are actually used.

Version:
$Revision: 1.1 $, $Date: 2000/07/05 16:21:25 $
Author:
Adil Qureshi
Department of Computer Science,
University College London,
Gower St,
London WC1E 6BT,
UK.
See Also:
Serialized Form

Field Summary
 Primitive p
          The primitive associated with this Gene which is either a Function or a Terminal.
 
Constructor Summary
Gene()
           
 
Method Summary
abstract  int complexity()
          Calculates the number of nodes (Genes) in the subtree starting at this node (Gene).
abstract  Gene deepClone()
          Makes a deep clone of this Gene, i.e.
abstract  int depth()
          Calculates the maximum depth of the subtree starting at this node (Gene).
abstract  boolean evaluateBoolean(Individual i)
          Evaluate this Gene as a Gene that returns a boolean when evaluated.
abstract  byte evaluateByte(Individual i)
          Evaluate this Gene as a Gene that returns a byte when evaluated.
abstract  char evaluateChar(Individual i)
          Evaluate this Gene as a Gene that returns a char when evaluated.
abstract  double evaluateDouble(Individual i)
          Evaluate this Gene as a Gene that returns a double when evaluated.
abstract  float evaluateFloat(Individual i)
          Evaluate this Gene as a Gene that returns a float when evaluated.
abstract  int evaluateInt(Individual i)
          Evaluate this Gene as a Gene that returns a int when evaluated.
abstract  long evaluateLong(Individual i)
          Evaluate this Gene as a Gene that returns a long when evaluated.
abstract  java.lang.Object evaluateObject(Individual i)
          Evaluate this Gene as a Gene that returns an Object when evaluated.
abstract  short evaluateShort(Individual i)
          Evaluate this Gene as a Gene that returns a short when evaluated.
abstract  java.lang.String toString()
          Converts the Gene and its subtrees into a String.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

p

public Primitive p
The primitive associated with this Gene which is either a Function or a Terminal.
Constructor Detail

Gene

public Gene()
Method Detail

complexity

public abstract int complexity()
Calculates the number of nodes (Genes) in the subtree starting at this node (Gene).

depth

public abstract int depth()
Calculates the maximum depth of the subtree starting at this node (Gene).

evaluateObject

public abstract java.lang.Object evaluateObject(Individual i)
                                         throws EvaluationException
Evaluate this Gene as a Gene that returns an Object when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
An Object which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateByte

public abstract byte evaluateByte(Individual i)
                           throws EvaluationException
Evaluate this Gene as a Gene that returns a byte when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A byte which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateShort

public abstract short evaluateShort(Individual i)
                             throws EvaluationException
Evaluate this Gene as a Gene that returns a short when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A short which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateInt

public abstract int evaluateInt(Individual i)
                         throws EvaluationException
Evaluate this Gene as a Gene that returns a int when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A int which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateLong

public abstract long evaluateLong(Individual i)
                           throws EvaluationException
Evaluate this Gene as a Gene that returns a long when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A long which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateFloat

public abstract float evaluateFloat(Individual i)
                             throws EvaluationException
Evaluate this Gene as a Gene that returns a float when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A float which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateDouble

public abstract double evaluateDouble(Individual i)
                               throws EvaluationException
Evaluate this Gene as a Gene that returns a double when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A double which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateChar

public abstract char evaluateChar(Individual i)
                           throws EvaluationException
Evaluate this Gene as a Gene that returns a char when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A char which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateBoolean

public abstract boolean evaluateBoolean(Individual i)
                                 throws EvaluationException
Evaluate this Gene as a Gene that returns a boolean when evaluated.
Parameters:
i - the Individual being evaluated.
Returns:
A boolean which is the evaluation result.
Throws:
EvaluationException - If there is an evaluation failure.

deepClone

public abstract Gene deepClone()
Makes a deep clone of this Gene, i.e. the Gene and all of it's subtrees.
Returns:
A clone of the Gene and its subtrees.

toString

public abstract java.lang.String toString()
Converts the Gene and its subtrees into a String.
Returns:
A String representing the Gene and any subtrees.
Overrides:
toString in class java.lang.Object