gpsys
Class Chromosome

java.lang.Object
  |
  +--gpsys.Chromosome

public class Chromosome
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

A Chromosome defines an evolvable gene tree.

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:
Terminal, Serialized Form

Field Summary
(package private)  int adf
          index into the adf array in the gpParameters.
(package private)  int complexity
          A count of the total number of nodes in this tree.
 GPParameters gpParameters
          The GPParameters used to create this chromosome
 Gene treeTop
          The Gene at the top of the tree.
 
Constructor Summary
(package private) Chromosome(GPParameters p, int adfIndex)
          Constructs a new Chromosome using the specified GPParameters.
 
Method Summary
 int complexity()
          Calculates the number of nodes in the Gene tree of this Chromosome.
static Chromosome cross(Chromosome mum, Chromosome dad)
          Creates a new child Chromosome via crossover of the mother and father Chromosomes.
 Chromosome deepClone()
          Makes a deep copy of this Chromsome by making a copy of the entire data graph.
 boolean evaluateBoolean(Individual i)
          Evaluates the chromosome so that it returns a boolean.
 byte evaluateByte(Individual i)
          Evaluates the chromosome so that it returns a byte.
 char evaluateChar(Individual i)
          Evaluates the chromosome so that it returns a char.
 double evaluateDouble(Individual i)
          Evaluates the chromosome so that it returns a double.
 float evaluateFloat(Individual i)
          Evaluates the chromosome so that it returns a float.
 int evaluateInt(Individual i)
          Evaluates the chromosome so that it returns an int.
 long evaluateLong(Individual i)
          Evaluates the chromosome so that it returns a long.
 java.lang.Object evaluateObject(Individual i)
          Evaluates the chromosome so that it returns an Object reference.
 short evaluateShort(Individual i)
          Evaluates the chromosome so that it returns a byte.
static Chromosome mutate(Chromosome mum)
          Creates a new child Chromosome which is a mutation of the mother.
 java.lang.String toString()
          Generates a String representing a dump of the Gene tree for this Chromosome.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

treeTop

public Gene treeTop
The Gene at the top of the tree. this gene is evaulated when this ADF needs evaluation
See Also:
Gene

gpParameters

public GPParameters gpParameters
The GPParameters used to create this chromosome
See Also:
GPParameters

adf

int adf
index into the adf array in the gpParameters. It is used to acces the ChromosomeParameters associated with this chromosome.

complexity

int complexity
A count of the total number of nodes in this tree.
Constructor Detail

Chromosome

Chromosome(GPParameters p,
           int adfIndex)
     throws TypeException
Constructs a new Chromosome using the specified GPParameters.
Parameters:
p - the GPParameters to use.
adfIndex - the index into the adf array in GPParameters the latter defines ChromosomeParameters for each adf.
Throws:
TypeException - If there was a typing problem during tree generation. For example a Function or Terminal of the required type could not be found.
Method Detail

mutate

public static Chromosome mutate(Chromosome mum)
Creates a new child Chromosome which is a mutation of the mother.
Parameters:
mum - is the mother Chromosome.
Returns:
a reference to a child Chromosome which is a mutation of the mother

cross

public static Chromosome cross(Chromosome mum,
                               Chromosome dad)
Creates a new child Chromosome via crossover of the mother and father Chromosomes.
Parameters:
mum - is the mother Chromosome. The child is actually a copy of the mother with one branch exchanged with a branch from the father.
dad - is the father Chromosome.
Returns:
a reference to a new child Chromosome.

deepClone

public Chromosome deepClone()
Makes a deep copy of this Chromsome by making a copy of the entire data graph.
Returns:
a reference to a copy of this Chromosome.

complexity

public int complexity()
Calculates the number of nodes in the Gene tree of this Chromosome.
Returns:
the number of nodes in the Gene tree.

evaluateObject

public java.lang.Object evaluateObject(Individual i)
                                throws EvaluationException
Evaluates the chromosome so that it returns an Object reference.
Parameters:
i - is the Individual being evaluated.
Returns:
a reference to an Object returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateByte

public byte evaluateByte(Individual i)
                  throws EvaluationException
Evaluates the chromosome so that it returns a byte.
Parameters:
i - is the Individual being evaluated.
Returns:
a byte returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateShort

public short evaluateShort(Individual i)
                    throws EvaluationException
Evaluates the chromosome so that it returns a byte.
Parameters:
i - is the Individual being evaluated.
Returns:
a byte returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateInt

public int evaluateInt(Individual i)
                throws EvaluationException
Evaluates the chromosome so that it returns an int.
Parameters:
i - is the Individual being evaluated.
Returns:
an int returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateLong

public long evaluateLong(Individual i)
                  throws EvaluationException
Evaluates the chromosome so that it returns a long.
Parameters:
i - is the Individual being evaluated.
Returns:
a long returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateFloat

public float evaluateFloat(Individual i)
                    throws EvaluationException
Evaluates the chromosome so that it returns a float.
Parameters:
i - is the Individual being evaluated.
Returns:
a float returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateDouble

public double evaluateDouble(Individual i)
                      throws EvaluationException
Evaluates the chromosome so that it returns a double.
Parameters:
i - is the Individual being evaluated.
Returns:
a double returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateChar

public char evaluateChar(Individual i)
                  throws EvaluationException
Evaluates the chromosome so that it returns a char.
Parameters:
i - is the Individual being evaluated.
Returns:
a char returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

evaluateBoolean

public boolean evaluateBoolean(Individual i)
                        throws EvaluationException
Evaluates the chromosome so that it returns a boolean.
Parameters:
i - is the Individual being evaluated.
Returns:
a boolean returned by evaluating the Gene tree.
Throws:
EvaluationException - If there is an evaluation failure.

toString

public java.lang.String toString()
Generates a String representing a dump of the Gene tree for this Chromosome.
Returns:
a String representing the Gene tree for this Chromosome.
Overrides:
toString in class java.lang.Object