peersim.vector
Class SingleValueObserver

java.lang.Object
  extended by peersim.vector.SingleValueObserver
All Implemented Interfaces:
Control

public class SingleValueObserver
extends java.lang.Object
implements Control

Print statistics over a vector. The vector is defined by a protocol, specified by "protocol", that has to implement SingleValue. Single nodes may avoid to be counted in the statistics by throwing an UnsupportedOperationException in method SingleValue.getValue(). Statistics printed are: min, max, number of samples, average, variance, number of minimal instances, number of maximal instances (using IncrementalStats.toString()).

See Also:
IncrementalStats

Parameter Summary
accuracy
          The parameter used to determine the accuracy (standard deviation) before stopping the simulation.
protocol
          The protocol to operate on.
 
Constructor Summary
SingleValueObserver(java.lang.String name)
          Standard constructor that reads the configuration parameters.
 
Method Summary
 boolean execute()
          Print statistics over a vector.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Parameter Detail

accuracy

The parameter used to determine the accuracy (standard deviation) before stopping the simulation. If not defined, a negative value is used which makes sure the observer does not stop the simulation.

See Also:
execute()

protocol

The protocol to operate on.

Constructor Detail

SingleValueObserver

public SingleValueObserver(java.lang.String name)
Standard constructor that reads the configuration parameters. Invoked by the simulation engine.

Parameters:
name - the configuration prefix for this class
Method Detail

execute

public boolean execute()
Print statistics over a vector. The vector is defined by a protocol, specified by "protocol", that has to implement SingleValue. Statistics printed are: min, max, number of samples, average, variance, number of minimal instances, number of maximal instances (using IncrementalStats.toString()).

Specified by:
execute in interface Control
Returns:
true if the standard deviation is below the value of "accuracy", and the time of the simulation is larger then zero (i.e. it has started).