org.apache.commons.math3.genetics

## Class AbstractListChromosome<T>

- java.lang.Object
- - org.apache.commons.math3.genetics.Chromosome
  - - org.apache.commons.math3.genetics.AbstractListChromosome<T>

- Type Parameters:
    `T` - type of the representation list
  All Implemented Interfaces:
    java.lang.Comparable<Chromosome>, Fitness
  Direct Known Subclasses:
    BinaryChromosome, RandomKey

      public abstract class AbstractListChromosome<T>
      extends Chromosome

  Chromosome represented by an immutable list of a fixed length.
  Since:
    2.0
  Version:
    $Id: AbstractListChromosome.java 1416643 2012-12-03 19:37:14Z tn $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.util.List<T>` | `representation` List representing the chromosome

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractListChromosome(java.util.List<T> representation)` Constructor.
    `AbstractListChromosome(T[] representation)` Constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `checkValidity(java.util.List<T> chromosomeRepresentation)` Asserts that `representation` can represent a valid chromosome.
    `int` | `getLength()` Returns the length of the chromosome.
    `protected java.util.List<T>` | `getRepresentation()` Returns the (immutable) inner representation of the chromosome.
    `abstract AbstractListChromosome<T>` | `newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)` Creates a new instance of the same class as `this` is, with a given `arrayRepresentation`.
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.apache.commons.math3.genetics.Chromosome

      `compareTo, findSameChromosome, getFitness, isSame, searchForFitnessUpdate`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.math3.genetics.Fitness

      `fitness`

- - ### Field Detail

    - #### representation

          private final java.util.List<T> representation

      List representing the chromosome

  - ### Constructor Detail

    - #### AbstractListChromosome

          public AbstractListChromosome(java.util.List<T> representation)
                                 throws InvalidRepresentationException

      Constructor.
      Parameters:
        `representation` - inner representation of the chromosome
      Throws:
        `InvalidRepresentationException` - iff the `representation` can not represent a valid chromosome

    - #### AbstractListChromosome

          public AbstractListChromosome(T[] representation)
                                 throws InvalidRepresentationException

      Constructor.
      Parameters:
        `representation` - inner representation of the chromosome
      Throws:
        `InvalidRepresentationException` - iff the `representation` can not represent a valid chromosome

  - ### Method Detail

    - #### checkValidity

          protected abstract void checkValidity(java.util.List<T> chromosomeRepresentation)
                                         throws InvalidRepresentationException

      Asserts that `representation` can represent a valid chromosome.
      Parameters:
        `chromosomeRepresentation` - representation of the chromosome
      Throws:
        `InvalidRepresentationException` - iff the `representation` can not represent a valid chromosome

    - #### getRepresentation

          protected java.util.List<T> getRepresentation()

      Returns the (immutable) inner representation of the chromosome.
      Returns:
        the representation of the chromosome

    - #### getLength

          public int getLength()

      Returns the length of the chromosome.
      Returns:
        the length of the chromosome

    - #### newFixedLengthChromosome

          public abstract AbstractListChromosome<T> newFixedLengthChromosome(java.util.List<T> chromosomeRepresentation)

      Creates a new instance of the same class as `this` is, with a given `arrayRepresentation`. This is needed in crossover and mutation operators, where we need a new instance of the same class, but with different array representation.

      Usually, this method just calls a constructor of the class.

      Parameters:
        `chromosomeRepresentation` - the inner array representation of the new chromosome.
      Returns:
        new instance extended from FixedLengthChromosome with the given arrayRepresentation

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`

Copyright (c) 2003-2013 Apache Software Foundation