Package io.jenetics

Class CharacterChromosome

    • Constructor Detail

      • CharacterChromosome

        protected CharacterChromosome​(ISeq<CharacterGene> genes,
                                      IntRange lengthRange)
        Create a new chromosome from the given genes array. The genes array is copied, so changes to the given genes array doesn't effect the genes of this chromosome.
        Parameters:
        genes - the genes that form the chromosome.
        lengthRange - the allowed length range of the chromosome.
        Throws:
        NullPointerException - if the given gene array is null.
        IllegalArgumentException - if the length of the gene array is smaller than one.
        Since:
        4.0
    • Method Detail

      • toArray

        public char[] toArray​(char[] array)
        Returns an char 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 char[] toArray()
        Returns an char 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 CharacterChromosome of​(CharSeq validCharacters,
                                             IntRange lengthRange)
        Create a new chromosome with the validCharacters char set as valid characters.
        Parameters:
        validCharacters - the valid characters for this chromosome.
        lengthRange - the allowed length range of the chromosome.
        Returns:
        a new CharacterChromosome with the given parameter
        Throws:
        NullPointerException - if the validCharacters 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.3
      • of

        public static CharacterChromosome of​(CharSeq validCharacters,
                                             int length)
        Create a new chromosome with the validCharacters char set as valid characters.
        Parameters:
        validCharacters - the valid characters for this chromosome.
        length - the length of the new chromosome.
        Returns:
        a new CharacterChromosome with the given parameter
        Throws:
        NullPointerException - if the validCharacters 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.3
      • of

        public static CharacterChromosome of​(String alleles,
                                             CharSeq validChars)
        Create a new chromosome from the given genes (given as string).
        Parameters:
        alleles - the character genes.
        validChars - the valid characters.
        Returns:
        a new CharacterChromosome with the given parameter
        Throws:
        IllegalArgumentException - if the genes string is empty.
      • of

        public static CharacterChromosome of​(String alleles)
        Create a new chromosome from the given genes (given as string).
        Parameters:
        alleles - the character genes.
        Returns:
        a new CharacterChromosome with the given parameter
        Throws:
        IllegalArgumentException - if the genes string is empty.
      • 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