public class IntegerGenotype extends java.util.ArrayList<java.lang.Integer> implements ListGenotype<java.lang.Integer>
The IntegerGenotype
is a Genotype
that consists of
Integer
values.
Example problem: Select the outcome of throwing five dice
Example usage:
Example instance: [3, 5, 6, 1, 3]IntegerGenotype genotype = new IntegerGenotype(1, 6); genotype.init(new Random(), 5);
Modifier and Type | Field and Description |
---|---|
protected Bounds<java.lang.Integer> |
bounds |
Constructor and Description |
---|
IntegerGenotype(Bounds<java.lang.Integer> bounds)
Constructs a
IntegerGenotype with the given Bounds . |
IntegerGenotype(int lowerBound,
int upperBound)
Constructs a
IntegerGenotype with a specified lower and upper
bound for all values. |
Modifier and Type | Method and Description |
---|---|
int |
getLowerBound(int index)
Returns the lower bound for the
i -th element. |
int |
getUpperBound(int index)
Returns the upper bound for the
i -th element. |
void |
init(java.util.Random random,
int n)
Initialize this genotype with
n random values. |
<G extends Genotype> |
newInstance()
Constructs a new (empty) instance of this
Genotype . |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
finalize, getClass, notify, notifyAll, wait, wait, wait
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray
protected final Bounds<java.lang.Integer> bounds
public IntegerGenotype(int lowerBound, int upperBound)
IntegerGenotype
with a specified lower and upper
bound for all values.lowerBound
- the lower boundupperBound
- the upper boundpublic IntegerGenotype(Bounds<java.lang.Integer> bounds)
IntegerGenotype
with the given Bounds
.bounds
- the boundspublic int getLowerBound(int index)
i
-th element.index
- the i
-th elementi
-th elementpublic int getUpperBound(int index)
i
-th element.index
- the i
-th elementi
-th elementpublic <G extends Genotype> G newInstance()
Genotype
Genotype
.newInstance
in interface Genotype
G
- the type of genotype for an implicit castpublic void init(java.util.Random random, int n)
n
random values.random
- the random number generatorn
- the number of elements in the resulting genotype