org.jgap
Class Allele

java.lang.Object
  extended by org.jgap.Allele
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
BooleanAllele, ConnectionAllele, IntegerAllele, NeuronAllele

public abstract class Allele
extends java.lang.Object
implements java.lang.Comparable

Allele contains gene data that can be different for multiple chromosomes with the same gene.

Author:
Philip Tucker

Constructor Summary
protected Allele()
          for hibernate
protected Allele(Gene aGene)
          ctor
 
Method Summary
abstract  Allele cloneAllele()
           
 int compareTo(java.lang.Object o)
           
abstract  double distance(Allele target)
           
 boolean equals(java.lang.Object o)
           
protected  Gene getGene()
           
static java.util.Set getGenes(java.util.Collection alleles)
           
 java.lang.Long getInnovationId()
           
 int hashCode()
           
abstract  void setToRandomValue(java.util.Random a_numberGenerator)
          Sets the value of this Gene to a random legal value for the implementation.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Allele

protected Allele()
for hibernate


Allele

protected Allele(Gene aGene)
ctor

Parameters:
aGene -
Method Detail

distance

public abstract double distance(Allele target)
Parameters:
target - should be same implementation class and same innovation ID as this gene
Returns:
positive distance between genes, where a value closer to 0 represents more similar genes; used in computing distance between chromosomes, which in turn is used to compute speciation compatibility.
See Also:
Chromosome.distance(Chromosome, SpeciationParms)

setToRandomValue

public abstract void setToRandomValue(java.util.Random a_numberGenerator)
Sets the value of this Gene to a random legal value for the implementation. This method exists for the benefit of mutation and other operations that simply desire to randomize the value of a gene.

Parameters:
a_numberGenerator - The random number generator that should be used to create any random values. It's important to use this generator to maintain the user's flexibility to configure the genetic engine to use the random number generator of their choice.

cloneAllele

public abstract Allele cloneAllele()
Returns:
Gene clone of this object

getGene

protected Gene getGene()
Returns:
gene

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
See Also:
Object.hashCode()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getGenes

public static java.util.Set getGenes(java.util.Collection alleles)
Parameters:
alleles - Collection contains Allele objects
Returns:
Set contains Gene objects

getInnovationId

public java.lang.Long getInnovationId()
Returns:
innovation ID
See Also:
Gene.getInnovationId()