evolution
Class Gene

java.lang.Object
  extended by evolution.Gene
All Implemented Interfaces:
java.lang.Cloneable

public class Gene
extends java.lang.Object
implements java.lang.Cloneable

Gene


Constructor Summary
Gene(java.lang.Object[] geneTypes, GeneToStringModel toStringFunction)
          Creates a new instance of Gene
 
Method Summary
 java.lang.Object clone()
          Create and return a copy of this gene
 java.lang.Object[] getGeneTypes()
          Return array of gene types
 java.lang.Object getGeneValue()
          Return gene value
 double getMutationProbability()
          Return mutation propability
 int getNumberOfTypes()
          Return number of gene types.
 GeneToStringModel getToStringFunction()
          Return reference to function used for generating String representaion of the gene
 int mutation()
          Mutate the gene.
 void setGene(java.lang.Object value)
          Set gene value with Object.
 void setGeneValue(int index)
          Set gene value for specified type from list of types
 void setMutationProbability(double mutationProbability)
          Set mutation propability
 void setToStringFunction(GeneToStringModel toStringFunction)
          Set function used for generating String representaion of the gene
 java.lang.String toString()
          Return String representation of the gene using GeneToStingFunction .
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gene

public Gene(java.lang.Object[] geneTypes,
            GeneToStringModel toStringFunction)
Creates a new instance of Gene

Parameters:
geneTypes - Array of gene types
toStringFunction - Reference to GeneToStringFunction
Method Detail

setMutationProbability

public void setMutationProbability(double mutationProbability)
Set mutation propability

Parameters:
mutationProbability - Set propability of the gene

getMutationProbability

public double getMutationProbability()
Return mutation propability

Returns:
mutation propability

setGene

public void setGene(java.lang.Object value)
Set gene value with Object. Array of gene types must contain element

Parameters:
value - New gene value

setGeneValue

public void setGeneValue(int index)
Set gene value for specified type from list of types

Parameters:
index - Index of gene type

getGeneTypes

public java.lang.Object[] getGeneTypes()
Return array of gene types

Returns:
Array of gene types

getGeneValue

public java.lang.Object getGeneValue()
Return gene value

Returns:
Gene value

getNumberOfTypes

public int getNumberOfTypes()
Return number of gene types.

Returns:
Number of gene types

mutation

public int mutation()
Mutate the gene. Return 1 if everything is Ok, 0 otherwise

Returns:
Return 1 if everything is Ok, 0 otherwise

toString

public java.lang.String toString()
Return String representation of the gene using GeneToStingFunction . If no GeneToStringFunction was set, function return String using toString standard function.

Overrides:
toString in class java.lang.Object
Returns:
Return String representation of the gene
See Also:
GeneToStringModel

setToStringFunction

public void setToStringFunction(GeneToStringModel toStringFunction)
Set function used for generating String representaion of the gene

Parameters:
toStringFunction - Reference to function

getToStringFunction

public GeneToStringModel getToStringFunction()
Return reference to function used for generating String representaion of the gene

Returns:
Return reference to function GeneToString

clone

public java.lang.Object clone()
Create and return a copy of this gene

Overrides:
clone in class java.lang.Object
Returns:
copy of the gene