Counter
- class pydsol.core.statistics.Counter(name: str)[source]
Bases:
StatisticsInterface
The Counter is a simple statistics object that can count events or occurrences. Note that the number of observations is not necessarily equal to the value of the counter, since the counter allows any integer as the increment (or decrement) during an observation.
The initialize() method resets the statistics object. The initialize method can, for instance, be called when the warmup period of the simulation experiment has completed.
Example
In simulation, the Counter can be used to count arrivals, the number of processed entities in servers, the number of entities in the system, etc.
- Attributes:
_name (str) – the name by which the statistics object can be identified
_n (int) – the number of observations
_count (int) – the current value of the counter
- __init__(name: str)[source]
Construct a new Counter statistics object. The Counter is a simple statistics object that can count events or occurrences. Note that the number of observations is not necessarily equal to the value of the counter, since the counter allows any integer as the increment (or decrement) during an observation.
- Parameters:
name (str) – The name by which the statistics object can be identified.
- Raises:
TypeError – when name is not a string
- initialize()[source]
Initialize the statistics object, resetting all values to the state where no observations have been made. This method can, for instance, be called when the warmup period of the simulation experiment has completed.
- property name
Return the name of this statistics object.
- Returns:
The name of this statistics object.
- Return type:
str
- register(value: int)[source]
Process one observation. The value indicates the increment or decrement of the counter (often 1).
- Parameters:
value (int) – The increment or decrement of the Counter.
- Raises:
TypeError – when value is not an int
- count()[source]
Return the current value of the counter statistic.
- Returns:
The current value of the counter statistic.
- Return type:
int
- n()[source]
Return the number of observations.
- Returns:
The number of observations.
- Return type:
int
- classmethod report_header() str [source]
Return a string representing a header for a textual table with a monospaced font that can contain multiple counters.
- report_line() str [source]
Return a string representing a line with important statistics values for this counter, for a textual table with a monospaced font that can contain multiple counters.
Return a string representing a footer for a textual table with a monospaced font that can contain multiple counters.