K
- type of the key, a.k.a conditionerS
- type of the statisticpublic abstract class ConditionalStatisticBase<K,S extends ResultTaggable>
extends java.lang.Object
K
. Also the type of
the statistic is generic and specified by the generic type S
.
Three constructors are provided for different use cases.
ConditionalStatisticBase(SimNode, Class, StatisticCreator, Iterable, StatisticTagger)
is intended to be used with generic discrete keys. All possible keys have to
be provided at initialization time, so that the statistics can be created
before the simulation starts. Make sure that the Iterable
always
returns the keys in the same order (i.e. don't iterate over a HashSet
), otherwise the order of the statistics is undefined and import simulations
will fail.ConditionalStatisticBase(SimNode, Class, StatisticCreator, BucketUtility)
is intended to be used with continuous double keys, which are mapped to
discrete buckets by a BucketUtility
.ConditionalStatisticBase(SimNode, Class, StatisticCreator, int)
is a convenience constructor to be used with integer keys. Keys start at
zero. For other use cases with integer keys use the generic constructor.All constructors require the class of the key as parameter. This is used for type-checking at runtime, which is not possible with java generics alone.
In addition, the constructors require an instance of a
ConditionalStatisticBase.StatisticCreator
. This is a function which creates new instances of
the intended statistic class.
Modifier and Type | Class and Description |
---|---|
static interface |
ConditionalStatisticBase.StatisticCreator<S extends ResultTaggable> |
static interface |
ConditionalStatisticBase.StatisticTagger<K,S extends ResultTaggable> |
static interface |
ConditionalStatisticBase.ToIndexMapper<K> |
Modifier and Type | Field and Description |
---|---|
static ConditionalStatisticBase.StatisticTagger<java.lang.Object,ResultTaggable> |
TO_STRING_TAGGER |
Modifier | Constructor and Description |
---|---|
protected |
ConditionalStatisticBase(SimNode ownNode,
java.lang.Class<K> keyClass,
ConditionalStatisticBase.StatisticCreator<? extends S> statCreator,
BucketUtility bucketUtility)
for doubles (lin or log spaced mapping)
|
protected |
ConditionalStatisticBase(SimNode ownNode,
java.lang.Class<K> keyClass,
ConditionalStatisticBase.StatisticCreator<? extends S> statCreator,
int numBuckets)
for integers (0..numBuckets-1)
|
protected |
ConditionalStatisticBase(SimNode ownNode,
java.lang.Class<K> keyClass,
ConditionalStatisticBase.StatisticCreator<? extends S> statCreator,
java.lang.Iterable<? extends K> keys,
ConditionalStatisticBase.StatisticTagger<? super K,? super S> tagger)
for enumerable keys
|
Modifier and Type | Method and Description |
---|---|
protected S |
getStatistic(K key) |
void |
registerKey(K key)
register an additional key.
|
public static ConditionalStatisticBase.StatisticTagger<java.lang.Object,ResultTaggable> TO_STRING_TAGGER
protected ConditionalStatisticBase(SimNode ownNode, java.lang.Class<K> keyClass, ConditionalStatisticBase.StatisticCreator<? extends S> statCreator, java.lang.Iterable<? extends K> keys, ConditionalStatisticBase.StatisticTagger<? super K,? super S> tagger)
protected ConditionalStatisticBase(SimNode ownNode, java.lang.Class<K> keyClass, ConditionalStatisticBase.StatisticCreator<? extends S> statCreator, BucketUtility bucketUtility)
protected ConditionalStatisticBase(SimNode ownNode, java.lang.Class<K> keyClass, ConditionalStatisticBase.StatisticCreator<? extends S> statCreator, int numBuckets)
public void registerKey(K key)
Attention if keys are added at simulation runtime, it is not possible to import batch results, because the structure of the export file does not match the objects instantiated at import time.
key
- the new key