public class BitChromosome extends Number<BitChromosome> implements Chromosome<BitGene>, XMLSerializable
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
_genes
The boolean array which holds the
BitGenes. |
protected int |
_length
The length of the chromosomes (number of bits).
|
protected double |
_p
The one's probability of the randomly generated Chromosome.
|
| Constructor and Description |
|---|
BitChromosome(BitSet bits)
Constructing a new BitChromosome from a given BitSet.
|
BitChromosome(byte[] bits)
Create a new
BitChromosome from the given byte array. |
BitChromosome(CharSequence value)
Create a new
BitChromosome from the given character sequence
containing '0' and '1'; as created with the toCanonicalString()
method. |
BitChromosome(int length)
Constructing a new BitChromosome with the given _length.
|
BitChromosome(int length,
BitSet bits) |
BitChromosome(int length,
double p)
Construct a new BitChromosome with the given _length.
|
BitChromosome(LargeInteger value)
Create a new
BitChromosome from the given large integer value. |
| Modifier and Type | Method and Description |
|---|---|
int |
bitCount()
Returns the number of bits set to true in this
BitChromosome. |
int |
compareTo(BitChromosome that) |
BitChromosome |
copy() |
double |
doubleValue()
Return the double value this BitChromosome represents.
|
boolean |
equals(Object o) |
BitGene |
getGene()
Return the first gene of this chromosome.
|
BitGene |
getGene(int index)
Return the gene on the specified index.
|
int |
hashCode() |
BitChromosome |
invert()
Invert the ones and zeros of this bit chromosome.
|
boolean |
isLargerThan(BitChromosome that) |
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
Chromosome of specific type
and the given genes. |
BitChromosome |
opposite() |
BitChromosome |
plus(BitChromosome that) |
LargeInteger |
sqrt() |
BitChromosome |
times(BitChromosome that) |
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.
|
LargeInteger |
toLargeInteger()
Return the LargeInteger value this BitChromosome represents.
|
ISeq<BitGene> |
toSeq()
Return an unmodifiable sequence of the genes of this chromosome.
|
Text |
toText() |
byteValue, floatValue, intValue, isGreaterThan, isLessThan, minus, pow, shortValue, toStringprotected double _p
protected int _length
public BitChromosome(byte[] bits)
BitChromosome from the given byte array.bits - the byte array.public BitChromosome(int length, double p)
length - Length of the BitChromosome, number of bits.p - Probability of the TRUEs in the BitChromosome.NegativeArraySizeException - if the length is smaller
than one.IllegalArgumentException - if p is not a valid probability.public BitChromosome(int length)
Chromosome are equally distributed.length - Length of the BitChromosome.NegativeArraySizeException - if the _length is smaller
than one.public BitChromosome(int length, BitSet bits)
length - Length of the BitChromosome.bits - the bit-set which initializes the chromosomeNegativeArraySizeException - if the length is smaller
than one.NullPointerException - if the bitSet is
null.public BitChromosome(BitSet bits)
bitSet.length()
(@see BitSet#length).bits - the bit-set which initializes the chromosomeNullPointerException - if the bitSet is
null.public BitChromosome(LargeInteger value)
BitChromosome from the given large integer value.value - the value of the created BitChromosomeNullPointerException - if the given value is null.public BitChromosome(CharSequence value)
BitChromosome from the given character sequence
containing '0' and '1'; as created with the toCanonicalString()
method.value - the input string.NullPointerException - if the value is null.IllegalArgumentException - if the length of the character sequence
is zero or contains other characters than '0' or '1'.public BitGene getGene()
ChromosomegetGene in interface Chromosome<BitGene>public BitGene getGene(int index)
ChromosomegetGene in interface Chromosome<BitGene>index - The gene index.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 long longValue()
longValue in class Number<BitChromosome>public double doubleValue()
doubleValue in class Number<BitChromosome>public boolean isValid()
VerifiableisValid in interface Verifiablepublic LargeInteger toLargeInteger()
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 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()
BitChromosome(CharSequence) constructor.public int compareTo(BitChromosome that)
compareTo in interface Comparable<BitChromosome>compareTo in class Number<BitChromosome>public boolean isLargerThan(BitChromosome that)
isLargerThan in class Number<BitChromosome>public LargeInteger sqrt()
public BitChromosome plus(BitChromosome that)
plus in interface GroupAdditive<BitChromosome>public BitChromosome opposite()
opposite in interface GroupAdditive<BitChromosome>public BitChromosome invert()
public BitChromosome times(BitChromosome that)
times in interface Ring<BitChromosome>public int hashCode()
hashCode in class Number<BitChromosome>public boolean equals(Object o)
equals in class Number<BitChromosome>public Text toText()
toText in interface RealtimetoText in class Number<BitChromosome>public BitChromosome copy()
copy in interface ValueTypecopy in class Number<BitChromosome>© 2007-2013 Franz Wilhelmstötter (2013-12-18 20:17)