Class DoubleGenotype

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

    public class DoubleGenotype
    extends java.util.ArrayList<java.lang.Double>
    implements ListGenotype<java.lang.Double>

    The DoubleGenotype consists of double values that can be used as a Genotype.

    Example problem: Select filling level of five bottles
    Example usage:

     DoubleGenotype<Switch> genotype = new DoubleGenotype();
     genotype.init(new Random(), 5);
     
    Example instance: [0.5035947840006195, 0.9693492473483428, 0.12786372316728167, 0.5299369900029843, 0.8055193291478467]
    Example search space size: [0;1]5

    See Also:
    Serialized Form
    • Field Summary

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

        modCount
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getLowerBound​(int index)
      Returns the lower bound for the i-th element.
      double 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.Double> bounds
    • Constructor Detail

      • DoubleGenotype

        public DoubleGenotype()
        Constructs a DoubleGenotype with lower bounds 0.0 and upper bounds 1.0.
      • DoubleGenotype

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

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

      • getLowerBound

        public double 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 double 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