Class Experiment

  • All Implemented Interfaces:
    ExperimentGetIfc

    public class Experiment
    extends java.lang.Object
    implements ExperimentGetIfc
    This class provides the information for running a simulation experiment. An experiment is a specification for the number of replications, the warm up length, replication length, etc. for controlling the running of a simulation. The defaults include: - length of replication = Double.POSITIVE_INFINITY - length of warm up = 0.0 - replication initialization TRUE - The system state is re-initialized prior to each replication - reset start stream option FALSE - Do not reset the streams of the random variables to their starting points prior to running the replications within the experiment. This implies that if the experiment is re-run on the same model in the same code invocation that an independent set of replications will be made. - advance next substream option TRUE - The random variables in a within an experiment will start at the next sub-stream for each new replication - number of times to advance streams = 1 This indicates how many times that the streams should be advanced prior to running the experiment. This can be used to ensure simulations start with different streams - antithetic replication option is off by default
    • Constructor Detail

      • Experiment

        public Experiment()
        Constructs an experiment called "Experiment" with antithetic option off
      • Experiment

        public Experiment​(java.lang.String name)
        Constructs an experiment called "name"
        Parameters:
        name - The name of the experiment
    • Method Detail

      • getExperimentName

        public final java.lang.String getExperimentName()
        Gets the name.
        Specified by:
        getExperimentName in interface ExperimentGetIfc
        Returns:
        The name of object.
      • getExperimentId

        public final long getExperimentId()
        Returns the id for this object
        Specified by:
        getExperimentId in interface ExperimentGetIfc
        Returns:
        the identifier
      • setExperimentName

        public final void setExperimentName​(java.lang.String str)
        Sets the name
        Parameters:
        str - The name as a string.
      • getNumberOfStreamAdvancesPriorToRunning

        public final int getNumberOfStreamAdvancesPriorToRunning()
        Returns the number of times that the streams should be advanced prior to running the experiment
        Specified by:
        getNumberOfStreamAdvancesPriorToRunning in interface ExperimentGetIfc
        Returns:
        the number to advance
      • getNumberOfReplications

        public final int getNumberOfReplications()
        Returns the number of replications to run
        Specified by:
        getNumberOfReplications in interface ExperimentGetIfc
        Returns:
        the number as a double
      • setNumberOfReplications

        public final void setNumberOfReplications​(int numReps)
        Sets the desired number of replications for the experiment
        Parameters:
        numReps - must be > 0
      • setNumberOfReplications

        public final void setNumberOfReplications​(int numReps,
                                                  boolean antitheticOption)
        Sets the desired number of replications for the experiment
        Parameters:
        numReps - must be > 0, and even (divisible by 2) if antithetic option is true
        antitheticOption - controls whether antithetic replications occur
      • getCurrentReplicationNumber

        public final int getCurrentReplicationNumber()
        Returns the current number of replications completed
        Specified by:
        getCurrentReplicationNumber in interface ExperimentGetIfc
        Returns:
        the number as a double
      • hasMoreReplications

        public final boolean hasMoreReplications()
        Checks if the current number of replications that have been executed is less than the number of replications specified.
        Specified by:
        hasMoreReplications in interface ExperimentGetIfc
        Returns:
        true if more
      • getAntitheticOption

        public final boolean getAntitheticOption()
        Returns whether or not the antithetic option is turned on. True means that it has been turned on.
        Specified by:
        getAntitheticOption in interface ExperimentGetIfc
        Returns:
        true if on
      • getLengthOfReplication

        public final double getLengthOfReplication()
        Returns the length of the replication as a double
        Specified by:
        getLengthOfReplication in interface ExperimentGetIfc
        Returns:
        the length of the replication
      • setLengthOfReplication

        public final void setLengthOfReplication​(double lengthOfReplication)
        Sets the length of each replication for this experiment. The length of the replication must be > 0, if set
        Parameters:
        lengthOfReplication - the length of the replication
      • getLengthOfWarmUp

        public final double getLengthOfWarmUp()
        Gets the length of the warm up for each replication with this experiment
        Specified by:
        getLengthOfWarmUp in interface ExperimentGetIfc
        Returns:
        the the length of the warm up
      • setLengthOfWarmUp

        public final void setLengthOfWarmUp​(double lengthOfWarmUp)
        Sets the length of the warm up for each replication within this experiment The length of the warm up must be > 0.0, if set. If the warm up is set greater than the run length then there will be no warm up
        Parameters:
        lengthOfWarmUp - length of the warm up, must be >= 0.0
      • getReplicationInitializationOption

        public final boolean getReplicationInitializationOption()
        Returns the setting for whether or not each replication will be reinitialized prior to running.
        Specified by:
        getReplicationInitializationOption in interface ExperimentGetIfc
        Returns:
        true means that each replication will be initialized
      • setReplicationInitializationOption

        public final void setReplicationInitializationOption​(boolean repInitOption)
        Sets the replication initialization option for the experiment If set to true, each replication within the experiment will be initialized prior to running.
        Parameters:
        repInitOption - true means to initialize
      • getMaximumAllowedExecutionTimePerReplication

        public final long getMaximumAllowedExecutionTimePerReplication()
        Returns maximum (real) clock time allocated for the iterative process
        Specified by:
        getMaximumAllowedExecutionTimePerReplication in interface ExperimentGetIfc
        Returns:
        the number as long representing milliseconds
      • setMaximumExecutionTimePerReplication

        public final void setMaximumExecutionTimePerReplication​(long milliseconds)
        Set the maximum allotted (suggested) execution (real) clock for the entire iterative process. This is suggested because the execution time requirement is only checked after the completion of an individual step After it is discovered that cumulative time for executing the step has exceeded the maximum time, then the iterative process will be ended (perhaps) not completing other steps.
        Parameters:
        milliseconds - the maximum time
      • getAdvanceNextSubStreamOption

        public final boolean getAdvanceNextSubStreamOption()
        Gets the reset next substream option. The reset next sub stream option This option indicates whether or not the random variables used during the replication within the experiment will be reset to their next substream after running each replication. The default is TRUE. This ensures that the random variables will jump to the next substream within their current stream at the end of a replication. This will cause the random variables in each subsequent replication to start in the same substream in the underlying random number streams if the replication is repeatedly used and the ResetStartStreamOption is set to false (which is the default). Otherwise, this option really has no effect if there is only 1 replication in an experiment. and then jump to the next substream (if this option is on). Having ResetNextSubStreamOption true assists in synchronizing the random number draws from one replication to another aiding in the implementation of common random numbers. Each replication within the same experiment is still independent.
        Specified by:
        getAdvanceNextSubStreamOption in interface ExperimentGetIfc
        Returns:
        true means the option is on
      • setAdvanceNextSubStreamOption

        public final void setAdvanceNextSubStreamOption​(boolean b)
        Sets the reset next substream option. The reset next sub stream option This option indicates whether or not the random variables used during the replication within the experiment will be reset to their next substream after running each replication. The default is TRUE. This ensures that the random variables will jump to the next substream within their current stream at the end of a replication. This will cause the random variables in each subsequent replication to start in the same substream in the underlying random number streams if the replication is repeatedly used and the ResetStartStreamOption is set to false (which is the default). Otherwise, this option really has no effect if there is only 1 replication in an experiment. and then jump to the next substream (if this option is on). Having ResetNextSubStreamOption true assists in synchronizing the random number draws from one replication to another aiding in the implementation of common random numbers. Each replication within the same experiment is still independent.
        Parameters:
        b - true means option is on
      • getResetStartStreamOption

        public final boolean getResetStartStreamOption()
        Gets the reset start stream option. The reset start stream option This option indicates whether or not the random variables used during the experiment will be reset to their starting stream prior to running the first replication. The default is FALSE. This ensures that the random variable's streams WILL NOT be reset prior to running the experiment. This will cause different experiments or the same experiment run multiple times that use the same random variables (via the same model) to continue within their current stream. Therefore the experiments will be independent when invoked within the same program execution. To get common random number (CRN), run the experiments in different program executions OR set this option to true prior to running the experiment again within the same program invocation.
        Specified by:
        getResetStartStreamOption in interface ExperimentGetIfc
        Returns:
        true means the option is on
      • setResetStartStreamOption

        public final void setResetStartStreamOption​(boolean b)
        Sets the reset start stream option. The reset start stream option This option indicates whether or not the random variables used during the experiment will be reset to their starting stream prior to running the first replication. The default is FALSE. This ensures that the random variable's streams WILL NOT be reset prior to running the experiment. This will cause different experiments or the same experiment run multiple times that use the same random variables (via the same model) to continue within their current stream. Therefore the experiments will be independent when invoked within the same program execution. To get common random number (CRN), run the experiments in different program executions OR set this option to true prior to running the experiment again within the same program invocation.
        Parameters:
        b - true if reset desired
      • getGarbageCollectAfterReplicationFlag

        public boolean getGarbageCollectAfterReplicationFlag()
        Indicates whether or not System.gc() should be called after each replication
        Specified by:
        getGarbageCollectAfterReplicationFlag in interface ExperimentGetIfc
        Returns:
        true if on
      • setGarbageCollectAfterReplicationFlag

        public void setGarbageCollectAfterReplicationFlag​(boolean flag)
        Indicates whether or not System.gc() should be called after each replication
        Parameters:
        flag - true if on
      • setExperiment

        public void setExperiment​(Experiment e)
        Sets all attributes of this experiment to the same values as the supplied experiment (except for getId()).
        Parameters:
        e - the experiment to copy
      • newInstance

        public Experiment newInstance()
        Returns a new Experiment based on the supplied experiment. Essentially a clone, except for the getId()
        Returns:
        a new Experiment
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • resetCurrentReplicationNumber

        protected final void resetCurrentReplicationNumber()
        Resets the current replication number to zero
      • incrementCurrentReplicationNumber

        protected final void incrementCurrentReplicationNumber()
        Increments the number of replications that has been executed