weka.filters.supervised.attribute.gpattributegeneration
Class Genome<T>

java.lang.Object
  extended by weka.filters.supervised.attribute.gpattributegeneration.Genome<T>
All Implemented Interfaces:
java.lang.Comparable<Genome<T>>

public class Genome<T>
extends java.lang.Object
implements java.lang.Comparable<Genome<T>>

An individual genome for the GP system, made up of nodes. Adapted from Luke Devonshire's C# project

Author:
Colin Noakes & Luke Devonshire

Constructor Summary
Genome()
          Creates an empty Genome
Genome(GeneNode<Gene> genotype)
          Constructs a Genome given a genotype
Genome(Genome<T> genome)
          Constructor to allow for a deep copy of a genome.
Genome(java.util.Random rand, EnumGenerationMethod generationMethod, int maxDepth, java.util.ArrayList<java.lang.String> funcSet, int[] validAttributes)
          Constructor to generate a random genome given the relevant parameters.
Genome(java.lang.String prefixGenome)
          Create a genome from a PREFIX string, with nodes separated by a space
 
Method Summary
 void Clear()
          Clears the genome of all its properties
 int compareTo(Genome<T> o)
          Implements comparison method from 'Comparable'.
 boolean equals(java.lang.Object obj)
          Equates this genome with the given parameter genome.
 java.util.ArrayList<GeneNode<Gene>> getChildren()
          Returns the children of the genome's root node
 double getCrowdingDistance()
          Gets crowding distance of the genome
 int getDominationRank()
          Returns the domination rank of the genome
 GeneNode<Gene> getGenotype()
          Returns genotype
 int getLength()
          returns the length of the genome
 double getTreeAccuracy()
          Returns the tree accuracy of the genome.
 int getTreeSize()
          Get the tree size of the genome
 double getVectorFitness()
          Calculate Vector fitness (1 is highest; but will never reach this).
 int hashCode()
          Calculates a hashcode for Genome for use in HashMap
 void setCrowdingDistance(double dist)
          Sets the crowding distance
 void setDominationRank(int rank)
          Sets the domination rank of the genome
 void setGenotype(GeneNode<Gene> geno)
          Sets genotype of genome and re-populates children to make it correct
 void setTreeAccuracy(double fitness)
          Sets tree accuracy.
 void setTreeSize(int treeSize)
          Set the tree size of the genome
 java.lang.String toString()
          A string representation of the genome
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Genome

public Genome()
Creates an empty Genome


Genome

public Genome(Genome<T> genome)
Constructor to allow for a deep copy of a genome. Simply copies all fields using helper fields to copy data genotype structure.

Parameters:
genome - Genome to copy

Genome

public Genome(GeneNode<Gene> genotype)
Constructs a Genome given a genotype

Parameters:
genotype - Genotype to use for new Genome

Genome

public Genome(java.lang.String prefixGenome)
Create a genome from a PREFIX string, with nodes separated by a space

Parameters:
prefixGenome - String to turn into a genome

Genome

public Genome(java.util.Random rand,
              EnumGenerationMethod generationMethod,
              int maxDepth,
              java.util.ArrayList<java.lang.String> funcSet,
              int[] validAttributes)
Constructor to generate a random genome given the relevant parameters. Used when initialising populations or other times when a random genome is required

Parameters:
rand - Random object to use for generating pseudo-random numbers
generationMethod - The generation method to use
maxDepth - The maximum depth of the tree created
funcSet - Available functions to use for creating the tree
validAttributes - the valid numeric attributes that can be used as part of equations
Method Detail

Clear

public void Clear()
Clears the genome of all its properties


getTreeAccuracy

public double getTreeAccuracy()
Returns the tree accuracy of the genome. 1 is the best value.

Returns:
The tree accuracy of the genome

setTreeAccuracy

public void setTreeAccuracy(double fitness)
Sets tree accuracy. 1 is the best value.

Parameters:
fitness - tree accuracy to give the Genome

getGenotype

public GeneNode<Gene> getGenotype()
Returns genotype

Returns:
Genotype of genome

setGenotype

public void setGenotype(GeneNode<Gene> geno)
Sets genotype of genome and re-populates children to make it correct

Parameters:
geno - Genotype to give to gene

getChildren

public java.util.ArrayList<GeneNode<Gene>> getChildren()
Returns the children of the genome's root node

Returns:
Children of the root node

getLength

public int getLength()
returns the length of the genome

Returns:
Length of the genome

getVectorFitness

public double getVectorFitness()
Calculate Vector fitness (1 is highest; but will never reach this). Equation:

Returns:
Vector fitness of this genome

getTreeSize

public int getTreeSize()
Get the tree size of the genome

Returns:
the tree size of the genome

setTreeSize

public void setTreeSize(int treeSize)
Set the tree size of the genome

Parameters:
treeSize - the tree size to set

getDominationRank

public int getDominationRank()
Returns the domination rank of the genome

Returns:
The domination rank

setDominationRank

public void setDominationRank(int rank)
Sets the domination rank of the genome

Parameters:
rank - The domination rank

getCrowdingDistance

public double getCrowdingDistance()
Gets crowding distance of the genome

Returns:
The crowding distance

setCrowdingDistance

public void setCrowdingDistance(double dist)
Sets the crowding distance

Parameters:
dist - The crowding distance

toString

public java.lang.String toString()
A string representation of the genome

Overrides:
toString in class java.lang.Object
Returns:
The genome represented as a string

compareTo

public int compareTo(Genome<T> o)
Implements comparison method from 'Comparable'. Compares based on genome fitness so Java can show a 'natural ordering' of genomes

Specified by:
compareTo in interface java.lang.Comparable<Genome<T>>
Parameters:
o - The genome to compare to
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

equals

public boolean equals(java.lang.Object obj)
Equates this genome with the given parameter genome. Returns true if genome is identical

Overrides:
equals in class java.lang.Object
Parameters:
obj - Genome to compare to
Returns:
True for same genome, false for not

hashCode

public int hashCode()
Calculates a hashcode for Genome for use in HashMap

Overrides:
hashCode in class java.lang.Object
Returns:
Hash code