Orbital library

orbital.algorithm.evolutionary
Class Gene.BitSet

java.lang.Object
  extended by orbital.algorithm.evolutionary.Gene.BitSet
All Implemented Interfaces:
java.io.Serializable, Gene
Direct Known Subclasses:
Gene.Fixed
Enclosing interface:
Gene

public static class Gene.BitSet
extends java.lang.Object
implements Gene, java.io.Serializable

Bit string gene.

Much like DNA, this implementation uses a boolean-array as Gene data. However, the interpretation of this bit string is, of course, problem specific.

Author:
André Platzer
See Also:
Serialized Form

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.BitSet(int length)
          Create a Gene of a certain length.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this gene.
 Metric distanceMeasure()
          Get the distance measure for this class.
 boolean equals(java.lang.Object o)
           
 java.lang.Object get()
          Get the gene interpretation value.
 boolean get(int index)
          Get the boolean value at index.
 int hashCode()
           
 Gene inverse()
          Get an inverted version of this Gene.
 int length()
          Get the length of the boolean data.
 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(int index, boolean value)
          Set the boolean value at index.
 void set(java.lang.Object n)
          Set the gene value.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Gene.BitSet

public Gene.BitSet(int length)
Create a Gene of a certain length.

Parameters:
length - the number of boolean data flags in this Gene.
Method Detail

clone

public java.lang.Object clone()
Description copied from interface: Gene
Returns a clone of this gene.

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

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface Gene
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Gene
Overrides:
hashCode in class java.lang.Object

length

public final int length()
Get the length of the boolean data.


get

public boolean get(int index)
Get the boolean value at index.

Returns:
the boolean data at the bit with index.

set

public void set(int index,
                boolean value)
Set the boolean value at index.

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

Parameters:
value - the boolean value to be set at index.

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 n)
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:
n - 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 uniform mutation. Each bit of Gene data will be flipped with a specified probability.

Specified by:
mutate in interface Gene
Parameters:
probability - the 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..

Implemented as uniform recombination.

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.

inverse

public Gene inverse()
Get an inverted version of this Gene.

Specified by:
inverse in interface Gene
Returns:
the complementary inverted Gene where all data booleans are negated.

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()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object

Orbital library
1.3.0: 11 Apr 2009

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