However, even without hitting that assert you can see the difference in the AppendEvent behaviour as shown in the attached png.
As you can see, the range-based loop is 1st adding the value and 2nd is adding the negative of that value. While in the iterator based loop this does not happen.
You can just add some comments as shown below and run the nr-mimo example as it is just for a few seconds. And loop at the prinout when it is first entering the loop for Summ the energy Delta.
if (!m_receiving)
{
NiChanges::iterator nowIterator = GetPosition(now);
for (NiChanges::iterator i = m_niChanges.begin(); i != nowIterator; i++)
{
m_firstPower += i->GetDelta();
NS_LOG_UNCOND("Summing energy. Delta: " << i->GetDelta()
<< ", m_firstPower: " << m_firstPower);
}
// for (auto& i : m_niChanges)
// {
// m_firstPower += i.GetDelta();
// NS_LOG_UNCOND("Summing energy. Delta: " << i.GetDelta()
// << ", m_firstPower: " << m_firstPower);
// }
// Remove all events up to the current moment
m_niChanges.erase(m_niChanges.begin(), nowIterator);
NS_LOG_UNCOND("Events up to the current moment removed.");
// Create an event that represents the new energy
m_niChanges.insert(m_niChanges.begin(), NiChange(startTime, rxPowerW));
NS_LOG_UNCOND("Inserted new energy event at startTime: " << startTime.GetSeconds()
<< ", rxPowerW: " << rxPowerW);
}