public class TreeChromosome extends Chromosome
| Modifier and Type | Field and Description |
|---|---|
static int |
FULL |
static int |
GROW
Initial mode of creation of Chromosome.
|
static int |
RAMPED |
BIASED, crossoverPoints, crossoverRate, LAPLACE, length, mutationRate, soupType| Constructor and Description |
|---|
TreeChromosome(Element c)
Creates a TreeChromosome via XML.
|
TreeChromosome(int depth,
int resultType)
Constructs a TreeChromosome.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNode(ProgramNode node)
Adds a program node to the node set.
|
TreeChromosome |
clone()
A deep clone of this TreeChromosome.
|
void |
doCrossover(Chromosome father)
Performs crossover by selecting a random node in each of the two parent trees and swapping the subtrees.
|
void |
doMutation()
Performs tree and node mutation by iterating over the tree.
|
boolean |
equals(java.lang.Object chrom)
Compares this program tree to another in 'chrom'.
|
void |
fromString(java.lang.String b)
Creates a program tree from its string representation.
|
java.lang.Object |
getBases()
Returns the genotype aka the program tree, which in this case is also the phenotype.
|
boolean |
getNodeMutation()
Returns the flag for node mutation.
|
int |
hashCode()
Returns a hash code for the program tree.
|
void |
mixSoup()
Creates a random program tree in different manners.
|
void |
setNodeMutation(boolean nodeMutation)
Sets the flag for node mutation.
|
java.lang.String |
toString()
Returns the string representation of the program tree.
|
Element |
toXml(Element parent)
Saves the current state to XML.
|
create, getCrossoverPoints, getCrossoverRate, getLength, getMutationRate, getSoupType, setCrossoverPoints, setCrossoverRate, setLength, setMutationRate, setSoupTypepublic static final int GROW
public static final int RAMPED
public static final int FULL
public TreeChromosome(int depth,
int resultType)
depth - the maximal depth of the initial program treeresultType - the type of the result of the evolved function/programpublic TreeChromosome(Element c)
c - an XML Chromosome elementpublic TreeChromosome clone()
clone in class Chromosomepublic boolean equals(java.lang.Object chrom)
equals in class Chromosomechrom - a TreeChromosomepublic int hashCode()
hashCode in class Chromosomepublic java.lang.Object getBases()
getBases in class Chromosomepublic void addNode(ProgramNode node)
node - a program nodepublic boolean getNodeMutation()
public void setNodeMutation(boolean nodeMutation)
nodeMutation - true, if node mutation onpublic void doMutation()
doMutation in class Chromosomepublic void doCrossover(Chromosome father)
doCrossover in class Chromosomefather - the father chromosomepublic void mixSoup()
mixSoup in class Chromosomepublic java.lang.String toString()
toString in class Chromosomepublic void fromString(java.lang.String b)
fromString in class Chromosomeb - the program tree in string formpublic Element toXml(Element parent)
toXml in class Chromosomeparent - the JDOM parent element