Skip to content
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

Merged
merged 10 commits into from
Dec 13, 2024
Merged

Allow dt > 1 #141

merged 10 commits into from
Dec 13, 2024

Conversation

weshinsley
Copy link
Contributor

@weshinsley weshinsley commented Nov 22, 2024

Is there anything else that needs doing for this to work?
Anything I've missed?

@weshinsley weshinsley marked this pull request as ready for review November 22, 2024 17:25
@weshinsley weshinsley requested a review from richfitz November 22, 2024 17:25
Copy link
Member

@richfitz richfitz left a 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])
  }
})

@weshinsley
Copy link
Contributor Author

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...

@weshinsley weshinsley requested a review from richfitz November 28, 2024 13:49
@weshinsley weshinsley requested a review from richfitz December 13, 2024 12:49
@richfitz richfitz merged commit 5501f39 into main Dec 13, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants