K
- the type of keyspublic class DoubleMapGenotype<K> extends DoubleGenotype implements MapGenotype<K,java.lang.Double>
The DoubleMapGenotype
is a DoubleGenotype
with the
MapGenotype
functionality.
Example problem: Select filling level of five bottles bottle1,
bottle2, bottle3, bottle4,
bottle5
Example usage:
Example instance: [bottle1=0.5035947840006195,bottle2=0.9693492473483428 ,bottle3=0.12786372316728167 ,bottle4=0.5299369900029843,bottle5=0.8055193291478467]DoubleMapGenotype<Bottle> genotype = new DoubleMapGenotype<Bottle>(Arrays.asList(bottle1, bottle2, bottle3, bottle4, bottle5)); genotype.init(new Random());
Modifier and Type | Field and Description |
---|---|
protected java.util.List<K> |
keys |
bounds
Constructor and Description |
---|
DoubleMapGenotype(java.util.List<K> keys,
Bounds<java.lang.Double> bounds)
Constructs a
DoubleMapGenotype . |
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(K key)
Returns
true if the key is contained. |
int |
getIndexOf(K key)
Returns the index of the key.
|
java.util.Collection<K> |
getKeys()
Return all keys.
|
java.lang.Double |
getValue(K key)
Returns the value for the specified key.
|
void |
init(java.util.Random random)
Initialize this genotype with random values based on the size of the
keys . |
void |
init(java.util.Random random,
int n)
Not supported.
|
<G extends Genotype> |
newInstance()
Constructs a new (empty) instance of this
Genotype . |
void |
setValue(K key,
java.lang.Double value)
Sets the value for the specified key.
|
java.lang.String |
toString() |
getLowerBound, getUpperBound
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 java.util.List<K> keys
public DoubleMapGenotype(java.util.List<K> keys, Bounds<java.lang.Double> bounds)
DoubleMapGenotype
.keys
- the list of keysbounds
- the lower and upper boundspublic void init(java.util.Random random)
keys
.random
- the random number generatorpublic void init(java.util.Random random, int n)
init(Random)
instead.init
in class DoubleGenotype
random
- the random number generatorn
- the number of elements in the resulting genotypeDoubleGenotype.init(java.util.Random, int)
public boolean containsKey(K key)
MapGenotype
true
if the key is contained.containsKey
in interface MapGenotype<K,java.lang.Double>
key
- the keytrue
if the key is containedpublic java.lang.Double getValue(K key)
MapGenotype
getValue
in interface MapGenotype<K,java.lang.Double>
key
- the keyMapGenotype.setValue(K, V)
public void setValue(K key, java.lang.Double value)
MapGenotype
setValue
in interface MapGenotype<K,java.lang.Double>
key
- the keyvalue
- the valueMapGenotype.getValue(K)
public <G extends Genotype> G newInstance()
Genotype
Genotype
.newInstance
in interface Genotype
newInstance
in class DoubleGenotype
G
- the type of genotype for an implicit castpublic java.lang.String toString()
toString
in class java.util.AbstractCollection<java.lang.Double>
public int getIndexOf(K key)
MapGenotype
getIndexOf
in interface MapGenotype<K,java.lang.Double>
key
- the keypublic java.util.Collection<K> getKeys()
MapGenotype
getKeys
in interface MapGenotype<K,java.lang.Double>