|
artoflife pre0.1.0-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.artoflife.gp.Chromosome | +--org.artoflife.gp.genome.GpTreeChromosome
A Chromosome that describes a procedure
expressed as a tree of GpTreeNode
s
to return a value of a fixed type.
The root gene has a return type specific to this Chromosome which must not be allowed to vary. The Chromosome has an ID used to test compatibility with other Chromosomes.
Field Summary | |
protected RootGene |
rootGene
Root of the tree of genes. |
Constructor Summary | |
GpTreeChromosome(java.lang.String id,
java.lang.Class type)
Create with an identifying ID and set the root Gene to a random Gene of the correct type. |
Method Summary | |
java.lang.Object |
clone()
Must be able to clone an Individual's genome during clone of an Individual. |
void |
crossover(Chromosome chromosome)
Subclasses should ensure compatibility before doing the crossover, throwing an IncompatibleGenotypeException
if not. |
protected java.util.SortedMap |
getCrossovers()
Provides a SortedMap of GpCrossover s with their
probabilities (Doubles between 0.0 and 1.0)
so that #crossover(Chromosome, float)
can choose one to do a crossover. |
GpTreeNode |
getRootGene()
|
int |
getSize()
Return number of genes. |
void |
mutate(float probability)
Just ask the root Gene to mutate. |
java.lang.String |
toString()
|
Methods inherited from class org.artoflife.gp.Chromosome |
compatibleWith, getId |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected RootGene rootGene
Constructor Detail |
public GpTreeChromosome(java.lang.String id, java.lang.Class type)
id
- the Chromosome's id, not nulltype
- Class that the root Gene
returns on evaluationMethod Detail |
public GpTreeNode getRootGene()
public void crossover(Chromosome chromosome) throws IncompatibleChromosomeException
Chromosome
IncompatibleGenotypeException
if not.
crossover
in class Chromosome
chromosome
- the Chromosome to crossover this
one with
IncompatibleChromosomeException
protected java.util.SortedMap getCrossovers()
GpCrossover
s with their
probabilities (Doubles between 0.0 and 1.0)
so that #crossover(Chromosome, float)
can choose one to do a crossover. The map
needs to look like:
Load from configuration properties.
[getClass().getName()].crossover.class.0
and optionally
[getClass().getName()].crossover.probability.0
public void mutate(float probability)
mutate
in class Chromosome
probability
- that a Gene will mutate.public int getSize()
getSize
in class Chromosome
public java.lang.Object clone()
Chromosome
clone
in class Chromosome
public java.lang.String toString()
toString
in class java.lang.Object
|
artoflife pre0.1.0-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |