org.jgap
Class Gene

java.lang.Object
  extended byorg.jgap.Gene
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
ConnectionGene, NeuronGene

public class Gene
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Genes represent the discrete components of a potential solution (the Chromosome). This abstract class exists so that custom gene implementations can be easily plugged-in, which can add a great deal of flexibility and convenience for many applications. Note that it's very important that implementations of this interface also implement the equals() method. Without a proper implementation of equals(), some genetic operations will fail to work properly. Innovation ID is used as a historical marker and aids in crossover and determining "distance" between 2 chromosomes for speciation. Not the difference between compareTo() and distance():compareTo() is used by container classes to sort genes by innovation ID, distance() is the genetic distance between genes with the same innovation ID.

See Also:
Serialized Form

Constructor Summary
protected Gene()
          for hibernate
  Gene(java.lang.Long anInnovationId)
          Create new gene.
 
Method Summary
 int compareTo(java.lang.Object o)
          Comparison based on innovation ID.
 boolean equals(java.lang.Object o)
           
 java.lang.Long getInnovationId()
          Innovation ID is analagous to the locus of a real gene.
 int hashCode()
          Uses hash of innovation ID.
protected  void setInnovationId(java.lang.Long aInnovationId)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gene

protected Gene()
for hibernate


Gene

public Gene(java.lang.Long anInnovationId)
Create new gene.

Parameters:
anInnovationId -
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Comparison based on innovation ID.

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

equals

public boolean equals(java.lang.Object o)
Returns:
true if same innovation ID
See Also:
Object.equals(Object)

getInnovationId

public java.lang.Long getInnovationId()
Innovation ID is analagous to the locus of a real gene. Genes with the same innovation ID in 2 chromosomes are considered to be 2 alleles of the same gene.

Returns:
unique identifier; see NEAT methodology for uses of innovation ID as a historical marker.

hashCode

public int hashCode()
Uses hash of innovation ID.

See Also:
Object.hashCode()

setInnovationId

protected void setInnovationId(java.lang.Long aInnovationId)
Parameters:
aInnovationId -

toString

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