|
Orbital library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orbital.util.DelegateCollection orbital.util.DelegateList orbital.algorithm.evolutionary.Gene.List orbital.algorithm.evolutionary.Genome
public class Genome
The Genome data in a population represents a state. For bio informatics, genomes and chromosomes are treated as synonyms.
A Genome provides the following operators and functions:
Genomes provide fitness caching and clearing.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface orbital.algorithm.evolutionary.Gene |
---|
Gene.BitSet, Gene.BoundedFloat, Gene.BoundedInteger, Gene.Fixed, Gene.Float, Gene.Integer, Gene.List, Gene.Number |
Field Summary | |
---|---|
static java.util.Comparator |
comparator
Compare two Genomes according to their fitness, descending. |
Constructor Summary | |
---|---|
Genome()
|
|
Genome(Gene content)
Construct a genome with a single gene. |
Method Summary | |
---|---|
void |
add(int index,
java.lang.Object o)
Insert one gene. |
boolean |
add(java.lang.Object o)
Add one gene. |
void |
clearFitness()
Clears the fitness. |
java.lang.Object |
clone()
Returns a deep copy of this exact type of gene. |
boolean |
equals(java.lang.Object o)
Compares the specified object with this collection for equality. |
void |
evaluate(Population population,
boolean redo)
Evaluates the fitness of the Genomes, if necessary. |
java.lang.Object |
get()
Use with care!! Will not clear fitness if the return-value is modified. |
java.lang.Object |
get(int i)
Use with care! Will not clear fitness if the return-value is modified. |
double |
getFitness()
Get the fitness calculated the least recently. |
boolean |
hasFitness()
Whether genome has a fitness != Double.NaN. |
int |
hashCode()
Returns the hash code value for this collection. |
Gene |
inverse()
Get an inverted version of this Genome. |
Gene |
mutate(double probability)
Get a mutated version of this Gene. |
Gene[] |
recombine(Gene[] parents,
int childrenCount,
double recombinationProbability)
Genetically recombine gene data of parents to their children via reproduction.. |
java.lang.Object |
set(int i,
java.lang.Object g)
Set one gene. |
void |
set(java.lang.Object list)
Set the Genome data. |
void |
setFitness(double fitness)
Set the fitness calculated. |
void |
setFitness(java.lang.Number fitness)
|
Methods inherited from class orbital.algorithm.evolutionary.Gene.List |
---|
distanceMeasure, elementwiseRecombine, toString, uniformRecombine |
Methods inherited from class orbital.util.DelegateList |
---|
addAll, indexOf, lastIndexOf, listIterator, listIterator, remove, setDelegatee, setDelegatee, subList |
Methods inherited from class orbital.util.DelegateCollection |
---|
addAll, clear, contains, containsAll, getDelegatee, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.List |
---|
addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Field Detail |
---|
public static final java.util.Comparator comparator
Constructor Detail |
---|
public Genome()
public Genome(Gene content)
content
- the initial member gene.add(Object)
Method Detail |
---|
public java.lang.Object clone()
Gene.List
clone
in interface Gene
clone
in class Gene.List
public boolean equals(java.lang.Object o)
DelegateCollection
While the Collection interface adds no stipulations to the general contract for the Object.equals, programmers who implement the Collection interface "directly" (in other words, create a class that is a Collection but is not a Set or a List) must exercise care if they choose to override the Object.equals. It is not necessary to do so, and the simplest course of action is to rely on Object's implementation, but the implementer may wish to implement a "value comparison" in place of the default "reference comparison." (The List and Set interfaces mandate such value comparisons.)
The general contract for the Object.equals method states that equals must be symmetric (in other words, a.equals(b) if and only if b.equals(a)). The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)
equals
in interface java.util.Collection
equals
in interface java.util.List
equals
in interface Gene
equals
in class Gene.List
o
- Object to be compared for equality with this collection.
Object.equals(Object)
,
Set.equals(Object)
,
List.equals(Object)
public int hashCode()
DelegateCollection
hashCode
in interface java.util.Collection
hashCode
in interface java.util.List
hashCode
in interface Gene
hashCode
in class Gene.List
Object.hashCode()
,
Object.equals(Object)
public double getFitness()
evaluate(Population, boolean)
,
setFitness(double)
public boolean hasFitness()
getFitness()
public void setFitness(double fitness)
public void setFitness(java.lang.Number fitness)
public void clearFitness()
Double.NaN
.
setFitness(double)
public java.lang.Object get(int i)
get
in interface java.util.List
get
in class DelegateList
public java.lang.Object set(int i, java.lang.Object g)
set
in interface java.util.List
set
in class DelegateList
public boolean add(java.lang.Object o)
add
in interface java.util.Collection
add
in interface java.util.List
add
in class DelegateCollection
o
- element whose presence in this collection is to be ensured.
public void add(int index, java.lang.Object o)
add
in interface java.util.List
add
in class DelegateList
public java.lang.Object get()
get
in interface Gene
get
in class Gene.List
get(int)
public void set(java.lang.Object list)
set
in interface Gene
set
in class Gene.List
list
- the Object this gene should represent.
Encodes the value such that this gene represents the given object.public Gene mutate(double probability)
Gene.List
Implemented as Element-wise mutation.
mutate
in interface Gene
mutate
in class Gene.List
probability
- the probability rating of mutation level.
f.ex. probability with that each bit of the Gene mutates.
public Gene[] recombine(Gene[] parents, int childrenCount, double recombinationProbability)
Gene.List
a a = direct ancestors to be used n * --- ; n = number of children to be produced p p = probability for each part of parent's Gene to be inherited a/p = elongation of Gene length n/a = growth of population size if n/a < 1 the population is contracting. if n/a = 1 the population size is fixed. if n/a > 1 the population is growing.Usually it is p=n/a..
recombine
in interface Gene
recombine
in class Gene.List
parents
- the Genes to be used as parents for the children.
a
is the number of parents (direct ancestors).
parents are readonly.childrenCount
- the number of Gene children to produce and return.
n
is the number of children to be produced.recombinationProbability
- the probability with that parts of the inherited gene data
is recombined.
This does not necessarily imply an exchange of data, Genes might as well
realign or repair at random. But it makes a data recombination possible.
childrenCount
children produced.Gene.List.elementwiseRecombine(Gene[],int,double)
public Gene inverse()
inverse
in interface Gene
inverse
in class Gene.List
public void evaluate(Population population, boolean redo)
Default implementation will consider GeneticAlgorithm.getEvaluation()
.
redo
- force whole evaluation again, even for cached fitness values.
Should usually be false
for efficiency reasons.population
- the population containing this genome.
(Redundant information but required for better performance).getFitness()
|
Orbital library 1.3.0: 11 Apr 2009 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |