public class BitChromosome extends Number implements Chromosome<BitGene>, Comparable<BitChromosome>, Serializable
| Modifier and Type | Field and Description | 
|---|---|
| protected byte[] | _genesThe boolean array which holds the  BitGenes. | 
| protected int | _lengthThe length of the chromosomes (number of bits). | 
| protected double | _pThe ones probability of the randomly generated Chromosome. | 
| Constructor and Description | 
|---|
| BitChromosome(byte[] bits)Create a new  BitChromosomefrom the givenbytearray. | 
| BitChromosome(byte[] bits,
             int start,
             int end)Create a new bit chromosome from the given bit (byte) array. | 
| Modifier and Type | Method and Description | 
|---|---|
| int | bitCount()Returns the number of bits set to true in this  BitChromosome. | 
| int | compareTo(BitChromosome that) | 
| double | doubleValue()Return the double value this BitChromosome represents. | 
| boolean | equals(Object obj) | 
| float | floatValue()Return the float value this BitChromosome represents. | 
| boolean | get()Return the value of the first gene of this chromosome. | 
| boolean | get(int index)Return the value on the specified index. | 
| BitGene | getGene()Return the first gene of this chromosome. | 
| BitGene | getGene(int index)Return the gene on the specified index. | 
| int | hashCode() | 
| int | intValue()Return the long value this BitChromosome represents. | 
| BitChromosome | invert()Invert the ones and zeros of this bit chromosome. | 
| boolean | isValid()Check if this object is valid. | 
| Iterator<BitGene> | iterator() | 
| int | length()Returns the length of the Chromosome. | 
| ListIterator<BitGene> | listIterator() | 
| long | longValue()Return the long value this BitChromosome represents. | 
| BitChromosome | newInstance()Create a new instance of type T. | 
| BitChromosome | newInstance(ISeq<BitGene> genes)A factory method which creates a new  Chromosomeof specific type
 and the givengenes. | 
| static BitChromosome | of(BigInteger value)Create a new  BitChromosomefrom the given big integer value. | 
| static BitChromosome | of(BitSet bits)Constructing a new BitChromosome from a given BitSet. | 
| static BitChromosome | of(BitSet bits,
  int length) | 
| static BitChromosome | of(CharSequence value)Create a new  BitChromosomefrom the given character sequence
 containing '0' and '1'; as created with thetoCanonicalString()method. | 
| static BitChromosome | of(int length)Constructing a new BitChromosome with the given _length. | 
| static BitChromosome | of(int length,
  double p)Construct a new BitChromosome with the given _length. | 
| IntStream | ones()Return the indexes of the ones of this bit-chromosome as stream. | 
| BigInteger | toBigInteger()Return the  BigIntegervalue thisBitChromosomerepresents. | 
| BitSet | toBitSet()Return the corresponding BitSet of this BitChromosome. | 
| byte[] | toByteArray() | 
| int | toByteArray(byte[] bytes)Returns the two's-complement binary representation of this
 large integer. | 
| String | toCanonicalString()Return the BitChromosome as String. | 
| ISeq<BitGene> | toSeq()Return an unmodifiable sequence of the genes of this chromosome. | 
| String | toString() | 
| IntStream | zeros()Return the indexes of the zeros of this bit-chromosome as stream. | 
byteValue, shortValueclone, finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected double _p
protected int _length
public BitChromosome(byte[] bits, int start, int end)
bits - the bit values of the new chromosome gene.start - the initial (bit) index of the range to be copied, inclusiveend - the final (bit) index of the range to be copied, exclusive.
        (This index may lie outside the array.)ArrayIndexOutOfBoundsException - if start < 0 or
         start > bits.length*8IllegalArgumentException - if start > endNullPointerException - if the bits array is
         null.public BitChromosome(byte[] bits)
BitChromosome from the given byte array.
 This is a shortcut for new BitChromosome(bits, 0, bits.length*8).bits - the byte array.public BitGene getGene()
ChromosomegetGene in interface Chromosome<BitGene>public boolean get()
public BitGene getGene(int index)
ChromosomegetGene in interface Chromosome<BitGene>index - The gene index.public boolean get(int index)
index - the gene indexIndexOutOfBoundsException - if the index is out of range
          (index < 1 || index >= length()).public ISeq<BitGene> toSeq()
ChromosometoSeq in interface Chromosome<BitGene>public int length()
Chromosomelength in interface Chromosome<BitGene>public int bitCount()
BitChromosome.BitChromosomepublic ListIterator<BitGene> listIterator()
public int intValue()
public long longValue()
public float floatValue()
floatValue in class Numberpublic double doubleValue()
doubleValue in class Numberpublic boolean isValid()
VerifiableisValid in interface Verifiablepublic BigInteger toBigInteger()
BigInteger value this BitChromosome represents.BigInteger value this BitChromosome represents.public int toByteArray(byte[] bytes)
Note: This representation is consistent with java.lang.BigInteger
           byte array representation and can be used for conversion
          between the two classes.
bytes - the bytes to hold the binary representation
               (two's-complement) of this large integer.IndexOutOfBoundsException - if bytes.length < (int)Math.ceil(length()/8.0)NullPointerException - it the give array is null.public byte[] toByteArray()
BitChromosome. The
         length of the array is (int)Math.ceil(length()/8.0).toByteArray(byte[])public BitSet toBitSet()
public IntStream ones()
public IntStream zeros()
public BitChromosome newInstance(ISeq<BitGene> genes)
ChromosomeChromosome of specific type
 and the given genes.newInstance in interface Chromosome<BitGene>genes - the genes of the new chromosome. The given genes array is
         not copied.Chromosome of the same type with the given genes.public BitChromosome newInstance()
FactorynewInstance in interface Factory<Chromosome<BitGene>>public String toCanonicalString()
of(CharSequence) constructor.public int compareTo(BitChromosome that)
compareTo in interface Comparable<BitChromosome>public BitChromosome invert()
public static BitChromosome of(int length, double p)
length - Length of the BitChromosome, number of bits.p - Probability of the TRUEs in the BitChromosome.BitChromosome with the given parameterNegativeArraySizeException - if the length is smaller
         than one.IllegalArgumentException - if p is not a valid probability.public static BitChromosome of(int length)
Chromosome are equally distributed.length - Length of the BitChromosome.BitChromosome with the given parameterNegativeArraySizeException - if the _length is smaller
         than one.public static BitChromosome of(BitSet bits, int length)
length - length of the BitChromosome.bits - the bit-set which initializes the chromosomeBitChromosome with the given parameterNegativeArraySizeException - if the length is smaller
         than one.NullPointerException - if the bitSet is
         null.public static BitChromosome of(BitSet bits)
bitSet.length() (BitSet.length()).bits - the bit-set which initializes the chromosomeBitChromosome with the given parameterNullPointerException - if the bitSet is
        null.public static BitChromosome of(BigInteger value)
BitChromosome from the given big integer value.value - the value of the created BitChromosomeBitChromosome with the given parameterNullPointerException - if the given value is null.public static BitChromosome of(CharSequence value)
BitChromosome from the given character sequence
 containing '0' and '1'; as created with the toCanonicalString()
 method.value - the input string.BitChromosome with the given parameterNullPointerException - if the value is null.IllegalArgumentException - if the length of the character sequence
         is zero or contains other characters than '0' or '1'.© 2007-2014 Franz Wilhelmstötter (2014-12-28 10:45)