Class IntegerGenotype

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.List<java.lang.Integer>, java.util.RandomAccess, Genotype, ListGenotype<java.lang.Integer>
    Direct Known Subclasses:
    IntegerMapGenotype, SelectGenotype, SelectMapGenotype

    public class IntegerGenotype
    extends java.util.ArrayList<java.lang.Integer>
    implements ListGenotype<java.lang.Integer>

    The IntegerGenotype is a Genotype that consists of Integer values.

    Example problem: Select the outcome of throwing five dice
    Example usage:

     IntegerGenotype genotype = new IntegerGenotype(1, 6);
     genotype.init(new Random(), 5);
     
    Example instance: [3, 5, 6, 1, 3]
    Example search space size: 65

    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Bounds<java.lang.Integer> bounds  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getLowerBound​(int index)
      Returns the lower bound for the i-th element.
      int getUpperBound​(int index)
      Returns the upper bound for the i-th element.
      void init​(java.util.Random random, int n)
      Initialize this genotype with n random values.
      <G extends Genotype>
      G
      newInstance()
      Constructs a new (empty) instance of this Genotype.
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
    • Field Detail

      • bounds

        protected final Bounds<java.lang.Integer> bounds
    • Constructor Detail

      • IntegerGenotype

        public IntegerGenotype​(int lowerBound,
                               int upperBound)
        Constructs a IntegerGenotype with a specified lower and upper bound for all values.
        Parameters:
        lowerBound - the lower bound
        upperBound - the upper bound
      • IntegerGenotype

        public IntegerGenotype​(Bounds<java.lang.Integer> bounds)
        Constructs a IntegerGenotype with the given Bounds.
        Parameters:
        bounds - the bounds
    • Method Detail

      • getLowerBound

        public int getLowerBound​(int index)
        Returns the lower bound for the i-th element.
        Parameters:
        index - the i-th element
        Returns:
        the lower bound of the i-th element
      • getUpperBound

        public int getUpperBound​(int index)
        Returns the upper bound for the i-th element.
        Parameters:
        index - the i-th element
        Returns:
        the upper bound of the i-th element
      • newInstance

        public <G extends Genotype> G newInstance()
        Description copied from interface: Genotype
        Constructs a new (empty) instance of this Genotype.
        Specified by:
        newInstance in interface Genotype
        Type Parameters:
        G - the type of genotype for an implicit cast
        Returns:
        new instance of the genotype
      • init

        public void init​(java.util.Random random,
                         int n)
        Initialize this genotype with n random values.
        Parameters:
        random - the random number generator
        n - the number of elements in the resulting genotype