|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.Chromosome
public class Chromosome
Chromosomes represent potential solutions and consist of a fixed-length collection of genes. Each gene represents a discrete part of the solution. Each gene in the Chromosome may be backed by a different concrete implementation of the Gene interface, but all genes with the same innovation ID must share the same concrete implementation across Chromosomes within a single population (genotype).
| Field Summary | |
|---|---|
static java.lang.Long |
DEFAULT_ID
default ID |
protected int |
m_fitnessValue
Stores the fitness value of this Chromosome as determined by the active fitness function. |
protected boolean |
m_isSelectedForNextGeneration
Keeps track of whether or not this Chromosome has been selected by the natural selector to move on to the next generation. |
| Constructor Summary | |
|---|---|
Chromosome(ChromosomeMaterial a_material,
java.lang.Long an_id)
this should only be called when a chromosome is being created from persistence; otherwise, the ID should be generated by a_activeConfiguration. |
|
| Method Summary | |
|---|---|
ChromosomeMaterial |
cloneMaterial()
|
int |
compareTo(java.lang.Object o)
Compares the given Chromosome to this Chromosome. |
double |
distance(Chromosome target,
SpeciationParms parms)
Calculates compatibility distance between this and target according to NEAT speciation
methodology. |
boolean |
equals(java.lang.Object other)
Compares this Chromosome against the specified object. |
Allele |
findMatchingGene(Allele alleleToMatch)
|
java.util.SortedSet |
getAlleles()
|
int |
getFitnessValue()
Retrieves the fitness value of this Chromosome, as determined by the active fitness function. |
java.lang.Long |
getId()
|
java.lang.Long |
getPrimaryParentId()
|
java.lang.Long |
getSecondaryParentId()
|
int |
getSpeciatedFitnessValue()
|
Specie |
getSpecie()
|
int |
hashCode()
Retrieve a hash code for this Chromosome. |
boolean |
isSelectedForNextGeneration()
Retrieves whether this Chromosome has been selected by the natural selector to continue to the next generation. |
void |
setFitnessValue(int a_newFitnessValue)
Sets the fitness value of this Chromosome. |
void |
setIsSelectedForNextGeneration(boolean a_isSelected)
Sets whether this Chromosome has been selected by the natural selector to continue to the next generation. |
int |
size()
Returns the size of this Chromosome (the number of alleles it contains). |
java.lang.String |
toString()
Returns a string representation of this Chromosome, useful for some display purposes. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.Long DEFAULT_ID
protected boolean m_isSelectedForNextGeneration
protected int m_fitnessValue
| Constructor Detail |
|---|
public Chromosome(ChromosomeMaterial a_material,
java.lang.Long an_id)
a_activeConfiguration.
a_material - Genetic material to be contained within this Chromosome instance.an_id - unique ID of new chromosome| Method Detail |
|---|
public double distance(Chromosome target,
SpeciationParms parms)
target according to NEAT speciation
methodology. It is generic enough that the alleles do not have to be nodes and connections.
target - parms -
targetChromosomeMaterial.distance(ChromosomeMaterial, SpeciationParms)public java.lang.Long getId()
hashCode() and
persistencepublic int size()
public ChromosomeMaterial cloneMaterial()
public java.util.SortedSet getAlleles()
public Allele findMatchingGene(Allele alleleToMatch)
alleleToMatch -
geneToMatchnull if none matchpublic int getFitnessValue()
public int getSpeciatedFitnessValue()
public void setFitnessValue(int a_newFitnessValue)
a_newFitnessValue - a positive integer representing the fitness of this Chromosome. if
0, fitness is set as 1.public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object other)
equals in class java.lang.Objectother - The object to compare against.
public int hashCode()
hashCode in class java.lang.Objectpublic int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - The Chromosome against which to compare this chromosome.
public void setIsSelectedForNextGeneration(boolean a_isSelected)
a_isSelected - true if this Chromosome has been selected, false otherwise.public boolean isSelectedForNextGeneration()
public Specie getSpecie()
public java.lang.Long getPrimaryParentId()
public java.lang.Long getSecondaryParentId()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||