|
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.Individual
An Individual has a genotype containing a number of
Chromosome
s, a Fitness
used during selection
from a Population
and a Phenotype
resulting
from expression of the genotype.
It can mutate via mutate(float)
and can breed with another
Individual via breedWith(Individual)
to produce
a child containing chromosomes that
have undergone Chromosome.crossover(org.artoflife.gp.Chromosome)
.
Individuals can also be cloned to produce a child with
an exact copy of the parent's genome (see clone()
).
The Chromosomes are indexed by their id so that crossover can take place between compatible Chromosomes.
An Individual's Phenotype is manipulated by Chromosomes during the expressGenome cycle. After expression, the Individual can calculate its Fitness on the basis of the its phenotype.
Fitness
,
Chromosome
,
Population
,
Phenotype
,
Serialized FormConstructor Summary | |
Individual(Phenotype phenotype,
Chromosome chromosome)
Create with a single Chromosome, express the genotype and as a result create the initial Fitness. |
|
Individual(Phenotype phenotype,
java.util.Collection chromosomes)
Create with a set of Chromosomes, express the genotype and as a result create the initial Fitness. |
Method Summary | |
protected void |
addChromsome(Chromosome chromosome)
|
Individual |
breedWith(Individual parent2)
Breed with another Individual by calling Chromosome.crossover(Chromosome)
on all same-type Chromosomes in both parents. |
java.lang.Object |
clone()
Override this to deep clone members of subclasses, eg the fitness if held as a field. |
protected abstract void |
expressGenome()
Express this Individual's genotype as its phenotype. |
java.lang.String |
genotypeAsString()
For debug. |
protected Chromosome |
getChromosome(java.lang.String id)
Find a Chromosome in the Individual's genotype. |
protected java.util.Map |
getChromosomes()
|
abstract Fitness |
getFitness()
Override to describe how fit this Individual is. |
int |
getGenomeSize()
May be used in some selection strategies to select small fit Individuals. |
Phenotype |
getPhenotype()
|
void |
mutate(float probability)
Mutate this Individual's genome by mutating every Chromosome . |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Individual(Phenotype phenotype, java.util.Collection chromosomes)
phenotype
- this Individual's Phenotype used during expressGenome()
chromosomes
- Collection of Chromosome
s
making up this Individual's genotype.public Individual(Phenotype phenotype, Chromosome chromosome)
phenotype
- this Individual's Phenotype used during expressGenome()
chromosome
- single Chromosome
this Individual has.Method Detail |
protected java.util.Map getChromosomes()
expressGenome()
after
making changes.protected Chromosome getChromosome(java.lang.String id)
public Phenotype getPhenotype()
expressGenome()
has been called.protected void addChromsome(Chromosome chromosome)
chromosome
- to add to the genotype, replacing
any of the same id already in the genome. This does not
call expressGenome()
.public int getGenomeSize()
public void mutate(float probability)
Chromosome
.
probability
- of mutation, see Chromosome.mutate(float)
Chromosome.mutate(float)
public Individual breedWith(Individual parent2) throws IncompatibleGenotypeException
Chromosome.crossover(Chromosome)
on all same-type Chromosomes in both parents.
parent2
- Individual to breed with
IncompatibleGenotypeException
- if the individuals have incompatible
genotypesChromosome.crossover(Chromosome)
public abstract Fitness getFitness()
expressGenome()
since the
fitness is a direct result of the genome and doesn't change.
during the lifetime. For other others the Fitness may change
during lifetime.
protected abstract void expressGenome()
Should be called from any methods in an Individual that mutates the genotype.
Override appropriate to the system being modelled.
Can this be replaced with a generic implementation or does it have to be abstract so that implementations can express Chromosomes in a certain order to do certain things?
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String genotypeAsString()
|
artoflife pre0.1.0-dev | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |