Package jsl.observers

Class 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.
    • 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 null
        addAll - 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
      • 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