Package microsim.statistics.functions
Class MovingAverageTraceFunction
java.lang.Object
microsim.statistics.functions.AbstractFunction
microsim.statistics.functions.MovingAverageTraceFunction
- All Implemented Interfaces:
EventListener,IDoubleSource,IUpdatableSource
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, Ross Richardson
-
Nested Class Summary
Nested classes/interfaces inherited from interface microsim.statistics.IDoubleSource
IDoubleSource.Variables -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected IDoubleSourceprotected IFloatSourceprotected IIntSourceprotected intprotected ILongSourceprotected intprotected static final intprotected static final intprotected static final intprotected static final intprotected intprotected Enum<?>protected double[]Fields inherited from class microsim.statistics.functions.AbstractFunction
timeChecker -
Constructor Summary
ConstructorsConstructorDescriptionMovingAverageTraceFunction(IDoubleSource source, Enum<?> valueID, int windowSize) Create a basic statistic probe on a IDoubleSource object.MovingAverageTraceFunction(IFloatSource source, Enum<?> valueID, int windowSize) Create a basic statistic probe on a IFloatSource object.MovingAverageTraceFunction(IIntSource source, Enum<?> valueID, int windowSize) Create a basic statistic probe on a IIntSource object.MovingAverageTraceFunction(ILongSource source, Enum<?> valueID, int windowSize) Create a basic statistic probe on a ILongSource object. -
Method Summary
Modifier and TypeMethodDescriptionvoidCollect a value from the source.doublegetDoubleValue(Enum<?> valueID) Return the result of a given statistic.voidISimEventListener callback function.Methods inherited from class microsim.statistics.functions.AbstractFunction
isCheckingTime, setCheckingTime, updateSource
-
Field Details
-
TYPE_DBL
protected static final int TYPE_DBL- See Also:
-
TYPE_FLT
protected static final int TYPE_FLT- See Also:
-
TYPE_INT
protected static final int TYPE_INT- See Also:
-
TYPE_LNG
protected static final int TYPE_LNG- See Also:
-
dblSource
-
fltSource
-
intSource
-
lngSource
-
type
protected int type -
valueID
-
len
protected int len -
values
protected double[] values -
average
protected double average -
valueCount
protected int valueCount
-
-
Constructor Details
-
MovingAverageTraceFunction
Create a basic statistic probe on a IDoubleSource object.- Parameters:
source- The IDoubleSource object.valueID- The value identifier defined by source object.
-
MovingAverageTraceFunction
Create a basic statistic probe on a IFloatSource object.- Parameters:
source- The IFloatSource object.valueID- The value identifier defined by source object.
-
MovingAverageTraceFunction
Create a basic statistic probe on a ILongSource object.- Parameters:
source- The ILongSource object.valueID- The value identifier defined by source object.
-
MovingAverageTraceFunction
Create a basic statistic probe on a IIntSource object.- Parameters:
source- The IIntSource object.valueID- The value identifier defined by source object.
-
-
Method Details
-
applyFunction
public void applyFunction()Collect a value from the source.- Specified by:
applyFunctionin classAbstractFunction
-
getDoubleValue
Return the result of a given statistic.- Specified by:
getDoubleValuein interfaceIDoubleSource- Parameters:
valueID- One of the F_ constants representing available statistics.- Returns:
- The computed value.
- Throws:
UnsupportedOperationException- If the given valueID is not supported.
-
onEvent
ISimEventListener callback function. It supports only jas.engine.Sim.EVENT_UPDATE event.- Specified by:
onEventin interfaceEventListener- Overrides:
onEventin classAbstractFunction- Throws:
UnsupportedOperationException- If actionType is not supported.
-