Class ResponseInterval

  • All Implemented Interfaces:
    ObservableIfc, GetNameIfc, IdentityIfc

    public class ResponseInterval
    extends SchedulingElement
    This class represents an interval of time over which statistical collection should be performed. An interval is specified by providing an interval start time and a duration. The duration must be finite and greater than zero. Simulation responses in the form of instances of ResponseVariable, TimeWeighted, and Counter can be added to the interval for observation. New responses are created and associated with each of the supplied responses. The new responses collect observations associated with the supplied responses only during the specified interval. In the case of response variables or time weighted variables, the average response during the interval is observed. In the case of counters, the total count during the interval is observed. If the interval is not associated with a ResponseSchedule, the interval may be repeated. In which case, the statistics are collected across the intervals. A repeated interval starts immediately after the previous duration. Note that for ResponseVariables that are observed, if there are no observations during the interval then the average response during the interval is undefined (and thus not observed). Therefore interval statistics for ResponseVariables are conditional on the occurrence of at least one observation. This is most relevant when the interval is repeated because intervals with no observations are not tabulated.
    • Field Detail

      • START_EVENT_PRIORITY

        public final int START_EVENT_PRIORITY
        Need to ensure that start event happens after schedule start and after warm up event
        See Also:
        Constant Field Values
      • END_EVENT_PRIORITY

        public final int END_EVENT_PRIORITY
        Need to ensure that end event happens before schedule end
        See Also:
        Constant Field Values
      • myStartTime

        protected double myStartTime
        The time that the interval should start
      • myRepeatFlag

        protected boolean myRepeatFlag
        The repeat flag controls whether or not the interval will repeat after its duration has elapsed. The default is false.
    • Constructor Detail

      • ResponseInterval

        public ResponseInterval​(ModelElement parent,
                                double duration,
                                java.lang.String label)
        Creates an interval response
        Parameters:
        parent - the parent model element
        duration - must be finite and strictly positive
        label - the label used to denote the interval, must not be null
    • Method Detail

      • setRepeatFlag

        public final void setRepeatFlag​(boolean flag)
        Sets whether or not the interval will repeat after it reaches it length
        Parameters:
        flag - true means repeats
      • getRepeatFlag

        public final boolean getRepeatFlag()
        Returns whether or not the interval will repeat after it completes its duration
        Returns:
        true means it repeats
      • setStartTime

        public final void setStartTime​(double startTime)
        Specifies when the interval is to start. If negative, then the interval will not be started
        Parameters:
        startTime - must not be infinite
      • getStartTime

        public final double getStartTime()
        Returns:
        the time to start the interval
      • setResponseSchedule

        protected final void setResponseSchedule​(ResponseSchedule schedule)
        Parameters:
        schedule - the response schedule that the interval is on
      • setDuration

        protected final void setDuration​(double duration)
        Parameters:
        duration - must be finite and positive
      • addResponseToInterval

        public ResponseVariable addResponseToInterval​(ResponseVariable theResponse)
        Adds a ResponseVariable to the interval for data collection over the interval. By default, interval empty statistics are not collected.
        Parameters:
        theResponse - the response to collect interval statistics on
        Returns:
        a ResponseVariable for the interval
      • addResponseToInterval

        public ResponseVariable addResponseToInterval​(ResponseVariable theResponse,
                                                      boolean intervalEmptyStatOption)
        Adds a ResponseVariable to the interval for data collection over the interval
        Parameters:
        theResponse - the response to collect interval statistics on
        intervalEmptyStatOption - true means include statistics on whether the interval is empty when observed
        Returns:
        a ResponseVariable for the interval
      • addCounterToInterval

        public ResponseVariable addCounterToInterval​(Counter theCounter)
        Adds a Counter to the interval for data collection over the interval
        Parameters:
        theCounter - the counter to collect interval statistics on
        Returns:
        a ResponseVariable for the interval
      • isScheduled

        public final boolean isScheduled()
        Returns:
        true if the interval has been scheduled
      • getTimeLastStarted

        public final double getTimeLastStarted()
        When the interval was last started
        Returns:
        When the interval was last started
      • getTimeLastEnded

        public final double getTimeLastEnded()
        When the interval was last ended
        Returns:
        When the interval was last ended
      • getDuration

        public final double getDuration()
        The duration (length) of the interval
        Returns:
        The duration (length) of the interval
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called
        Overrides:
        initialize in class ModelElement
      • afterReplication

        protected void afterReplication()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed after each replication. It is called after replicationEnded() has been called.
        Overrides:
        afterReplication in class ModelElement
      • scheduleInterval

        protected final void scheduleInterval​(double startTime)
        Schedules the interval to occur at current time + start time
        Parameters:
        startTime - the time to start the interval
      • cancelInterval

        public void cancelInterval()
        Cancels the scheduling of the interval. Any statistical collection will not occur.
      • toString

        public java.lang.String toString()
        Includes the model name, the id, the model element name, the parent name, and parent id
        Overrides:
        toString in class ModelElement
        Returns:
        a string representing the model element
      • asString

        public java.lang.String asString()
        Description copied from class: ModelElement
        Allows sub-classes to provide more detail than toString() to represent the ModelElement as a String
        Overrides:
        asString in class ModelElement
        Returns:
        a detailed String representation