gpsys
Class GeneTerminal

java.lang.Object
  |
  +--gpsys.Gene
        |
        +--gpsys.GeneTerminal

public class GeneTerminal
extends Gene
implements java.lang.Cloneable

A GeneTerminal is a leaf in a Gene tree and represents a Terminal.

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

Fields inherited from class gpsys.Gene
p
 
Constructor Summary
(package private) GeneTerminal(int maxDepth, Type type, GPParameters gpParameters, int adfIndex)
          Constructs a Gene Terminal by randomly selecting a Terminal of the required type from the Terminal set of the associated Chromosome.
 
Method Summary
 int complexity()
          Get the number of Genes in this Gene.
 Gene deepClone()
          Make a clone of this Gene.
 int depth()
          Calculate the maximum depth of this Gene.
 boolean evaluateBoolean(Individual i)
          Evaluate this Gene as Terminal returning a boolean.
 byte evaluateByte(Individual i)
          Evaluate this Gene as Terminal returning a byte.
 char evaluateChar(Individual i)
          Evaluate this Gene as Terminal returning a char.
 double evaluateDouble(Individual i)
          Evaluate this Gene as Terminal returning a double.
 float evaluateFloat(Individual i)
          Evaluate this Gene as Terminal returning a float.
 int evaluateInt(Individual i)
          Evaluate this Gene as Terminal returning an int.
 long evaluateLong(Individual i)
          Evaluate this Gene as Terminal returning a long.
 java.lang.Object evaluateObject(Individual i)
          Evaluate this Gene as Terminal returning an Object reference.
 short evaluateShort(Individual i)
          Evaluate this Gene as Terminal returning a short.
 java.lang.String toString()
          Create a String representing this Gene.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Constructor Detail

GeneTerminal

GeneTerminal(int maxDepth,
             Type type,
             GPParameters gpParameters,
             int adfIndex)
       throws TypeException
Constructs a Gene Terminal by randomly selecting a Terminal of the required type from the Terminal set of the associated Chromosome.
Parameters:
maxDepth - the maximum depth of the Gene tree to be generated.
type - the required return type of top node in the tree.
gpParameters - the GP parameters for this run.
adfIndex - the index of the ChromosomeParameters to used.
Throws:
TypeException - If no Terminal of the required type could be found.
Method Detail

evaluateObject

public java.lang.Object evaluateObject(Individual i)
                                throws EvaluationException
Evaluate this Gene as Terminal returning an Object reference.
Parameters:
i - the individual to which this Gene belongs
Returns:
An Object which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateObject in class Gene

evaluateByte

public byte evaluateByte(Individual i)
                  throws EvaluationException
Evaluate this Gene as Terminal returning a byte.
Parameters:
i - the individual to which this Gene belongs
Returns:
A byte which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateByte in class Gene

evaluateShort

public short evaluateShort(Individual i)
                    throws EvaluationException
Evaluate this Gene as Terminal returning a short.
Parameters:
i - the individual to which this Gene belongs
Returns:
A short which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateShort in class Gene

evaluateInt

public int evaluateInt(Individual i)
                throws EvaluationException
Evaluate this Gene as Terminal returning an int.
Parameters:
i - the individual to which this Gene belongs
Returns:
An int which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateInt in class Gene

evaluateLong

public long evaluateLong(Individual i)
                  throws EvaluationException
Evaluate this Gene as Terminal returning a long.
Parameters:
i - the individual to which this Gene belongs
Returns:
A long which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateLong in class Gene

evaluateFloat

public float evaluateFloat(Individual i)
                    throws EvaluationException
Evaluate this Gene as Terminal returning a float.
Parameters:
i - the individual to which this Gene belongs
Returns:
A float which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateFloat in class Gene

evaluateDouble

public double evaluateDouble(Individual i)
                      throws EvaluationException
Evaluate this Gene as Terminal returning a double.
Parameters:
i - the individual to which this Gene belongs
Returns:
A double which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateDouble in class Gene

evaluateChar

public char evaluateChar(Individual i)
                  throws EvaluationException
Evaluate this Gene as Terminal returning a char.
Parameters:
i - the individual to which this Gene belongs
Returns:
A char which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateChar in class Gene

evaluateBoolean

public boolean evaluateBoolean(Individual i)
                        throws EvaluationException
Evaluate this Gene as Terminal returning a boolean.
Parameters:
i - the individual to which this Gene belongs
Returns:
A boolean which is the result of the evaluation.
Throws:
EvaluationException - If there is an evaluation failure.
Overrides:
evaluateBoolean in class Gene

depth

public int depth()
Calculate the maximum depth of this Gene. The result is always one since this Gene represents a Terminal.
Returns:
1, this the depth of any Terminal.
Overrides:
depth in class Gene

complexity

public int complexity()
Get the number of Genes in this Gene.
Returns:
1, since it represents a Terminal.
Overrides:
complexity in class Gene

deepClone

public Gene deepClone()
Make a clone of this Gene.
Returns:
a clone of this Gene.
Overrides:
deepClone in class Gene

toString

public java.lang.String toString()
Create a String representing this Gene.
Returns:
a String representing this tree.
Overrides:
toString in class Gene