-
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
NAN in multivariant stochastic SEIR Model #1009
Comments
I use std::min and std::max instead of std::clamp to ensure that flows are in the correct bonds. Usage of std::clamp gives a "invalid bounds arguments passed to std::clamp" error which is consistent with the NAN output |
@nijawa : Yes, nan is probably an incorrect input but clamp should prevent any appearance of nan beforehand. So there's potentially another problem? My questions still is "How does the |
@mknaranja At I suspect that the issue is that we dont minimize the flow to the compartment but rather we minimize it to I dont have a good way to resolve this right now |
Clamping/maximizing with |
I think that |
my seir2v model is not yet in main yet so if I branch from main that model will be missing I think? There also still is a bit I have to tidy up before it should get merged into main. Is there a prefered |
Yes, the change would just address the functionality not merge the model yet. As we are in double precision, |
Clamping with a tolerance also is problematic if compartments are 0. To fix this I could either use a multiplicative tolerance (something like 1-1e-10) or use std::max(std::min to enforce non-negative flows over clamp errors |
I suggest clamping to zero exactly, and only use tolerances on the upper bound. Then you don't need a relative tolerance, at least I would've just subtracted You should avoid getting NaNs in the first place, min/max will probably not reliably recover the results if there are NaNs involved. One other thing you could consider is post-processing the results of get_flows in the advance function. There you can just take the max of each compartment and 0. If you've clamped the flows before, the error from that should be at most around 1e-16. |
Depends. If you have nothing commited, then you can just pull again to update all unrelated files. If there are edits that would be overwritten, git will complain. |
The tolerance works on the upper limit of the clamp. std::clamp(flow, 0, compartment / step_size - tol) doesnt seem to work if compartment = 0 |
I am not sure. If the problem still persists, it would be possible to catch these errors in the simulation, as the SDE models use their own simulations anyways. |
Bug description
NAN in compartments in SEIR2V Model
Version
Windows
To reproduce
(https://github.com/SciCompMod/memilio/blob/1009-nan-in-multivariant-seir-model/cpp/examples/sde_seir2v.cpp)
Relevant log output
No response
Add any relevant information, e.g. used compiler, screenshots.
No response
Checklist
The text was updated successfully, but these errors were encountered: