BitChromosome (JEvolution)
Date: 2013-03-21

evSOLve.JEvolution.chromosomes

## Class BitChromosome

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

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

      public class BitChromosome
      extends Chromosome

  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.List<java.lang.Boolean>` | `bases` The carrier of genetic information.

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

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BitChromosome()` The standard constructor with default length.
    `BitChromosome(Element c)` Creates a BitChromosome via XML.
    `BitChromosome(int length)` Constructs a chromosome of given length.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `clone()` A proper clone.
    `void` | `doCrossover(Chromosome father)` k-point Crossover.
    `void` | `doMutation()` Bit flip mutation.
    `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` | `hashCode()` An efficient hash code.
    `void` | `mixSoup()` Initial creation of alleles.
    `java.lang.String` | `toString()` Convert chromosome to string.

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

      `create, getCrossoverPoints, getCrossoverRate, getLength, getMutationRate, getSoupType, setCrossoverPoints, setCrossoverRate, setLength, setMutationRate, setSoupType, toXml`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### bases

          protected java.util.List<java.lang.Boolean> bases

      The carrier of genetic information.

  - ### Constructor Detail

    - #### BitChromosome

          public BitChromosome()

      The standard constructor with default length.

    - #### BitChromosome

          public BitChromosome(int length)

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

    - #### BitChromosome

          public BitChromosome(Element c)

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

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()

      A proper clone.
      Overrides:
        `clone` in class `Chromosome`
      Returns:
        Object The clone.

    - #### equals

          public boolean equals(java.lang.Object o)

      An efficient check for equality. Uses List.equals().
      Specified by:
        `equals` in class `Chromosome`
      Returns:
        the equality of the passed object with this object.

    - #### hashCode

          public int hashCode()

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

    - #### doMutation

          public void doMutation()

      Bit flip mutation.
      Specified by:
        `doMutation` in class `Chromosome`

    - #### doCrossover

          public void doCrossover(Chromosome father)

      k-point Crossover. By now k may be only 1 or 2!!
      Specified by:
        `doCrossover` in class `Chromosome`
      Parameters:
        `father` - A parent Chromosome (technically already a child).

    - #### mixSoup

          public void mixSoup()

      Initial creation of alleles.
      Specified by:
        `mixSoup` in class `Chromosome`

    - #### getBases

          public java.lang.Object getBases()

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

    - #### toString

          public java.lang.String toString()

      Convert chromosome to string. The MSB has index 0.
      Specified by:
        `toString` in class `Chromosome`

    - #### fromString

          public void fromString(java.lang.String b)

      Create bases from String.
      Specified by:
        `fromString` in class `Chromosome`
      Parameters:
        `b` - a String describing the bases