com.speckled.specksim.statistics
Class StatisticsModule

java.lang.Object
  extended by com.speckled.specksim.statistics.StatisticsModule
Direct Known Subclasses:
CommunicationsModule, LeaderStatisticModule, NeighbourhoodModule

public abstract class StatisticsModule
extends java.lang.Object

The abstract superclass for statistics modules. Implementors need only concern themselves with generating and naming the statistics.

Author:
ryanm

Field Summary
static int DEFAULT_HISTORY
          The default history length
 
Constructor Summary
StatisticsModule()
           
 
Method Summary
protected abstract  float[] generateStatistics(StateSink state)
          Generate a statistics set for the supplied state.
 float[][] getHistory()
          Gets the history of this module
 int getHistoryLength()
          Gets the history length of this module
 float[] getHistoryTimes()
          Gets the simulator times at which each historical record was generated.
abstract  java.lang.String getName()
          Gets a name for this module
 java.lang.String[] getStatisticDescriptions()
          Gets descriptions for each of the statistics generated by this module
 java.lang.String[] getStatisticNames()
          Gets the names of the statistics in this module
 float[] getStatistics()
          Gets the statistics
protected  boolean isIncluded(int index)
          Subclasses should use this method, instead of state.isIncluded( index ).
 void setHistoryLength(int length)
          Sets the history length of this StatisticModule
protected  java.lang.String[] statisticDescriptions()
          Override this method to return an array of descriptive Strings for the statistics calculated by this StatisticsModule.
protected abstract  java.lang.String[] statisticNames()
          Get the names of the statistics that will be generated by this module
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HISTORY

public static final int DEFAULT_HISTORY
The default history length

See Also:
Constant Field Values
Constructor Detail

StatisticsModule

public StatisticsModule()
Method Detail

getStatisticNames

public final java.lang.String[] getStatisticNames()
Gets the names of the statistics in this module

Returns:
An array of statistic names

getStatisticDescriptions

public final java.lang.String[] getStatisticDescriptions()
Gets descriptions for each of the statistics generated by this module

Returns:
An array containing descriptive Strings for each of the statistics, or null.

getStatistics

public final float[] getStatistics()
Gets the statistics

Returns:
The statistics array

getHistory

public final float[][] getHistory()
Gets the history of this module

Returns:
A two dimensional array, the first dimension is the time index, the second is the statistic index

getHistoryTimes

public final float[] getHistoryTimes()
Gets the simulator times at which each historical record was generated.

Returns:
An array of the simulator times. eg: the record in getHistory()[ i ] was generated at simulator time getHistoryTimes[ i ]

setHistoryLength

public final void setHistoryLength(int length)
Sets the history length of this StatisticModule

Parameters:
length - The new length of the history

getHistoryLength

public final int getHistoryLength()
Gets the history length of this module

Returns:
The history length

isIncluded

protected final boolean isIncluded(int index)
Subclasses should use this method, instead of state.isIncluded( index ). This allows the automatic generation of filtered and unfiltered results

Parameters:
index - The index of the speck element to query
Returns:
true if the element should be included in statistic generation, false otherwise

getName

public abstract java.lang.String getName()
Gets a name for this module

Returns:
A name for this module

generateStatistics

protected abstract float[] generateStatistics(StateSink state)
Generate a statistics set for the supplied state. This may return null if the state is not suitable for this module. For example, it would be difficult to generate location-based statistics for a field of non-LocationAware Specks.

Parameters:
state - The Simulator state on which to operate
Returns:
A float array of the results, or null if the statistic cannot be generated for the supplied state

statisticNames

protected abstract java.lang.String[] statisticNames()
Get the names of the statistics that will be generated by this module

Returns:
A String of descriptive names for the returned statistics

statisticDescriptions

protected java.lang.String[] statisticDescriptions()
Override this method to return an array of descriptive Strings for the statistics calculated by this StatisticsModule.

Returns:
An array of descriptions for the statistics