|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jgap.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 in a respective position (locus) must share the same concrete implementation across Chromosomes within a single population (genotype). In other words, gene 1 in a chromosome must share the same concrete implementation as gene 1 in all other chromosomes in the population.
| Field Summary | |
static double |
DELTA
|
| Constructor Summary | |
Chromosome(Gene[] a_initialGenes)
Constructs a Chromosome separate from any specific Configuration. |
|
Chromosome(Gene a_sampleGene,
int a_desiredSize)
Constructs a Chromosome of the given size separate from any specific Configuration. |
|
| Method Summary | |
void |
cleanup()
Invoked when this Chromosome is no longer needed and should perform any necessary cleanup. |
java.lang.Object |
clone()
Returns a copy of this Chromosome. |
int |
compareTo(java.lang.Object other)
Compares the given Chromosome to this Chromosome. |
boolean |
equals(java.lang.Object other)
Compares this Chromosome against the specified object. |
java.lang.Object |
getApplicationData()
Retrieves the application-specific data that is attached to this Chromosome. |
double |
getFitnessValue()
Retrieves the fitness value of this Chromosome, as determined by the active fitness function. |
Gene |
getGene(int a_desiredLocus)
Returns the Gene at the given index (locus) within the Chromosome. |
Gene[] |
getGenes()
Retrieves the set of genes that make up this Chromosome. |
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. |
static Chromosome |
randomInitialChromosome()
Convenience method that returns a new Chromosome instance with its genes values (alleles) randomized. |
void |
setApplicationData(java.lang.Object a_newData)
This sets the application-specific data that is attached to this Chromosome. |
void |
setFitnessValue(int a_newFitnessValue)
Sets the fitness value of this Chromosome. |
void |
setGenes(Gene[] a_genes)
|
void |
setIsSelectedForNextGeneration(boolean a_isSelected)
Sets whether this Chromosome has been selected by the natural selector to continue to the next generation or manually (e.g. via an add-method). |
int |
size()
Returns the size of this Chromosome (the number of genes 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 |
getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final double DELTA
| Constructor Detail |
public Chromosome(Gene a_sampleGene,
int a_desiredSize)
a_sampleGene - A sample concrete Gene instance that will be used
as a template for all of the genes in this
Chromosome.a_desiredSize - The desired size (number of genes) of this
Chromosome.public Chromosome(Gene[] a_initialGenes)
a_initialGenes - The genes of this Chromosome.| Method Detail |
public java.lang.Object clone()
public Gene getGene(int a_desiredLocus)
a_desiredLocus - The index of the gene value to be returned.
public Gene[] getGenes()
public int size()
public double getFitnessValue()
public void setFitnessValue(int a_newFitnessValue)
a_newFitnessValue - a positive integer representing the fitness
of this Chromosome.public java.lang.String toString()
public static Chromosome randomInitialChromosome()
throws InvalidConfigurationException
InvalidConfigurationException - if the given Configuration
instance is invalid.
java.lang.IllegalArgumentException - if the given Configuration instance
is null.public boolean equals(java.lang.Object other)
other - The object to compare against.
public int hashCode()
public int compareTo(java.lang.Object other)
compareTo in interface java.lang.Comparableother - 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 void cleanup()
public void setApplicationData(java.lang.Object a_newData)
a_newData - The new application-specific data to attach to this
Chromosome.public java.lang.Object getApplicationData()
public void setGenes(Gene[] a_genes)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||