-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add exception when emergence is negative in SimpleMPD model #379
Conversation
why not replace the emergence rate with zero and send a warning, without stopping the simulation |
@ThomasASmith This is exactly what I did initially. However setting the emergence to 0 will affect the simulation and because it is quite rare, users running thousands of scenarios will not see it unless they manually check all the logs. By throwing an exception, the user will see that an output is missing and can decide how to handle the situation. In most cases I would argue this error is caused by a bad or unrealistic seasonality. In addition, the Fourier transform that we use to smooth the input EIR values struggles with small values. It seems that just setting the lowest EIR values to 1% of the peak will solve all the problems. I actually have another open pull request that will automatically set the minimum EIR to 1% of the max EIR in all scenarios but this is not always needed so it has been pending for a while. Maybe it's time to merge this one too? Many users probably have this problem without realizing their smoothed input EIR in OpenMalaria doesn't actually match their initial monthly values. To illustrate this, you can copy-paste the following monthly EIR values into this tool: https://swisstph.github.io/openmalaria/fourier The following values will crash the simulation when using the SimpleMPD model. You can see with the tool that the Fourier series does not match the input very well.
However, setting the two smallest values to 0.01 or moving the decimal place solves the problem:
Not only the smoothed EIR matches the monthly values, but the simulation no longer crashes with the SimpleMPD model. |
Thanks for the explanation. You have obviously thought it through.
Tom
From: Aurélien Cavelan ***@***.***>
Sent: Wednesday, January 3, 2024 8:24 PM
To: SwissTPH/openmalaria ***@***.***>
Cc: Thomas A. Smith ***@***.***>; Mention ***@***.***>
Subject: [EXTERN] Re: [SwissTPH/openmalaria] Add exception when emergence is negative in SimpleMPD model (PR #379)
@ThomasASmith<https://github.com/ThomasASmith> This is exactly what I did initially. However setting the emergence to 0 will affect the simulation and because it is quite rare, users running thousands of scenarios will not see it unless they manually check all the logs.
By throwing an exception, the user will see that an output is missing and can decide how to handle the situation.
In most cases I would argue this error is caused by a bad or unrealistic seasonality. In addition, the Fourier transform that we use to smooth the input EIR values struggles with small values. It seems that just setting the lowest EIR values to 1% of the peak will solve all the problems.
I actually have another open pull request that will automatically set the minimum EIR to 1% of the max EIR in all scenarios but this is not always needed so it has been pending for a while. Maybe it's time to merge this one too?
Many users probably have this problem without realizing their smoothed input EIR in OpenMalaria doesn't actually match their initial monthly values.
To illustrate this, you can copy-paste the following monthly EIR values into this tool: https://swisstph.github.io/openmalaria/fourier The following values will crash the simulation when using the SimpleMPD model. You can see with the tool that the Fourier series does not match the input very well.
1.0
0.950484
0.850176
0.998646
0.592984
0.090076
0.002824
0.001974
0.019501
0.115986
0.440608
0.866085
image.png (view on web)<https://github.com/SwissTPH/openmalaria/assets/2157755/155954ef-af33-4933-a9c1-19e677f6b8b5>
However, setting the two smallest values to 0.01 or moving the decimal place solves the problem:
1.0
0.950484
0.850176
0.998646
0.592984
0.090076
0.02824
0.01974
0.019501
0.115986
0.440608
0.866085
image.png (view on web)<https://github.com/SwissTPH/openmalaria/assets/2157755/714d9e1c-8549-4897-9263-2a443cc9f16c>
Not only the smoothed EIR matches the monthly values, but the simulation no longer crashes with the SimpleMPD model.
—
Reply to this email directly, view it on GitHub<#379 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ACILVJDFG3JM5RLO6UAGY3TYMWV3TAVCNFSM6AAAAABBLYI3MKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVHA2TIMZTGQ>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on call
When the seasonality increases too fast and when the annual EIR is low, the following quantity can become negative:
invLarvalResources[t] = (probPreadultSurvival * yt - mosqEmergeRate[t]) / (mosqEmergeRate[t] * yt);
which causes the emergence rate to be negative and crash the simulation.
This pull request does not fix the error, but the code will now throw a helpful exception and stop the simulation when this happens. This error is rare and can usually be fixed by adjusting the seasonal monthly values or the fourier coefficients and by making sure that the lowest EIR is within 1% of the peak EIR.