IntChromosome (JEvolution)
Date: 2013-03-21

evSOLve.JEvolution.chromosomes

## Class IntChromosome

- java.lang.Object
- - evSOLve.JEvolution.chromosomes.Chromosome
  - - evSOLve.JEvolution.chromosomes.IntChromosome

- All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable
  Direct Known Subclasses:
    PermChromosome

      public class IntChromosome
      extends Chromosome

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<java.lang.Integer>` | `bases` The genetic information carrier.
    `protected int` | `high` The largest integer encoded.
    `protected int` | `low` The lowest integer encoded.

    - ### Fields inherited from class evSOLve.JEvolution.chromosomes.Chromosome

      `BIASED, crossoverPoints, crossoverRate, LAPLACE, length, mutationRate, soupType`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `IntChromosome()` Creates a chromosome with default length.
    `IntChromosome(Element c)` Creates an IntChromosome via XML.
    `IntChromosome(int length)` Constructs a chromosome of given length.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `clone()` A proper clone, cloning the bases deeply by creating new objects.
    `void` | `doCrossover(Chromosome father)` Standard 1-, or 2-Point Crossover.
    `void` | `doMutation()` Mutate by randomly setting a base to a new integer value within 'low' and 'high' (both included).
    `boolean` | `equals(java.lang.Object o)` An efficient check for equality.
    `void` | `fromString(java.lang.String b)` Create bases from String.
    `java.lang.Object` | `getBases()` Return the genetic information.
    `int` | `getHigh()` Gives higher bound of integer encoding.
    `int` | `getLow()` Gives lower bound of integer encoding.
    `int` | `hashCode()` An efficient hash code.
    `void` | `mixSoup()` Initial creation of alleles.
    `void` | `setHigh(int high)` Changes higher bound of integer encoding.
    `void` | `setLow(int low)` Changes lower bound of integer encoding.
    `java.lang.String` | `toString()` Convert chromosome to string.
    `Element` | `toXml(Element parent)` Saves the current state to XML.

    - ### Methods inherited from class evSOLve.JEvolution.chromosomes.Chromosome

      `create, 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.List<java.lang.Integer> bases

      The genetic information carrier.

    - #### low

          protected int low

      The lowest integer encoded.

    - #### high

          protected int high

      The largest integer encoded.

  - ### Constructor Detail

    - #### IntChromosome

          public IntChromosome()

      Creates a chromosome with default length.

    - #### IntChromosome

          public IntChromosome(int length)

      Constructs a chromosome of given length.
      Parameters:
        `length` - the number of bases

    - #### IntChromosome

          public IntChromosome(Element c)

      Creates an IntChromosome via XML.
      Parameters:
        `c` - an XML Chromosome element

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()

      A proper clone, cloning the bases deeply by creating new objects.
      Overrides:
        `clone` in class `Chromosome`
      Returns:
        Object the cloned IntChromosome

    - #### 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.
      Specified by:
        `equals` in class `Chromosome`
      Returns:
        equal The equality of the passed object with this object.

    - #### hashCode

          public int hashCode()

      An efficient hash code. Uses Vector.hashCode().
      Specified by:
        `hashCode` in class `Chromosome`
      Returns:
        hashCode A correct hash code.

    - #### doMutation

          public void doMutation()

      Mutate by randomly setting a base to a new integer value within 'low' and 'high' (both included). It may occur that the new value is equal to the old.
      Specified by:
        `doMutation` in class `Chromosome`

    - #### doCrossover

          public void doCrossover(Chromosome father)

      Standard 1-, or 2-Point Crossover.
      Specified by:
        `doCrossover` in class `Chromosome`
      Parameters:
        `father` - A parent Chromosome.

    - #### mixSoup

          public void mixSoup()

      Initial creation of alleles. Integers are randomly drawn from uniform distribution (eventually biased).
      Specified by:
        `mixSoup` in class `Chromosome`

    - #### getLow

          public int getLow()

      Gives lower bound of integer encoding.
      Returns:
        the smallest integer encoded

    - #### setLow

          public void setLow(int low)

      Changes lower bound of integer encoding.
      Parameters:
        `low` - the smallest integer encoded

    - #### getHigh

          public int getHigh()

      Gives higher bound of integer encoding.
      Returns:
        the largest integer encoded

    - #### setHigh

          public void setHigh(int high)

      Changes higher bound of integer encoding.
      Parameters:
        `high` - the largest integer encoded

    - #### getBases

          public java.lang.Object getBases()

      Return the genetic information.
      Specified by:
        `getBases` in class `Chromosome`
      Returns:
        bases The bases.

    - #### toString

          public java.lang.String toString()

      Convert chromosome to string. The first base (the rightmost) has index 0.
      Specified by:
        `toString` in class `Chromosome`

    - #### fromString

          public void fromString(java.lang.String b)

      Create bases from String. The syntax of the string must be like this: "1|2|3|4|", where the numbers are just examples, but the '|' character must be exactly at the given spots.
      Specified by:
        `fromString` in class `Chromosome`
      Parameters:
        `b` - a String describing the bases

    - #### toXml

          public Element toXml(Element parent)

      Saves the current state to XML.
      Overrides:
        `toXml` in class `Chromosome`
      Parameters:
        `parent` - the JDOM parent element
      Returns:
        the Chromosome element