|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--org.jgap.Chromosome
Chromosomes represent fixed-length collections of genes. In the current implementation, this is the lowest level class since genes are, themselves, represented as individual bits. Each gene can have two values (true or false). This should be suitable for most applications, but it's always possible for a fitness function to consider multiple genes as a single unit if more than two possible values are desired. In the future, a Gene class and Allele interface may be created that will allow more flexibility in this regard.
Chromosomes support reproduction, crossover, and mutation. Additional mechanisms for chromosome evolution are planned for future versions.
| Constructor Summary | |
Chromosome(java.util.BitSet initialGenes,
int chromosomeLength)
Constructs this Chromosome instance with the given set of genes. |
|
Chromosome(java.util.BitSet initialGenes,
int chromosomeLength,
int desiredMutationRate)
Constructs this Chromosome instance with the given set of genes and the given mutation rate. |
|
| Method Summary | |
void |
crossover(org.jgap.Chromosome mate)
Performs basic crossover between this Chromosome instance and the given instance. |
boolean |
getAllele(int locus)
Returns the allele (value) of the gene at the given locus (index) within the Chromosome. |
void |
mutate()
Runs through the genes of this Chromosome, possibly mutating some in the process. |
static org.jgap.Chromosome |
randomInitialChromosome(int size)
Convenience method that returns a newly constructed Chromosome instance of the given size with a random population of genes. |
static org.jgap.Chromosome |
randomInitialChromosome(int size,
int mutationRate)
Convenience method that returns a newly constructed Chromosome instance of the given size with a random population of genes and instantiated with the given mutation rate. |
org.jgap.Chromosome |
reproduce()
Returns a copy of this Chromosome. |
int |
size()
Returns the size of this Chromosome (the number of genes). |
java.lang.String |
toString()
Returns a string representation of this Chromosome, useful for debugging purposes. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Chromosome(java.util.BitSet initialGenes,
int chromosomeLength)
initialGenes - The set of genes with which to initialize
this Chromosome instance. Each bit in the
BitSet represents a single gene.
public Chromosome(java.util.BitSet initialGenes,
int chromosomeLength,
int desiredMutationRate)
initialGenes - The set of genes with which to initialize
this Chromosome instance. Each bit in the
BitSet represents a single gene.desiredMutationRate - The desired chances of mutation
expressed as the fraction 1/n where
n is this parameter. For example, if
1000 were given, then statistically
one out of every thousand genes
processed would incur mutation during
evolution.| Method Detail |
public org.jgap.Chromosome reproduce()
public void crossover(org.jgap.Chromosome mate)
java.lang.IllegalArgumentException - if the size of the given
Chromosome is not the same as the size of this
Chromosome.public void mutate()
public boolean getAllele(int locus)
public int size()
public java.lang.String toString()
toString in class java.lang.Objectpublic static org.jgap.Chromosome randomInitialChromosome(int size)
public static org.jgap.Chromosome randomInitialChromosome(int size,
int mutationRate)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||