Package io.jenetics

Class DoubleChromosome

    • Constructor Detail

      • DoubleChromosome

        protected DoubleChromosome​(ISeq<DoubleGene> genes,
                                   IntRange lengthRange)
        Create a new chromosome from the given genes and the allowed length range of the chromosome.
        Parameters:
        genes - the genes that form the chromosome.
        lengthRange - the allowed length range of the chromosome
        Throws:
        NullPointerException - if one of the arguments is null.
        IllegalArgumentException - if the length of the gene sequence is empty, doesn't match with the allowed length range, the minimum or maximum of the range is smaller or equal zero or the given range size is zero.
        Since:
        4.0
    • Method Detail

      • doubleStream

        public DoubleStream doubleStream()
        Returns a sequential stream of the alleles with this chromosome as its source.
        Returns:
        a sequential stream of alleles
        Since:
        4.3
      • toArray

        public double[] toArray​(double[] array)
        Returns an double array containing all of the elements in this chromosome in proper sequence. If the chromosome fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the length of this chromosome.
        Parameters:
        array - the array into which the elements of this chromosomes are to be stored, if it is big enough; otherwise, a new array is allocated for this purpose.
        Returns:
        an array containing the elements of this chromosome
        Throws:
        NullPointerException - if the given array is null
        Since:
        3.0
      • toArray

        public double[] toArray()
        Returns an double array containing all of the elements in this chromosome in proper sequence.
        Returns:
        an array containing the elements of this chromosome
        Since:
        3.0
      • of

        public static DoubleChromosome of​(DoubleGene... genes)
        Create a new DoubleChromosome with the given genes.
        Parameters:
        genes - the genes of the chromosome.
        Returns:
        a new chromosome with the given genes.
        Throws:
        IllegalArgumentException - if the length of the genes array is empty or the given genes doesn't have the same range.
        NullPointerException - if the given genes array is null
      • of

        public static DoubleChromosome of​(Iterable<DoubleGene> genes)
        Create a new DoubleChromosome with the given genes.
        Parameters:
        genes - the genes of the chromosome.
        Returns:
        a new chromosome with the given genes.
        Throws:
        NullPointerException - if the given genes are null
        IllegalArgumentException - if the of the genes iterable is empty or the given genes doesn't have the same range.
        Since:
        4.3
      • of

        public static DoubleChromosome of​(double min,
                                          double max,
                                          IntRange lengthRange)
        Create a new random chromosome.
        Parameters:
        min - the min value of the DoubleGenes (inclusively).
        max - the max value of the DoubleGenes (exclusively).
        lengthRange - the allowed length range of the chromosome.
        Returns:
        a new DoubleChromosome with the given parameter
        Throws:
        IllegalArgumentException - if the length of the gene sequence is empty, doesn't match with the allowed length range, the minimum or maximum of the range is smaller or equal zero or the given range size is zero.
        NullPointerException - if the given lengthRange is null
        Since:
        4.0
      • of

        public static DoubleChromosome of​(double min,
                                          double max,
                                          int length)
        Create a new random DoubleChromosome.
        Parameters:
        min - the min value of the DoubleGenes (inclusively).
        max - the max value of the DoubleGenes (exclusively).
        length - the length of the chromosome.
        Returns:
        a new DoubleChromosome with the given parameter
        Throws:
        IllegalArgumentException - if the length is smaller than one.
      • of

        public static DoubleChromosome of​(DoubleRange range,
                                          IntRange lengthRange)
        Create a new random chromosome.
        Parameters:
        range - the integer range of the chromosome.
        lengthRange - the allowed length range of the chromosome.
        Returns:
        a new DoubleChromosome with the given parameter
        Throws:
        IllegalArgumentException - if the length of the gene sequence is empty, doesn't match with the allowed length range, the minimum or maximum of the range is smaller or equal zero or the given range size is zero.
        NullPointerException - if the given lengthRange is null
        Since:
        4.0
      • of

        public static DoubleChromosome of​(DoubleRange range,
                                          int length)
        Create a new random DoubleChromosome.
        Parameters:
        range - the integer range of the chromosome.
        length - the length of the chromosome.
        Returns:
        a new random DoubleChromosome
        Throws:
        NullPointerException - if the given range is null
        IllegalArgumentException - if the length is smaller than one.
        Since:
        3.2
      • of

        public static DoubleChromosome of​(double min,
                                          double max)
        Create a new random DoubleChromosome of length one.
        Parameters:
        min - the minimal value of this chromosome (inclusively).
        max - the maximal value of this chromosome (exclusively).
        Returns:
        a new DoubleChromosome with the given parameter
      • of

        public static DoubleChromosome of​(DoubleRange range)
        Create a new random DoubleChromosome of length one.
        Parameters:
        range - the double range of the chromosome.
        Returns:
        a new random DoubleChromosome of length one
        Throws:
        NullPointerException - if the given range is null
        Since:
        3.2
      • min

        public A min()
        Description copied from interface: BoundedChromosome
        Return the minimum value of this BoundedChromosome.
        Specified by:
        min in interface BoundedChromosome<A extends Comparable<? super A>,​G extends BoundedGene<A,​G>>
        Returns:
        the minimum value of this BoundedChromosome.
      • max

        public A max()
        Description copied from interface: BoundedChromosome
        Return the maximum value of this BoundedChromosome.
        Specified by:
        max in interface BoundedChromosome<A extends Comparable<? super A>,​G extends BoundedGene<A,​G>>
        Returns:
        the maximum value of this BoundedChromosome.
      • hashCode

        public int hashCode()
      • equals

        public boolean equals​(Object obj)
      • lengthRange

        public IntRange lengthRange()
        Return the allowed length range of the chromosome. The minimum value of the range is included and the maximum value is excluded.
        Returns:
        the allowed length range of the chromosome