evSOLve.JEvolution
Class IntChromosome

java.lang.Object
  |
  +--evSOLve.JEvolution.Chromosome
        |
        +--evSOLve.JEvolution.IntChromosome
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class IntChromosome
extends Chromosome

Integer encoding. The bases are implemented as a Vector of Integers with values ranging from 'lowInt' to 'highInt'. Mutation is implemented as randomly selecting a new integer, crossover is standard 1-, or 2-point.

Version:
0.4
Author:
Helmut A. Mayer
See Also:
Serialized Form

Field Summary
protected  java.util.Vector bases
          The genetic information carrier.
protected  int highInt
          The largest integer encoded.
protected  int lowInt
          The lowest integer encoded.
 
Fields inherited from class evSOLve.JEvolution.Chromosome
BIASED, crossoverPoints, crossoverRate, JA, LAPLACE, length, mutationRate, soupType, utils
 
Constructor Summary
IntChromosome()
          Creates a chromosome with 'lenght' bases, and default values for 'lowInt' (0) and 'highInt' ('length' - 1).
 
Method Summary
 java.lang.Object clone()
          A proper clone, cloning the bases deeply by creating new objects.
protected  void doCrossover(Chromosome father)
          Standard 1-, or 2-Point Crossover.
protected  void doMutation()
          Mutate by randomly setting a base to a new integer value within 'lowIndex' and 'highIndex' (both included).
 boolean equals(java.lang.Object o)
          An efficient check for equality.
 java.lang.Object getBases()
          Return the genetic information.
 int getHighInt()
          Gives high index of integer encoding.
 int getLowInt()
          Gives low index of integer encoding.
 int hashCode()
          An efficient hash code.
 void setBases(java.lang.Object bases)
          Set bases to a known solution.
 void setHighInt(int highInt)
          Change low index of integer encoding.
 void setLowInt(int lowIndex)
          Changes low index of integer encoding.
 java.lang.String toString()
          Convert chromosome to string.
 
Methods inherited from class evSOLve.JEvolution.Chromosome
getCrossoverPoints, getCrossoverRate, getLength, getMutationRate, getSoupType, setCrossoverPoints, setCrossoverRate, setLength, setMutationRate, setSoupType
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bases

protected java.util.Vector bases
The genetic information carrier.

lowInt

protected int lowInt
The lowest integer encoded.

highInt

protected int highInt
The largest integer encoded.
Constructor Detail

IntChromosome

public IntChromosome()
Creates a chromosome with 'lenght' bases, and default values for 'lowInt' (0) and 'highInt' ('length' - 1).
Method Detail

clone

public java.lang.Object clone()
A proper clone, cloning the bases deeply by creating new objects.
Overrides:
clone in class Chromosome

equals

public boolean equals(java.lang.Object o)
An efficient check for equality. It only checks the bases, first, if the number of bases is equal, and then if the base values are the same.
Overrides:
equals in class Chromosome

hashCode

public int hashCode()
An efficient hash code. Uses Vector.hashCode().
Overrides:
hashCode in class Chromosome

doMutation

protected void doMutation()
Mutate by randomly setting a base to a new integer value within 'lowIndex' and 'highIndex' (both included). It may occur that the new value is equal to the old.
Overrides:
doMutation in class Chromosome

doCrossover

protected void doCrossover(Chromosome father)
Standard 1-, or 2-Point Crossover.
Overrides:
doCrossover in class Chromosome
Parameters:
father - A parent Chromosome.

getLowInt

public int getLowInt()
Gives low index of integer encoding.

setLowInt

public void setLowInt(int lowIndex)
Changes low index of integer encoding.
Parameters:
lowInt - the smallest integer encoded

getHighInt

public int getHighInt()
Gives high index of integer encoding.

setHighInt

public void setHighInt(int highInt)
Change low index of integer encoding.
Parameters:
highInt - the largest integer encoded

getBases

public java.lang.Object getBases()
Return the genetic information.

setBases

public void setBases(java.lang.Object bases)
Set bases to a known solution.
Parameters:
bases - The encoded solution.

toString

public java.lang.String toString()
Convert chromosome to string. The first base (the rightmost) has index 0.
Overrides:
toString in class Chromosome