Class MovingAverageTraceFunction

  • All Implemented Interfaces:
    EventListener, IDoubleSource, IUpdatableSource

    public class MovingAverageTraceFunction
    extends AbstractFunction
    implements IDoubleSource
    This class computes the average of the last values collected from a data source. The number of values used to compute the average value is specified in the constructor. The mean function return always double values, so it implements only the IDoubleSource interface.

    Title: JAS

    Description: Java Agent-based Simulation library

    Copyright (C) 2002 Michele Sonnessa

    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
    Author:
    Michele Sonnessa and Ross Richardson

    • Constructor Detail

      • MovingAverageTraceFunction

        public MovingAverageTraceFunction​(IDoubleSource source,
                                          java.lang.Enum<?> valueID,
                                          int windowSize)
        Create a basic statistic probe on a IDoubleSource object.
        Parameters:
        name - Name of the statistic object.
        source - The IDoubleSource object.
        valueID - The value identifier defined by source object.
      • MovingAverageTraceFunction

        public MovingAverageTraceFunction​(IFloatSource source,
                                          java.lang.Enum<?> valueID,
                                          int windowSize)
        Create a basic statistic probe on a IFloatSource object.
        Parameters:
        name - Name of the statistic object.
        source - The IFloatSource object.
        valueID - The value identifier defined by source object.
      • MovingAverageTraceFunction

        public MovingAverageTraceFunction​(ILongSource source,
                                          java.lang.Enum<?> valueID,
                                          int windowSize)
        Create a basic statistic probe on a ILongSource object.
        Parameters:
        name - Name of the statistic object.
        source - The ILongSource object.
        valueID - The value identifier defined by source object.
      • MovingAverageTraceFunction

        public MovingAverageTraceFunction​(IIntSource source,
                                          java.lang.Enum<?> valueID,
                                          int windowSize)
        Create a basic statistic probe on a IIntSource object.
        Parameters:
        name - Name of the statistic object.
        source - The IIntSource object.
        valueID - The value identifier defined by source object.
    • Method Detail

      • getDoubleValue

        public double getDoubleValue​(java.lang.Enum<?> valueID)
        Return the result of a given statistic.
        Specified by:
        getDoubleValue in interface IDoubleSource
        Parameters:
        valueID - One of the F_ constants representing available statistics.
        Returns:
        The computed value.
        Throws:
        java.lang.UnsupportedOperationException - If the given valueID is not supported.
      • onEvent

        public void onEvent​(java.lang.Enum<?> type)
        ISimEventListener callback function. It supports only jas.engine.Sim.EVENT_UPDATE event.
        Specified by:
        onEvent in interface EventListener
        Overrides:
        onEvent in class AbstractFunction
        Parameters:
        actionType - The action id. Only jas.engine.Sim.EVENT_UPDATE is supported.
        Throws:
        java.lang.UnsupportedOperationException - If actionType is not supported.