public class IntegerChromosome extends AbstractChromosome<G> implements NumericChromosome<Integer,IntegerGene>, Serializable
IntegerGene
,
Serialized Form_genes, _valid
Modifier | Constructor and Description |
---|---|
protected |
IntegerChromosome(ISeq<IntegerGene> genes,
IntRange lengthRange)
Create a new chromosome from the given
genes and the allowed
length range of the chromosome. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
A |
getMax()
Return the maximum value of this
BoundedChromosome . |
A |
getMin()
Return the minimum value of this
BoundedChromosome . |
int |
hashCode() |
IntStream |
intStream()
Returns a sequential stream of the alleles with this chromosome as its
source.
|
IntRange |
lengthRange()
Return the allowed length range of the chromosome.
|
IntegerChromosome |
newInstance()
Create a new instance of type T.
|
IntegerChromosome |
newInstance(ISeq<IntegerGene> genes)
A factory method which creates a new
Chromosome of specific type
and the given genes . |
static IntegerChromosome |
of(IntegerGene... genes)
Create a new
IntegerChromosome with the given genes. |
static IntegerChromosome |
of(int min,
int max)
Create a new random
IntegerChromosome of length one. |
static IntegerChromosome |
of(int min,
int max,
int length)
Create a new random
IntegerChromosome . |
static IntegerChromosome |
of(int min,
int max,
IntRange lengthRange)
Create a new random chromosome.
|
static IntegerChromosome |
of(IntRange range)
Create a new random
IntegerChromosome of length one. |
static IntegerChromosome |
of(IntRange range,
int length)
Create a new random
IntegerChromosome . |
static IntegerChromosome |
of(IntRange range,
IntRange lengthRange)
Create a new random chromosome.
|
static IntegerChromosome |
of(Iterable<IntegerGene> genes)
Create a new
IntegerChromosome with the given genes. |
int[] |
toArray()
Returns an int array containing all of the elements in this chromosome
in proper sequence.
|
int[] |
toArray(int[] array)
Returns an int array containing all of the elements in this chromosome
in proper sequence.
|
getGene, isValid, iterator, length, toSeq, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
byteValue, byteValue, doubleValue, doubleValue, floatValue, floatValue, intValue, intValue, longValue, longValue, shortValue, shortValue
getMax, getMin
as, getGene, getGene, iterator, length, stream, toSeq
isValid
forEach, spliterator
protected IntegerChromosome(ISeq<IntegerGene> genes, IntRange lengthRange)
genes
and the allowed
length range of the chromosome.genes
- the genes that form the chromosome.lengthRange
- the allowed length range of the chromosomeNullPointerException
- 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.public IntegerChromosome newInstance(ISeq<IntegerGene> genes)
Chromosome
Chromosome
of specific type
and the given genes
.newInstance
in interface Chromosome<IntegerGene>
genes
- the genes of the new chromosome. The given genes array is
not copied.Chromosome
of the same type with the given genes.public IntegerChromosome newInstance()
Factory
newInstance
in interface Factory<Chromosome<IntegerGene>>
public IntStream intStream()
public int[] toArray(int[] array)
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.NullPointerException
- if the given array
is null
public int[] toArray()
public static IntegerChromosome of(IntegerGene... genes)
IntegerChromosome
with the given genes.genes
- the genes of the chromosome.IllegalArgumentException
- if the length of the genes array is
empty or the given genes
doesn't have the same range.public static IntegerChromosome of(Iterable<IntegerGene> genes)
IntegerChromosome
with the given genes.genes
- the genes of the chromosome.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.public static IntegerChromosome of(int min, int max, IntRange lengthRange)
min
- the min value of the IntegerGene
s (inclusively).max
- the max value of the IntegerGene
s (inclusively).lengthRange
- the allowed length range of the chromosome.IntegerChromosome
with the given parameterIllegalArgumentException
- 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
public static IntegerChromosome of(int min, int max, int length)
IntegerChromosome
.min
- the min value of the IntegerGene
s (inclusively).max
- the max value of the IntegerGene
s (inclusively).length
- the length of the chromosome.IntegerChromosome
IllegalArgumentException
- if the length is smaller than onepublic static IntegerChromosome of(IntRange range, IntRange lengthRange)
range
- the integer range of the chromosome.lengthRange
- the allowed length range of the chromosome.IntegerChromosome
with the given parameterIllegalArgumentException
- 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
public static IntegerChromosome of(IntRange range, int length)
IntegerChromosome
.range
- the integer range of the chromosome.length
- the length of the chromosome.IntegerChromosome
NullPointerException
- if the given range
is null
IllegalArgumentException
- if the length is smaller than onepublic static IntegerChromosome of(int min, int max)
IntegerChromosome
of length one.min
- the minimal value of this chromosome (inclusively).max
- the maximal value of this chromosome (inclusively).IntegerChromosome
of length onepublic static IntegerChromosome of(IntRange range)
IntegerChromosome
of length one.range
- the integer range of the chromosome.IntegerChromosome
of length oneNullPointerException
- if the given range
is null
public A getMin()
BoundedChromosome
BoundedChromosome
.getMin
in interface BoundedChromosome<A extends Comparable<? super A>,G extends BoundedGene<A,G>>
BoundedChromosome
.public A getMax()
BoundedChromosome
BoundedChromosome
.getMax
in interface BoundedChromosome<A extends Comparable<? super A>,G extends BoundedGene<A,G>>
BoundedChromosome
.public int hashCode()
public IntRange lengthRange()
© 2007-2019 Franz Wilhelmstötter (2019-11-18 20:30)