weka.filters.supervised.attribute.gpattributegeneration
Class Gene

java.lang.Object
  extended by weka.filters.supervised.attribute.gpattributegeneration.Gene

public class Gene
extends java.lang.Object

Stores a gene node Ported from C#.

Author:
Luke Devonshire & Colin Noakes

Constructor Summary
Gene()
          An empty Gene
Gene(java.lang.String geneValue, EnumGeneType gType)
          A gene with the given value
 
Method Summary
 void generateValue(java.util.Random rand, java.util.ArrayList<java.lang.String> funcSet, int[] validAttributes)
          Generate a random value for the Gene.
 void generateValue(java.util.Random rand, EnumGeneType gType, java.util.ArrayList<java.lang.String> funcSet, int[] validAttributes)
          Generate a random value for the gene of the specified type
 void generateValue(java.util.Random rand, EnumGeneType gType, java.util.ArrayList<java.lang.String> funcSet, int arity, int[] validAttributes)
          Generate a random value for the gene of the specified type taking into account the arity desired
 EnumGeneType getType()
          Returns the type of the gene
 java.lang.String getValue()
          Returns the Gene's value
 void setType(EnumGeneType gType)
          Sets whether the node is a terminal or function
 java.lang.String toString()
          Returns the string representation of the gene
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gene

public Gene()
An empty Gene


Gene

public Gene(java.lang.String geneValue,
            EnumGeneType gType)
A gene with the given value

Parameters:
geneValue - The value to give the gene
isTerminal - Whether the gene is a terminal or function node
Method Detail

getType

public EnumGeneType getType()
Returns the type of the gene

Returns:
The EnumGeneType enum that matches this gene's type

setType

public void setType(EnumGeneType gType)
Sets whether the node is a terminal or function

Parameters:
isTerminal - True if Gene is a terminal; False if a function node

getValue

public java.lang.String getValue()
Returns the Gene's value

Returns:
The Gene's value

generateValue

public void generateValue(java.util.Random rand,
                          java.util.ArrayList<java.lang.String> funcSet,
                          int[] validAttributes)
Generate a random value for the Gene. Half of the Genes generated by this are functions, half terminals

Parameters:
rand - The Random generator to use
funcSet - The set of available functions
validAttributes - the valid numeric attributes that can be used as part of equations

generateValue

public void generateValue(java.util.Random rand,
                          EnumGeneType gType,
                          java.util.ArrayList<java.lang.String> funcSet,
                          int[] validAttributes)
Generate a random value for the gene of the specified type

Parameters:
rand - The Random generator to use
gType - Specifies whether a function or terminal should be generated
funcSet - The set of available functions
validAttributes - the valid numeric attributes that can be used as part of equations

generateValue

public void generateValue(java.util.Random rand,
                          EnumGeneType gType,
                          java.util.ArrayList<java.lang.String> funcSet,
                          int arity,
                          int[] validAttributes)
Generate a random value for the gene of the specified type taking into account the arity desired

Parameters:
rand - The Random generator to use
isTerminal - Specifies whether a function or terminal should be generated
funcSet - The set of available functions
arity - The desired arity
validAttributes - the valid numeric attributes that can be used as part of equations

toString

public java.lang.String toString()
Returns the string representation of the gene

Overrides:
toString in class java.lang.Object
Returns:
string representation of the gene