jaga
Class Genotype

java.lang.Object
  |
  +--java.util.BitSet
        |
        +--jaga.BitSet
              |
              +--jaga.Genotype
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, islandev.Individual, java.io.Serializable
Direct Known Subclasses:
FullOrderGenotype

public class Genotype
extends BitSet
implements islandev.Individual

Genotypes are bitsets with a fitness which is reset whenever a bit is touched.

Genotypes also contain properties, for example to store different paramaters about individuals or multiple fitness values.

See Also:
Serialized Form

Field Summary
static java.lang.String FIT_DECL
           
static java.lang.String GEN_DECL
           
static java.lang.String LEN_DECL
           
static double MAX_FITNESS
           
static java.lang.String PROP_DECL
           
 
Constructor Summary
Genotype()
           
Genotype(int length)
          Creates new Genotype
Genotype(java.lang.String bits)
           
Genotype(java.lang.String symbols, int length, int base)
           
 
Method Summary
 void addProperty(java.lang.Object value)
           
 boolean bitSetEquals(BitSet o)
           
 void clear(int idx)
           
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Only look at fitness when comparing.
 boolean equals(java.lang.Object o)
           
 void flip(int index)
          Flips this bit (0->1, 1->0)
 double getFitness()
           
 double getFitness(int n)
          Assuming properties are double, returns the nth fitness, st.
 java.lang.Object getProperty(int index)
          Returns a property of this genotype
 void set(int idx)
           
 void setFitness(double fitness)
           
 void setLength(int length)
           
 void setProperty(int index, java.lang.Object value)
          This sets a property of this genotype
 void setTo(int idx, boolean value)
          automatically reset fitness when genetic code modified
 java.lang.String toString()
          Will convert the BitSet to a string using the current codebase.
 void touched()
           
 
Methods inherited from class jaga.BitSet
bitsToInt, getBooleanChunk, getChunk, hashCode, length, setBits, setCodeBase
 
Methods inherited from class java.util.BitSet
and, andNot, get, or, size, xor
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_FITNESS

public static final double MAX_FITNESS

GEN_DECL

public static final java.lang.String GEN_DECL

FIT_DECL

public static final java.lang.String FIT_DECL

LEN_DECL

public static final java.lang.String LEN_DECL

PROP_DECL

public static final java.lang.String PROP_DECL
Constructor Detail

Genotype

public Genotype(int length)
Creates new Genotype

Genotype

public Genotype()

Genotype

public Genotype(java.lang.String bits)

Genotype

public Genotype(java.lang.String symbols,
                int length,
                int base)
Method Detail

compareTo

public int compareTo(java.lang.Object o)
Only look at fitness when comparing.
Specified by:
compareTo in interface java.lang.Comparable

setTo

public void setTo(int idx,
                  boolean value)
automatically reset fitness when genetic code modified
Overrides:
setTo in class BitSet

set

public void set(int idx)
Overrides:
set in class java.util.BitSet

clear

public void clear(int idx)
Overrides:
clear in class java.util.BitSet

flip

public void flip(int index)
Description copied from class: BitSet
Flips this bit (0->1, 1->0)
Overrides:
flip in class BitSet

setLength

public void setLength(int length)
Overrides:
setLength in class BitSet

touched

public void touched()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.util.BitSet

bitSetEquals

public boolean bitSetEquals(BitSet o)

toString

public java.lang.String toString()
Description copied from class: BitSet
Will convert the BitSet to a string using the current codebase.
Overrides:
toString in class BitSet

getFitness

public double getFitness()
Specified by:
getFitness in interface islandev.Individual

setFitness

public void setFitness(double fitness)

setProperty

public void setProperty(int index,
                        java.lang.Object value)
This sets a property of this genotype

addProperty

public void addProperty(java.lang.Object value)

getProperty

public java.lang.Object getProperty(int index)
Returns a property of this genotype
Specified by:
getProperty in interface islandev.Individual

getFitness

public double getFitness(int n)
Assuming properties are double, returns the nth fitness, st. -1 is .fitness and for n >= 0 its the nth property.

clone

public java.lang.Object clone()
Overrides:
clone in class java.util.BitSet