Package jsl.observers
Class ReplicationDataCollector
- java.lang.Object
-
- jsl.observers.ModelElementObserver
-
- jsl.observers.ReplicationDataCollector
-
- All Implemented Interfaces:
ObserverIfc
,GetNameIfc
,IdentityIfc
public class ReplicationDataCollector extends ModelElementObserver
Collects and stores the replication average for each specified response or final value for each counter. Must be created prior to running the simulation for any data to be collected. The added responses or counters must already be part of the model. This is important. Only those responses or counters that already exist in the model hierarchy will be added automatically if you use that automatic add option. The collector collects data at the end of each replication. Running the simulation multiple times within the same execution will record over any data from a previous simulation run. Use the various methods to save the data if it is needed prior to running the simulation again. Or, remove the collector as an observer of the model prior to running subsequent simulations.
-
-
Field Summary
-
Fields inherited from class jsl.observers.ModelElementObserver
myName
-
-
Constructor Summary
Constructors Constructor Description ReplicationDataCollector(Model model)
Creates a ReplicationDataCollector and does not automatically add response or counters.ReplicationDataCollector(Model model, boolean addAll)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAllResponsesAndCounters()
Adds all response variables and counters that are in the model to the data collectorvoid
addCounterResponse(java.lang.String counterName)
void
addCounterResponse(Counter counter)
void
addResponse(java.lang.String responseName)
void
addResponse(ResponseVariable response)
protected void
afterReplication(ModelElement m, java.lang.Object arg)
protected void
beforeExperiment(ModelElement m, java.lang.Object arg)
boolean
contains(java.lang.String responseName)
double[][]
getAllReplicationData()
The responses are ordered in the same order as returned by getResponseNames() and are the columns, each row for a column is the replication average, row 0 is replication 1java.util.Map<java.lang.String,double[]>
getAllReplicationDataAsMap()
double[]
getFinalReplicationValues(Counter counter)
int
getNumberOfResponses()
int
getNumReplications()
double[]
getReplicationAverages(ResponseVariable responseVariable)
double[]
getReplicationData(java.lang.String responseName)
If the response name does not exist in the collector a zero length array is returned.java.util.List<java.lang.String>
getResponseNames()
java.lang.String
toString()
-
Methods inherited from class jsl.observers.ModelElementObserver
afterExperiment, beforeReplication, getId, getModelElement, getName, initialize, montecarlo, removedFromModel, replicationEnded, setModelElement, setName, timedUpdate, update, update, warmUp
-
-
-
-
Constructor Detail
-
ReplicationDataCollector
public ReplicationDataCollector(Model model)
Creates a ReplicationDataCollector and does not automatically add response or counters.- Parameters:
model
- the model that has the responses, must not be null
-
ReplicationDataCollector
public ReplicationDataCollector(Model model, boolean addAll)
- Parameters:
model
- the model that has the responses, must not be nulladdAll
- if true then ALL currently defined response variables and counters within the model will be automatically added to the data collector
-
-
Method Detail
-
addAllResponsesAndCounters
public final void addAllResponsesAndCounters()
Adds all response variables and counters that are in the model to the data collector
-
addResponse
public final void addResponse(java.lang.String responseName)
- Parameters:
responseName
- the name of the response within the model, must be in the model
-
addResponse
public final void addResponse(ResponseVariable response)
- Parameters:
response
- the response within the model to collect and store data for, must not be null
-
addCounterResponse
public final void addCounterResponse(java.lang.String counterName)
- Parameters:
counterName
- the name of the counter within the model, must be in the model
-
addCounterResponse
public final void addCounterResponse(Counter counter)
- Parameters:
counter
- the counter within the model to collect and store data for, must not be null
-
getNumberOfResponses
public final int getNumberOfResponses()
- Returns:
- the number of responses to collect
-
beforeExperiment
protected void beforeExperiment(ModelElement m, java.lang.Object arg)
- Overrides:
beforeExperiment
in classModelElementObserver
-
afterReplication
protected void afterReplication(ModelElement m, java.lang.Object arg)
- Overrides:
afterReplication
in classModelElementObserver
-
getResponseNames
public final java.util.List<java.lang.String> getResponseNames()
- Returns:
- a list holding the names of the responses and counters
-
contains
public final boolean contains(java.lang.String responseName)
- Parameters:
responseName
- the name of the response or counter in the model- Returns:
- true if the name is present, false otherwise
-
getReplicationData
public final double[] getReplicationData(java.lang.String responseName)
If the response name does not exist in the collector a zero length array is returned.- Parameters:
responseName
- the name of the response or counter, must be in the model- Returns:
- the replication averages for the named response
-
getReplicationAverages
public final double[] getReplicationAverages(ResponseVariable responseVariable)
- Parameters:
responseVariable
- the response variable, must not be null and must be in model- Returns:
- the replication averages for the named response
-
getFinalReplicationValues
public final double[] getFinalReplicationValues(Counter counter)
- Parameters:
counter
- the counter, must not be null and must be in model- Returns:
- the replication averages for the named response
-
getNumReplications
public final int getNumReplications()
- Returns:
- the number of replications collected so far
-
getAllReplicationData
public final double[][] getAllReplicationData()
The responses are ordered in the same order as returned by getResponseNames() and are the columns, each row for a column is the replication average, row 0 is replication 1- Returns:
- the replication averages for each response or value for counter for each replication
-
getAllReplicationDataAsMap
public final java.util.Map<java.lang.String,double[]> getAllReplicationDataAsMap()
- Returns:
- a map holding the response name as key and the end replication data as an array
-
toString
public java.lang.String toString()
- Overrides:
toString
in classModelElementObserver
-
-