-
Notifications
You must be signed in to change notification settings - Fork 16
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 Safeguards to EulerCore to reduce undefined behavior for SDE models #1165
Comments
I have proposed a possible "new" EulerCore in the linked branch, before opening a pull request I would like to discuss whether this should be moved into a new core |
@reneSchm any expert opinion how Nils could proceed? |
I assume you mean NaNs in simulation results by "undefined behaviour"? While they are not great, these NaNs are perfectly well defined behaviour in our case. I am not convinced that the IntegratorCore is a suitable place for this. The main issues I see are:
An alternative may be to use a new DerivFunction to compute the stochastic component from each flow and add it to that flow, as well as applying the safeguards. This DerivFunction can be used by a new Simulation class, or we can discuss adding it in some form to the FlowSimulation. I have a experimental branch here. It does not have your safeguards yet, but I think they can be added around the calculation of m_pop or around the compuation of the stochastic components. Can you maybe try to use this with a model that is currently causing issues, so we can try and discuss fixes? That is, can you implement the "get_flow_denoised" function, which just returns the flows without clamping or adding a stochastic component. |
Hi René thank you for your insight. I will implement a model with 3 variants and 4 different immunity states as an example. |
I have implemented two models sde_ui3 and sde_ui10, reflecting a SIS model with virus mutation (the first with 3 variants and 4 immunity states, the second with 10 variants and 11 immunity states). It seems to work quite well but I have yet to write tests. One thing I have noticed is that the 10 variant model is very demanding during build with cmake. My setup was barely able to finish compilation with 32 GB RAM and 100 GB swap file so I excluded the model from the cmake files in the branch. |
The ui10 model is demanding because of the ~400 infection states, as the compile time map for indices is optimized for runtime, but not compile time. I played around a little with the models, and without the factor |
Motivation / Current Behaviour
As of now SDE models have to implement checks for whether flows/derivatives result in overflows in the compartments (negative compartments or compartments greater than population size). The current implementation can also result in undefined behavior by floating point operations (see Issue #1009)
Enhancement description
Adapting the EulerCore (potentially writing a EulerMaruyamaCore) one can use vectorized functions to add those safeguards and other modifications into the core. Potential modifications are:
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: