Bug 2589 - Binary search in LteMiErrorModel::GetTbDecodificationStats is incorrect
Binary search in LteMiErrorModel::GetTbDecodificationStats is incorrect
Status: PATCH PENDING
Product: ns-3
Classification: Unclassified
Component: lte
ns-3-dev
All All
: P3 normal
Assigned To: Biljana Bojović
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-12-15 15:58 EST by Alexander Krotov
Modified: 2017-01-04 00:16 EST (History)
3 users (show)

See Also:


Attachments
Patch 1/2 (1.41 KB, text/plain)
2016-12-15 15:58 EST, Alexander Krotov
Details
Patch 1/2 (1.41 KB, patch)
2016-12-15 15:58 EST, Alexander Krotov
Details | Diff
Patch 2/2 (actual fix, apply on top of the first) (2.69 KB, patch)
2016-12-15 16:04 EST, Alexander Krotov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Krotov 2016-12-15 15:58:00 EST
Created attachment 2702 [details]
Patch 1/2

Binary search at http://code.nsnam.org/ns-3-dev/file/f883d71c975e/src/lte/model/lte-mi-error-model.cc#l613 is incorrect. It does not give the intended result. At least the result is not the same as what commented code gives: http://code.nsnam.org/ns-3-dev/file/f883d71c975e/src/lte/model/lte-mi-error-model.cc#l604

I split the fix in two patches. First one uncomments the simple but slow version of code and moves it inside "#ifdef NS3_BUILD_PROFILE_DEBUG" to show that it indeed results in assertion failures during tests.

The second patch replaces the algorithm with the standard std::lower_bound. It follows in the next message.
Comment 1 Alexander Krotov 2016-12-15 15:58:46 EST
Created attachment 2703 [details]
Patch 1/2

Reuploaded first patch as patch.
Comment 2 Alexander Krotov 2016-12-15 16:04:11 EST
Created attachment 2704 [details]
Patch 2/2 (actual fix, apply on top of the first)

Here I wrapped cbSizeTable into std::array to use std::lower_bound. According to tests (no assertion failures) the code corresponds to the simple version of code.

I think we never discussed limits of C++11 usage in NS-3 code since switch, but I decided that using "auto" for iterator and lambda for a one-line comparison function is sane in this case.