Orbital library

orbital.algorithm.evolutionary
Class Gene.List

java.lang.Object
  extended by orbital.util.DelegateCollection
      extended by orbital.util.DelegateList
          extended by orbital.algorithm.evolutionary.Gene.List
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable, java.util.Collection, java.util.List, Gene
Direct Known Subclasses:
Genome
Enclosing interface:
Gene

public static class Gene.List
extends DelegateList
implements Gene, java.io.Serializable

Represents a container gene that contains a list of other genes.

This list is especially useful for aggregating a collection of correlated genes into a single logical gene.

Author:
André Platzer
See Also:
Serialized Form
Invariants:
sub classes support nullary constructor (for virtual new instance).
Structure:
extends DelegateList, aggregates members:List

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
 
Constructor Summary
Gene.List()
           
Gene.List(java.lang.Class geneType, int size)
          new list of Genes.
 
Method Summary
 java.lang.Object clone()
          Returns a deep copy of this exact type of gene.
 Metric distanceMeasure()
          Get the distance measure for this class.
protected  Gene[] elementwiseRecombine(Gene[] parents, int childrenCount, double recombinationProbability)
          Implemented as element-wise recombination, each gene does recombine, separately.
 boolean equals(java.lang.Object o)
          Compares the specified object with this collection for equality.
 java.lang.Object get()
          Get the gene interpretation value.
 int hashCode()
          Returns the hash code value for this collection.
 Gene inverse()
          Get an inverted version of this Gene.
 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..
 void set(java.lang.Object list)
          Set the gene value.
 java.lang.String toString()
           
protected  Gene[] uniformRecombine(Gene[] parents, int childrenCount, double recombinationProbability)
          Implemented as uniform recombination, uniformly distributes genes to the children.
 
Methods inherited from class orbital.util.DelegateList
add, addAll, get, indexOf, lastIndexOf, listIterator, listIterator, remove, set, setDelegatee, setDelegatee, subList
 
Methods inherited from class orbital.util.DelegateCollection
add, 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
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

Gene.List

public Gene.List(java.lang.Class geneType,
                 int size)
          throws java.lang.InstantiationException,
                 java.lang.IllegalAccessException
new list of Genes.

Parameters:
geneType - the type of the member genes.
size - the initial size of this list. i.e. the initial number of Genes.
Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException

Gene.List

public Gene.List()
Method Detail

clone

public java.lang.Object clone()
Returns a deep copy of this exact type of gene.

Specified by:
clone in interface Gene
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Description copied from class: DelegateCollection
Compares the specified object with this collection for equality.

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.)

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Specified by:
equals in interface Gene
Overrides:
equals in class DelegateCollection
Parameters:
o - Object to be compared for equality with this collection.
Returns:
true if the specified object is equal to this collection
See Also:
Object.equals(Object), Set.equals(Object), List.equals(Object)

hashCode

public int hashCode()
Description copied from class: DelegateCollection
Returns the hash code value for this collection. While the Collection interface adds no stipulations to the general contract for the Object.hashCode method, programmers should take note that any class that overrides the Object.equals method must also override the Object.hashCode method in order to satisfy the general contract for the Object.hashCodemethod. In particular, c1.equals(c2) implies that c1.hashCode()==c2.hashCode().

Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Specified by:
hashCode in interface Gene
Overrides:
hashCode in class DelegateCollection
Returns:
the hash code value for this collection
See Also:
Object.hashCode(), Object.equals(Object)

get

public java.lang.Object get()
Description copied from interface: Gene
Get the gene interpretation value.

Useful for interpreting a gene for fitness evaluation and interpretation of solutions.

Specified by:
get in interface Gene
Returns:
the Object represented by this gene. Interprets gene by decoding its data.

set

public void set(java.lang.Object list)
Description copied from interface: Gene
Set the gene value.

Consider setting fitness to Double.NaN due to the change to remind evaluator.

Specified by:
set in interface Gene
Parameters:
list - the Object this gene should represent. Encodes the value such that this gene represents the given object.

mutate

public Gene mutate(double probability)
Get a mutated version of this Gene.

Implemented as Element-wise mutation.

Specified by:
mutate in interface Gene
Parameters:
probability - the probability rating of mutation level. f.ex. probability with that each bit of the Gene mutates.
Returns:
a new gene that is a mutation of this one.

recombine

public Gene[] recombine(Gene[] parents,
                        int childrenCount,
                        double recombinationProbability)
Genetically recombine gene data of parents to their children via reproduction.
 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..

Specified by:
recombine in interface Gene
Parameters:
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.
Returns:
the new childrenCount children produced.
See Also:
elementwiseRecombine(Gene[],int,double)

elementwiseRecombine

protected Gene[] elementwiseRecombine(Gene[] parents,
                                      int childrenCount,
                                      double recombinationProbability)

Implemented as element-wise recombination, each gene does recombine, separately.


uniformRecombine

protected Gene[] uniformRecombine(Gene[] parents,
                                  int childrenCount,
                                  double recombinationProbability)

Implemented as uniform recombination, uniformly distributes genes to the children.


inverse

public Gene inverse()
Description copied from interface: Gene
Get an inverted version of this Gene.

Used in Population.create(Population, Genome, int) to form a balanced and least biased initial population.

Specified by:
inverse in interface Gene
Returns:
the complementary inverted Gene.

distanceMeasure

public Metric distanceMeasure()
Description copied from interface: Gene
Get the distance measure for this class.

Used to determine how different two genes are.

Specified by:
distanceMeasure in interface Gene
Returns:
a distance measure whose deviation is 1 such that it can easily be used as a measure for similarity. Additionally, only positive numbers should be returned. So this distance measure only has values in [0,1].

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.