16 #ifndef __OMNETPP_CHISTOGRAMSTRATEGY_H
17 #define __OMNETPP_CHISTOGRAMSTRATEGY_H
19 #include <omnetpp/chistogram.h>
67 virtual void collect(
double value) = 0;
74 virtual void collectWeighted(
double value,
double weight) = 0;
82 virtual void setUpBins() = 0;
88 virtual void clear() = 0;
111 Mode mode = cHistogram::MODE_REALS;
121 lo(lo), hi(hi), numBins(numBins), mode(mode) {}
129 void setRange(
double lo,
double hi) {this->lo = lo; this->hi = hi;}
130 double getUpperLimit()
const {
return hi;}
131 void setUpperLimit(
double hi) {this->hi = hi;}
132 double getLowerLimit()
const {
return lo;}
133 void setLowerLimit(
double lo) {this->lo = lo;}
134 Mode getMode()
const {
return mode;}
135 void setMode(Mode mode) {this->mode = mode;}
136 double getBinSize()
const {
return numBins;}
137 void setBinSize(
double binSize) {this->numBins = binSize;}
142 virtual void collect(
double value)
override;
143 virtual void collectWeighted(
double value,
double weight)
override;
144 virtual void setUpBins()
override;
160 bool inPrecollection =
true;
161 size_t numToPrecollect = 1000;
162 size_t numToCollate = 10;
163 double lastRange = NAN;
164 int rangeUnchangedCounter = 0;
165 int rangeUnchangedThreshold = 50;
166 double finiteMinValue = NAN, finiteMaxValue = NAN;
167 std::vector<double> values;
168 std::vector<double> weights;
171 virtual void moveValuesIntoHistogram();
172 virtual bool precollect(
double value,
double weight=1.0);
173 virtual void createBins() = 0;
188 int getNumToPrecollect()
const {
return numToPrecollect;}
189 void setNumToPrecollect(
int numToPrecollect) {this->numToPrecollect = numToPrecollect;}
190 int getNumToCollate()
const {
return numToCollate;}
191 void setNumToCollate(
int numToCollate) {this->numToCollate = numToCollate;}
192 int getRangeUnchangedThreshold()
const {
return rangeUnchangedThreshold;}
193 void setRangeUnchangedThreshold(
int threshold) {this->rangeUnchangedThreshold = threshold;}
198 virtual void setUpBins()
override;
199 virtual void clear()
override;
225 static const int DEFAULT_NUM_BINS = 60;
226 double rangeExtensionFactor = 1.5;
227 double binSize = NAN;
228 int numBinsHint = -1;
229 int targetNumBins = DEFAULT_NUM_BINS;
230 Mode mode = cHistogram::MODE_AUTO;
231 bool autoExtend =
true;
232 bool binMerging =
true;
233 int maxNumBins = 1000;
236 virtual void createBins()
override;
237 virtual void extendBinsTo(
double value);
238 virtual void reduceNumBinsTo(
int numBins);
239 virtual void mergeAllBinsIntoOne(
double newApproxBinSize);
247 explicit cDefaultHistogramStrategy(
int numBinsHint=-1, Mode mode=cHistogram::MODE_AUTO) : numBinsHint(numBinsHint), mode(mode) {}
255 int getNumBinsHint()
const {
return numBinsHint;}
256 void setNumBinsHint(
int numBins) {this->numBinsHint = numBins;}
261 virtual void collect(
double value)
override;
262 virtual void collectWeighted(
double value,
double weight)
override;
307 static const int DEFAULT_NUM_BINS = 60;
310 double rangeExtensionFactor = 1.5;
311 int numBinsHint = -1;
312 int targetNumBins = DEFAULT_NUM_BINS;
313 double requestedBinSize = NAN;
314 double binSize = NAN;
315 Mode mode = cHistogram::MODE_AUTO;
316 bool binSizeRounding =
true;
317 bool autoExtend =
true;
318 bool binMerging =
true;
319 int maxNumBins = 1000;
322 virtual void createBins()
override;
323 virtual void extendBinsTo(
double value);
324 virtual void reduceNumBinsTo(
int numBins);
325 virtual void mergeAllBinsIntoOne(
double newApproxBinSize);
342 void setRangeHint(
double lo,
double hi) {this->lo = lo; this->hi = hi;}
343 double getUpperLimitHint()
const {
return hi;}
344 void setUpperLimitHint(
double hi) {this->hi = hi;}
345 double getLowerLimitHint()
const {
return lo;}
346 void setLowerLimitHint(
double lo) {this->lo = lo;}
347 double getRangeExtensionFactor()
const {
return rangeExtensionFactor;}
348 void setRangeExtensionFactor(
double rangeExtensionFactor) {this->rangeExtensionFactor = rangeExtensionFactor;}
349 Mode getMode()
const {
return mode;}
350 void setMode(Mode mode) {this->mode = mode;}
351 double getBinSizeHint()
const {
return requestedBinSize;}
352 void setBinSizeHint(
double binSize) {this->requestedBinSize = binSize;}
353 bool getBinSizeRounding()
const {
return binSizeRounding;}
354 void setBinSizeRounding(
bool binSizeRounding) {this->binSizeRounding = binSizeRounding;}
355 int getNumBinsHint()
const {
return numBinsHint;}
356 void setNumBinsHint(
int numBins) {this->numBinsHint = numBins;}
357 void setAutoExtend(
bool enable) {this->autoExtend = enable;}
358 bool getAutoExtend()
const {
return autoExtend;}
359 void setBinMerging(
bool enable) {this->binMerging = enable;}
360 bool getBinMerging()
const {
return binMerging;}
361 int getMaxNumBins()
const {
return maxNumBins;}
362 void setMaxNumBins(
int numBins) {this->maxNumBins = numBins;}
367 virtual void collect(
double value)
override;
368 virtual void collectWeighted(
double value,
double weight)
override;
369 virtual void clear()
override;