OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000769OMNeT++simulation kernelpublic2014-07-31 12:102014-11-30 12:12
0000769: cVarHistogram produces wrong results with custom (ie manually specified) cells
Hi there,

I've tried to use cVarHistogram with custom cells as described in Section 7.8.2 "Histogram with Custom Cells" of the manual( [^]). However, when I look at the scalar file, all samples are binned in the same cell, regardless of their value.

I've attached the .cc file to reproduce this behaviour.

Looking at the code of, it seems that the problem is that the variable rangemax does not get updated when using custom cells and it has always set to zero. Therefore, when the collectTransformed() method is called, all values ended up being counted as cell_over.

oid cVarHistogram::collectTransformed(double val)
    if (val < rangemin) // rangemin == bin_bounds[0]
    else if (val >= rangemax) // rangemax == bin_bounds[num_cells]
    else // sample falls in the range of ordinary cells/bins
            // ....

I believe the solution is to update rangemax in the addBinBound method.

Let me know if you need any more information,


No tags attached.
? (938) 2014-07-31 12:10
Issue History
2014-07-31 12:10paolinuxNew Issue
2014-07-31 12:10paolinuxFile Added:
2014-11-28 14:50andrasNote Added: 0000953
2014-11-30 09:37andrasNote Added: 0000956
2014-11-30 12:12andrasStatusnew => resolved
2014-11-30 12:12andrasFixed in Version => 4.6
2014-11-30 12:12andrasResolutionopen => fixed
2014-11-30 12:12andrasAssigned To => andras
2015-10-12 09:28ammmar1988Issue cloned: 0000873

2014-11-28 14:50   
The problem is that rangemin/rangemax is not up to date at the time of collect().

> I believe the solution is to update rangemax in the addBinBound method.

The problem with this is that in auto-bins mode, cVarHistogram::transform() uses previously computed rangemin/rangemax variables while creating cells via addBinBound() -- so addBinBound() automatically updating rangemin/rangemax would cause problem/confusion here.

2 better solutions:
  a) let transform() do setting up rangemin/rangemax, and transform() should automatically be invoked on the first collect() call when in manual bins mode. (and further addBinBound() calls after transform() should be prohibited.)

  b) rename existing addBinBound() to doAddBinBound(), and add a new public addBinBound() that calls doAddBinBound() and additionally adjusts rangemin/max too.

Probably (a) is better.
2014-11-30 09:37   
To complicate matters, the user may also manually specify rangemin, rangemax, or both (see range_mode and RANGE_AUTOUPPER,RANGE_AUTOLOWER,RANGE_FIXED constants), and they may conflict with manually added bin bounds. These cases should be reported as errors.