Package microsim.statistics.functions
Class MultiTraceFunction
java.lang.Object
microsim.statistics.functions.MultiTraceFunction
- All Implemented Interfaces:
EventListener
,DoubleSource
,UpdatableSource
- Direct Known Subclasses:
MultiTraceFunction.Double
,MultiTraceFunction.Integer
,MultiTraceFunction.Long
public abstract class MultiTraceFunction
extends Object
implements DoubleSource, UpdatableSource, EventListener
A MixFunction object is to collect data over time, computing some statistics on the fly, without storing the data in
memory. It is particularly useful when the user need to compute basic statistics on data sources, without affecting
the memory occupancy. The memoryless series computes automatically the statistics using accumulation variables and
counters.
This statistic computer should be used when possible, particularly when the simulation model has to run for a long time, condition which implies the growth of the memory occupancy. Moreover, the Memoryless Series objects are much faster than the Series one, because they pre-compute the statistics operation step by step. Trying to compute a mean of a Series object, force the Mean function to sum all the values, every time series is updated.
This statistic computer should be used when possible, particularly when the simulation model has to run for a long time, condition which implies the growth of the memory occupancy. Moreover, the Memoryless Series objects are much faster than the Series one, because they pre-compute the statistics operation step by step. Trying to compute a mean of a Series object, force the Mean function to sum all the values, every time series is updated.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
An implementation of the Memoryless Series class, which manages double type data sources.static class
An implementation of the Memoryless Series class, which manages integer type data sources.static class
An implementation of the Memoryless Series class, which manages long type data sources.static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getCount()
double
getDoubleValue
(@NonNull Enum<?> valueID) Computes one of the available statistical functions on the collected data.abstract double
getMean()
abstract double
void
EventListener
callback function.void
Collects a value from the source.
-
Field Details
-
count
protected int count
-
-
Constructor Details
-
MultiTraceFunction
public MultiTraceFunction()
-
-
Method Details
-
updateSource
public void updateSource()Collects a value from the source.- Specified by:
updateSource
in interfaceUpdatableSource
-
getMean
public abstract double getMean() -
getVariance
public abstract double getVariance() -
getCount
public int getCount() -
onEvent
EventListener
callback function. It supports onlyCommonEventType.UPDATE
event.- Specified by:
onEvent
in interfaceEventListener
- Parameters:
type
- The action id. OnlyCommonEventType.UPDATE
is supported.- Throws:
SimulationRuntimeException
- If actionType is not supported.NullPointerException
- whentype
isnull
.
-
getDoubleValue
Computes one of the available statistical functions on the collected data.- Specified by:
getDoubleValue
in interfaceDoubleSource
- Parameters:
valueID
- A unique identifier for a variable.- Returns:
- The current double value of the required variable.
- Throws:
NullPointerException
- whenvalueID
isnull
.UnsupportedOperationException
- whenvalueID
is of not supported type.
-