|
|
| 26 |
#include "ns3/simulator.h" |
26 |
#include "ns3/simulator.h" |
| 27 |
|
27 |
|
| 28 |
namespace ns3 { |
28 |
namespace ns3 { |
| 29 |
extern const double NaN; |
29 |
|
|
|
30 |
extern const double NaN; /// Stored representation of NaN |
| 31 |
|
| 32 |
/** |
| 33 |
* \brief true if x is NaN |
| 34 |
* \param x |
| 35 |
* \return whether x is NaN |
| 36 |
*/ |
| 30 |
inline bool isNaN (double x) { return x != x; } |
37 |
inline bool isNaN (double x) { return x != x; } |
| 31 |
|
38 |
|
| 32 |
class DataOutputCallback; |
39 |
class DataOutputCallback; |
| 33 |
|
40 |
|
|
|
41 |
/** |
| 42 |
* \ingroup stats |
| 43 |
* \class StatisticalSummary |
| 44 |
* \brief Abstract class for calculating statistical data |
| 45 |
* |
| 46 |
*/ |
| 34 |
class StatisticalSummary { |
47 |
class StatisticalSummary { |
| 35 |
public: |
48 |
public: |
| 36 |
/** |
49 |
/** |
|
|
| 40 |
{ |
53 |
{ |
| 41 |
} |
54 |
} |
| 42 |
/** |
55 |
/** |
| 43 |
* Returns the number of the observations. |
56 |
* Returns the number of observations. |
|
|
57 |
* \return Number of observations |
| 44 |
*/ |
58 |
*/ |
| 45 |
virtual long getCount () const = 0; |
59 |
virtual long getCount () const = 0; |
| 46 |
|
60 |
|
| 47 |
/** |
61 |
/** |
| 48 |
* Returns the sum of the values. |
62 |
* Returns the sum of the values. |
|
|
63 |
* \return Sum of values |
| 49 |
* @see getWeightedSum() |
64 |
* @see getWeightedSum() |
| 50 |
*/ |
65 |
*/ |
| 51 |
virtual double getSum () const = 0; |
66 |
virtual double getSum () const = 0; |
| 52 |
|
67 |
|
| 53 |
/** |
68 |
/** |
| 54 |
* Returns the sum of the squared values. |
69 |
* Returns the sum of the squared values. |
|
|
70 |
* \return Sum of squared values |
| 55 |
* @see getWeightedSqrSum() |
71 |
* @see getWeightedSqrSum() |
| 56 |
*/ |
72 |
*/ |
| 57 |
virtual double getSqrSum () const = 0; |
73 |
virtual double getSqrSum () const = 0; |
| 58 |
|
74 |
|
| 59 |
/** |
75 |
/** |
| 60 |
* Returns the minimum of the values. |
76 |
* Returns the minimum of the values. |
|
|
77 |
* \return Minimum of values |
| 61 |
*/ |
78 |
*/ |
| 62 |
virtual double getMin () const = 0; |
79 |
virtual double getMin () const = 0; |
| 63 |
|
80 |
|
| 64 |
/** |
81 |
/** |
| 65 |
* Returns the maximum of the values. |
82 |
* Returns the maximum of the values. |
|
|
83 |
* \return Maximum of values |
| 66 |
*/ |
84 |
*/ |
| 67 |
virtual double getMax () const = 0; |
85 |
virtual double getMax () const = 0; |
| 68 |
|
86 |
|
| 69 |
/** |
87 |
/** |
| 70 |
* Returns the mean of the (weighted) observations. |
88 |
* Returns the mean of the (weighted) observations. |
|
|
89 |
* \return Mean of (weighted) observations |
| 71 |
*/ |
90 |
*/ |
| 72 |
virtual double getMean () const = 0; |
91 |
virtual double getMean () const = 0; |
| 73 |
|
92 |
|
| 74 |
/** |
93 |
/** |
| 75 |
* Returns the standard deviation of the (weighted) observations. |
94 |
* Returns the standard deviation of the (weighted) observations. |
|
|
95 |
* \return Standard deviation of (weighted) observations |
| 76 |
*/ |
96 |
*/ |
| 77 |
virtual double getStddev () const = 0; |
97 |
virtual double getStddev () const = 0; |
| 78 |
|
98 |
|
| 79 |
/** |
99 |
/** |
| 80 |
* Returns the variance of the (weighted) observations. |
100 |
* Returns the variance of the (weighted) observations. |
|
|
101 |
* \return Variance of (weighted) observations |
| 81 |
*/ |
102 |
*/ |
| 82 |
virtual double getVariance () const = 0; |
103 |
virtual double getVariance () const = 0; |
| 83 |
}; |
104 |
}; |
| 84 |
|
105 |
|
|
|
106 |
/** |
| 107 |
* \ingroup stats |
| 108 |
* \class DataCalculator |
| 109 |
* \brief Calculates data during a simulation |
| 110 |
* |
| 111 |
*/ |
| 85 |
//------------------------------------------------------------ |
112 |
//------------------------------------------------------------ |
| 86 |
//-------------------------------------------- |
113 |
//-------------------------------------------- |
| 87 |
class DataCalculator : public Object { |
114 |
class DataCalculator : public Object { |
|
|
| 89 |
DataCalculator(); |
116 |
DataCalculator(); |
| 90 |
virtual ~DataCalculator(); |
117 |
virtual ~DataCalculator(); |
| 91 |
|
118 |
|
|
|
119 |
/** |
| 120 |
* Returns whether the DataCalculator is enabled |
| 121 |
* \return true if DataCalculator is enabled |
| 122 |
*/ |
| 92 |
bool GetEnabled () const; |
123 |
bool GetEnabled () const; |
|
|
124 |
|
| 125 |
/** |
| 126 |
* Enables DataCalculator when simulation starts |
| 127 |
*/ |
| 93 |
void Enable (); |
128 |
void Enable (); |
|
|
129 |
|
| 130 |
/** |
| 131 |
* Disables DataCalculator when simulation stops |
| 132 |
*/ |
| 94 |
void Disable (); |
133 |
void Disable (); |
| 95 |
|
134 |
|
|
|
135 |
/** |
| 136 |
* Sets the DataCalculator key to the provided key |
| 137 |
* \param key Key value as a string |
| 138 |
*/ |
| 96 |
void SetKey (const std::string key); |
139 |
void SetKey (const std::string key); |
|
|
140 |
/** |
| 141 |
* Gets the DataCalculator key |
| 142 |
* \return Key value as a string |
| 143 |
*/ |
| 97 |
std::string GetKey () const; |
144 |
std::string GetKey () const; |
| 98 |
|
145 |
|
|
|
146 |
/** |
| 147 |
* Sets the DataCalculator context to the provided context |
| 148 |
* \param context Context value as a string |
| 149 |
*/ |
| 99 |
void SetContext (const std::string context); |
150 |
void SetContext (const std::string context); |
|
|
151 |
/** |
| 152 |
* Gets the DataCalculator context |
| 153 |
* \return Context value as a string |
| 154 |
*/ |
| 100 |
std::string GetContext () const; |
155 |
std::string GetContext () const; |
| 101 |
|
156 |
|
|
|
157 |
/** |
| 158 |
* Starts DataCalculator at a given time in the simulation |
| 159 |
* \param startTime |
| 160 |
*/ |
| 102 |
virtual void Start (const Time& startTime); |
161 |
virtual void Start (const Time& startTime); |
|
|
162 |
/** |
| 163 |
* Stops DataCalculator at a given time in the simulation |
| 164 |
* \param stopTime |
| 165 |
*/ |
| 103 |
virtual void Stop (const Time& stopTime); |
166 |
virtual void Stop (const Time& stopTime); |
| 104 |
|
167 |
|
|
|
168 |
/** |
| 169 |
* Outputs data based on the provided callback |
| 170 |
* \param callback |
| 171 |
*/ |
| 105 |
virtual void Output (DataOutputCallback &callback) const = 0; |
172 |
virtual void Output (DataOutputCallback &callback) const = 0; |
| 106 |
|
173 |
|
| 107 |
protected: |
174 |
protected: |
| 108 |
bool m_enabled; // Descendant classes *must* check & respect m_enabled! |
175 |
bool m_enabled; /// Descendant classes *must* check & respect m_enabled! |
| 109 |
|
176 |
|
| 110 |
std::string m_key; |
177 |
std::string m_key; /// Key value |
| 111 |
std::string m_context; |
178 |
std::string m_context; /// Context value |
| 112 |
|
179 |
|
| 113 |
virtual void DoDispose (void); |
180 |
virtual void DoDispose (void); |
| 114 |
|
181 |
|