Class Experiment<T extends Number & Comparable<T>,​S extends SimulatorInterface<T>>

    • Field Detail

      • START_EXPERIMENT_EVENT

        public static final EventType START_EXPERIMENT_EVENT
        START_EXPERIMENT_EVENT is fired when the experiment starts.
      • END_EXPERIMENT_EVENT

        public static final EventType END_EXPERIMENT_EVENT
        END_EXPERIMENT_EVENT is fired when the experiment is ended.
    • Constructor Detail

      • Experiment

        public Experiment​(String id,
                          S simulator,
                          DSOLModel<T,​? extends S> model,
                          T startTime,
                          T warmupPeriod,
                          T runLength,
                          int numberOfReplications)
        Construct a new Experiment.
        Parameters:
        id - String; the id of the experiment
        simulator - S; the simulator
        model - DSOLModel<T, S>; the model to experiment with
        startTime - T; the start time of the simulation.
        warmupPeriod - R; the warmup period, included in the runlength (!)
        runLength - R; the total length of the run, including the warm-up period.
        numberOfReplications - int; the number of replications to execute
        Throws:
        NullPointerException - when id, startTime, warmupPeriod or runLength is null
        IllegalArgumentException - when warmup period is negative, or run length is zero or negative, or when the warmup time is longer than or equal to the runlength, or the number of replications is zero or negative
      • Experiment

        public Experiment​(S simulator,
                          DSOLModel<T,​? extends S> model,
                          ExperimentRunControl<T> runControl)
        Construct a new Experiment, using a RunControl to store the run control information.
        Parameters:
        simulator - S; the simulator
        model - DSOLModel<T, S>; the model to experiment with
        runControl - ExperimentRunControl; the run control information
        Throws:
        NullPointerException - when id, startTime, warmupPeriod or runLength is null
    • Method Detail

      • getRunControl

        public RunControl<T> getRunControl()
        Return the RunControl object that contains the treatment information.
        Specified by:
        getRunControl in interface Treatment<T extends Number & Comparable<T>>
        Returns:
        RunControl; the RunControl object that contains the treatment information
      • getSimulator

        public S getSimulator()
        Return the simulator.
        Returns:
        S; the simulator
      • getModel

        public DSOLModel<T,​? extends S> getModel()
        Return the model.
        Returns:
        DSOLModel; the model
      • getStartedReplications

        public List<? extends ExperimentReplication<T,​S>> getStartedReplications()
        Return the list of started replications. Not all replications might have finished yet.
        Returns:
        List<Replication<T, S>>; the list of started replications
      • start

        public void start()
                   throws RemoteException
        Start the extire experiment on a simulator, and execute ehe replications one by one.
        Throws:
        RemoteException - on network error if started by RMI
        IllegalArgumentException - when there are no more replications to run, or when the simulator is already running
      • startNextReplication

        protected void startNextReplication()
                                     throws RemoteException
        Start the next replication from the list of replications, or fire END_EXPERIMENT_EVENT when there are no more non-executed replications.
        Throws:
        RemoteException - on network error if started by RMI
      • endExperiment

        protected void endExperiment()
        Fire the end Experiment event.
      • makeExperimentReplication

        protected ExperimentReplication<T,​S> makeExperimentReplication()
        Create a new replication for an experiment. This method can be overridden in the inner classes.
        Returns:
        ExperimentReplication; a new replication for an experiment
      • reset

        public void reset()
        Reset the experiment so it can be run again.
      • endReplication

        protected void endReplication()
        Create or update summary statistics for the experiment based on the statistics of the just completed replication.
      • addSummaryStatistic

        protected void addSummaryStatistic​(String statistic,
                                           String field,
                                           double value)
        Tally a value in a summary statistic over multiple replications.
        Parameters:
        statistic - String; the name of the statistic
        field - String; the name of the field for the summary statistic
        value - double; the value to tally by the summary statistic
      • getSummaryStatistics

        public SortedMap<String,​SortedMap<String,​Tally>> getSummaryStatistics()
        The summary statistics over multiple replications. The table maps the name of the statistic to a map of fields to tallies that contain the statistics of the tallied values. Suppose we run a model with 10 replications, which has a tally named "waiting time". Then there will be an entry in this table called "waiting time" as well. This "waiting time" maps to several sub-maps, such as "N", "Population mean", "Population variance", "Min", "Max", etc. Each of these is a Tally for which the final values of the replications for that value have been tallied. The "Population Mean" for "waiting time" in this example therefore contains the average of the 10 average waiting times that have been alculated in the 10 replications.
        Returns:
        summaryStatistics SortedMap<String, SortedMap<String, Tally>>; the summary statistics
      • getCurrentReplication

        public int getCurrentReplication()
        Return the current (running or finished) replication.
        Returns:
        int; the current replication (still running or finished in case of last replication)
      • removeFromContext

        public void removeFromContext()
        Remove the entire experiment tree from the context.
      • getStreamUpdater

        public StreamUpdater getStreamUpdater()
        Return the current stream updater.
        Returns:
        streamUpdater StreamUpdater; the current stream updater
      • setStreamUpdater

        public void setStreamUpdater​(StreamUpdater streamUpdater)
        Set a new StreamUpdater to update the random seeds between replications.
        Parameters:
        streamUpdater - StreamUpdater; the new stream updater
      • getCurrentReplicationNumber

        public int getCurrentReplicationNumber()
        Return the current replication number, which is -1 if the experiment has not yet started.
        Returns:
        int; the current replication number
      • getNumberOfReplications

        public int getNumberOfReplications()
        Return the total number of replications to execute.
        Returns:
        int; the total number of replications to execute
      • isRunning

        public boolean isRunning()
        Return whether the experiment is running or not.
        Returns:
        boolean; whether the experiment is running or not