Closed matt-gretton-dann closed 3 years ago
I suspect from lines 891 and 892, P.JourneyDurationDistrib[i] and P.LocalJourneyDurationDistrib[i] are cumulatively calculated, hence are monotonically increasing. (Or perhaps two entries might be the same, but never dropping).
Hence, I think you can resume the search with j
where you last left it; it might/might not increase, since P.InvJourneyDurationDistrib will have 1024 elements, but JourneyDurationDistrib only 14.
But for PR #400, (if I'm right), that's a reason those two loops should not be fused together, or if they do, then they should have separate j1 and j2 keeping track of the progress through the cumulative distributions.
@weshinsley : Thanks for the review. So I'll "correct" the code by adding a comment that this is what is going on, and leave the code as originally written.
This was refactored at some point to make it more clear...
I noticed this whilst reviewing #400, and I'm not sure if it is a bug or not - @NeilFerguson I would appreciate your review.
I believe it doesn't affect any simulations published to date as it requires airports to be enabled - which they haven't been for CovidSim.
In the two loops starting at line 894 of src/CovidSim.cpp initialising
InvJourneyDurationDistrib
andInvLocalJourneyDurationDistrib
, the variablej
is initialised to0
at the head of the loop and then used to find an appropriate index in thewhile
loop, which is used to set the value ofInv...[i]
.The issue is
j
is not reset each go round the loop. ThereforeInv...[i - 1] <= Inv...[i]
(j is always increasing).I am not sure whether this is a bug or not. I think it probably is and so have made the proposed change - but @NeilFerguson can you please confirm?