-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow dt > 1 #141
Allow dt > 1 #141
Conversation
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.
Thanks - this looks much simpler than expected. Now for the wrinkle (which we can put into another PR if you prefer)
The motivating reason for this is the malaria mixed ODE/discrete time model, where dt
represents the time step for the discrete part of the model. In this case we want to allow stopping at any time. So this (nonexistant) test should pass:
test_that("can apply stochastic updates by setting dt", {
sys <- dust_system_create(malaria(), list(), n_particles = 10, dt = 10)
dust_system_set_state_initial(sys)
t <- seq(0, 20)
y <- dust_system_simulate(sys, t)
i_beta <- dust_unpack_index(sys)$beta
beta <- y[i_beta, , ]
## Equivalence to a deterinistic model:
sys0 <- dust_system_create(malaria(), list(), n_particles = 10)
for (i in seq_len(length(t) - 1)) {
dust_system_set_state(sys0, y[, , i])
dust_system_run_to_time(sys0, t[[i + 1]])
y0 <- dust_system_state(sys0)
expect_equal(y0[-i_beta, ], y[-i_beta, , i + 1])
}
})
Well - that test does now work by just not calling the checks that would prevent it from doing so if dt > 1 - not sure if this is the answer. But also not sure what checks should/can be carried out at that point (interface.R:700) if dt > 1... |
Is there anything else that needs doing for this to work?
Anything I've missed?