Class Counter

    • Field Detail

      • COUNTER_LIMIT_REACHED

        public static final int COUNTER_LIMIT_REACHED
        An "enum" for the counter state.
      • myInitialValue

        protected double myInitialValue
        The initial value of the counter
      • myValue

        protected double myValue
        The current value of the counter
      • myPrevValue

        protected double myPrevValue
        The previous value of the counter
      • myTimeOfChange

        protected double myTimeOfChange
        The time that the counter changed
      • myPrevTimeOfChange

        protected double myPrevTimeOfChange
        The previous time that the counter changed
      • myLimit

        protected double myLimit
        Sets a limit for the counter to fire an action
      • myCountLimitFlag

        protected boolean myCountLimitFlag
        Indicates that the limit has not yet been reached
      • myCounterActions

        protected java.util.Collection<CounterActionListenerIfc> myCounterActions
        A collection containing the counter actions for the counter
      • myCountAtPreviousTimedUpdate

        protected double myCountAtPreviousTimedUpdate
        Remembers the count at the previous timed update
      • myTotalDuringTimedUpdate

        protected double myTotalDuringTimedUpdate
        Remembers the total during a timed update
      • myAcrossRepStat

        protected Statistic myAcrossRepStat
        Statistic used to collect the across replication statistics on the final value of the counter for each replication
      • myAcrossIntervalResponse

        protected ResponseVariable myAcrossIntervalResponse
        A Counter can have a timed update action during a replication This response collects the average of the total count during each timed update interval. For example, a timed update interval of 1 hour can be set. Each hour this response will observe the count for that hour and collect averages across the timed update intervals
      • myLastUpdateTime

        protected double myLastUpdateTime
        Time of last update interval
      • myTimeOfWarmUp

        protected double myTimeOfWarmUp
        The time of the warm up if it occurs, 0.0 otherwise
    • Constructor Detail

      • Counter

        public Counter​(ModelElement parent)
        Parameters:
        parent -
      • Counter

        public Counter​(ModelElement parent,
                       long limit)
        Parameters:
        parent -
        limit -
      • Counter

        public Counter​(ModelElement parent,
                       long initialValue,
                       long limit)
        Parameters:
        parent -
        initialValue -
        limit -
      • Counter

        public Counter​(ModelElement parent,
                       java.lang.String name)
        Parameters:
        parent -
        name -
      • Counter

        public Counter​(ModelElement parent,
                       long limit,
                       java.lang.String name)
        Parameters:
        parent -
        limit -
        name -
      • Counter

        public Counter​(ModelElement parent,
                       long initialValue,
                       long limit,
                       java.lang.String name)
        Parameters:
        parent -
        initialValue -
        limit -
        name -
    • Method Detail

      • getCounterLimit

        public final double getCounterLimit()
        The limit used to trigger counter actions
        Returns:
      • setCountBasedStopLimit

        public final void setCountBasedStopLimit​(double countLimit)
        Sets the count limit for determining when the count based stopping should occur If countLimit is less than or equal to current count when set then the action will occur the next time that the variable changes Sets a limit and adds a stopping action. The executive will be stopped when the limit is reached.
        Parameters:
        countLimit - must be >=0, zero implies no count limit
      • setInitialValue

        protected final void setInitialValue​(long initialValue)
        Sets the initial value of the counter. It might start at a value greater than 1 prior to the simulation. This value will be used to initialize the counter prior to each replication
        Parameters:
        initialValue -
      • getInitialValue

        public final double getInitialValue()
        Returns the value used to initialize the counter prior to each replication
        Returns:
      • increment

        public final void increment()
        Increments the value of the variable by 1 at the current time.
      • increment

        public final void increment​(double value)
        Increments the value of the variable by the amount supplied. Throws an IllegalArgumentException if the value is negative.
        Parameters:
        value - The amount to increment by. Must be non-negative.
      • getValue

        public final double getValue()
        Description copied from interface: GetValueIfc
        This method simply returns the value.
        Specified by:
        getValue in interface GetValueIfc
        Returns:
        The value.
      • getPreviousValue

        public final double getPreviousValue()
        Description copied from interface: PreviousValueIfc
        Gets the previous number from the sequence of values
        Specified by:
        getPreviousValue in interface PreviousValueIfc
        Returns:
        a double representing the last value in the sequence
      • getPreviousTimeOfChange

        public double getPreviousTimeOfChange()
        The time that it changed before the getValue() was set
        Returns:
        the PrevTimeOfChange
      • getTimeOfChange

        public double getTimeOfChange()
        The time that the counter was set to getValue()
        Returns:
        the TimeOfChange
      • setCounterActionLimit

        public final void setCounterActionLimit​(long limit)
        Use to set the counter limit
        Parameters:
        limit - , must be > 0
      • getTotalDuringTimedUpdate

        public final double getTotalDuringTimedUpdate()
        The amount the counter changed during the timed update
        Returns:
        Returns the totalDuringTimedUpdate.
      • addStoppingAction

        public final void addStoppingAction()
        Description copied from interface: CounterActionIfc
        Tells the Counter to add an CounterActionIfc that will automatically stop the replication when the counter limit is reached.
        Specified by:
        addStoppingAction in interface CounterActionIfc
      • resetCounter

        public final void resetCounter​(long value)
        Resets the counter to the supplied value and clears the counter limit flag If timed updates are on, then count since the last timed update will be set to the supplied value. Notifies update observers of the state change
        Parameters:
        value - , must be < getCounterLimit() and >=0
      • resetCounter

        public final void resetCounter​(double value,
                                       boolean notifyUpdateObservers)
        Resets the counter to the supplied value and clears the counter limit flag If timed updates are on, then count since the last timed update will be set to the supplied value.
        Parameters:
        value - , must be < getCounterLimit() and >=0
        notifyUpdateObservers - If true, any update observers will be notified otherwise they will not be notified
      • setDefaultReportingOption

        public void setDefaultReportingOption​(boolean flag)
        Sets the default reporting option. True means the response will appear on default reports
        Specified by:
        setDefaultReportingOption in interface DefaultReportingOptionIfc
        Parameters:
        flag -
      • getDefaultReportingOption

        public boolean getDefaultReportingOption()
        Returns the default reporting option. True means that the response should appear on the default reports
        Specified by:
        getDefaultReportingOption in interface DefaultReportingOptionIfc
        Returns:
      • getAcrossReplicationStatistic

        public final StatisticAccessorIfc getAcrossReplicationStatistic()
        Gets a copy of the statistics that have been accumulated across all replications for this variable.
        Returns:
        A Statistic representing the across replication statistics.
      • getAcrossIntervalResponse

        public final ResponseVariable getAcrossIntervalResponse()
        If the time interval collection is turned on a ResponseVariable is created for capturing statistics across the intervals. This returns this value or null if time interval collection has not been turned on
        Returns:
        the response or null
      • turnOnTimeIntervalCollection

        public final void turnOnTimeIntervalCollection​(double interval)
        Turns on the collection of statistics across intervals of time, defined by the interval length
        Parameters:
        interval -
      • turnOnTimeIntervalTrace

        public final void turnOnTimeIntervalTrace()
        Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on
      • turnOnTimeIntervalTrace

        public final void turnOnTimeIntervalTrace​(boolean header)
        Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on
        Parameters:
        header - true means include the header
      • turnOnTimeIntervalTrace

        public final void turnOnTimeIntervalTrace​(java.lang.String fileName)
        Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on
        Parameters:
        fileName - the name of the file to write the trace
      • turnOnTimeIntervalTrace

        public final void turnOnTimeIntervalTrace​(java.lang.String fileName,
                                                  boolean header)
        Turns on tracing to a file of the time interval response if and only if time interval collection has been turned on
        Parameters:
        fileName - the name of the file to write the trace
        header - true means include the header
      • setValue

        protected void setValue​(double value)
        Sets the value of the counter, ensures a check against the limit Does not notify any update observers
        Parameters:
        value - The value to assign to the counter
      • beforeExperiment

        protected void beforeExperiment()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need logic to be performed prior to an experiment. The beforeExperiment method allows model elements to be setup prior to the first replication within an experiment. It is called once before any replications occur.
        Overrides:
        beforeExperiment in class ModelElement
      • initialize

        protected void initialize()
        Resets the counter and notifies any initialization observers
        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
      • warmUp

        protected void warmUp()
        Initialize the value to zero at the warm up time and notify warm up observers
        Overrides:
        warmUp in class ModelElement
      • timedUpdate

        protected void timedUpdate()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed at each timed update event during each replication. It is called for each timed update during each replication if the model element reacts to timed update actions.
        Overrides:
        timedUpdate in class ModelElement
      • notifyCounterLimitReachedObservers

        protected final void notifyCounterLimitReachedObservers()
        The method is used to notify observers that this model element has triggered its counter limit
      • notifyCounterActions

        protected final void notifyCounterActions()
      • notifyUpdateObservers

        protected void notifyUpdateObservers()
        The method is used to notify observers that this model element has been updated.
        Overrides:
        notifyUpdateObservers in class ModelElement
      • removedFromModel

        protected void removedFromModel()
        Description copied from class: Aggregatable
        This method should be overridden by subclasses that need actions performed when a model element is removed from a model after the replication has started.
        Overrides:
        removedFromModel in class Aggregatable