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

Export run_resumable_simulation into namespace #314

Closed
lmhaile opened this issue Jul 2, 2024 · 4 comments
Closed

Export run_resumable_simulation into namespace #314

lmhaile opened this issue Jul 2, 2024 · 4 comments

Comments

@lmhaile
Copy link
Contributor

lmhaile commented Jul 2, 2024

Hi @giovannic and @plietar !

I might be missing something here, but I believe run_resumable_simulation needs to be imported into the malariasimulation namespace via a @import call. Hoping to test the functionality, and I think this is my issue!

#' @title Run the simulation in a resumable way
#'
#' @description this function accepts an initial simulation state as an argument, and returns the
#' final state after running all of its timesteps. This allows one run to be resumed, possibly
#' having changed some of the parameters.
#' @param timesteps the timestep at which to stop the simulation
#' @param parameters a named list of parameters to use
#' @param correlations correlation parameters
#' @param initial_state the state from which the simulation is resumed
#' @param restore_random_state if TRUE, restore the random number generator's state from the checkpoint.
#' @return a list with two entries, one for the dataframe of results and one for the final
#' simulation state.
run_resumable_simulation <- function(

@plietar
Copy link
Member

plietar commented Jul 2, 2024

Yes I believe you’re right (albeit I think it’s an @export that is needed). I’ll make a fix tomorrow. In the meantime you can work around by using a triple colon, eg malariasimulation:::run_resumable_simulation.

I’d be curious to hear more your use case! You’re the first person to try this feature in practice, hence the snags. Let me know if anything else comes up. I’ve been meaning to write some vignette about it but haven’t got around to it yet.

@lmhaile
Copy link
Contributor Author

lmhaile commented Jul 3, 2024

Fantastic, thanks Paul! For now the triple colon works great.

@htopazian and I are setting up some context-specific runs where vaccine efficacy and carrying capacity parameters change halfway through the simulation (IE, modelling the introduction of mosquito gene drives and blood-stage vaccines). I launched a few test models yesterday and they seem to have completed, so will plot them to see how they look!

The code is in development but here is my use case:

https://github.com/mrc-ide/malaria_no_more/blob/e0826db8b1b02e76b1e71f6a7754c0e759289ddc/src/model_country/MNM_functions.R#L250-L294

Also happy to write a vignette for this based on the tests, since I'll be playing around with this feature today anyway. Thanks for your help!

@plietar
Copy link
Member

plietar commented Jul 3, 2024

Does automatic closing of issues when merging a PR not work on this repo?

@plietar
Copy link
Member

plietar commented Jul 3, 2024

Ah I think it's because the PR was merged onto dev, which isn't the "default branch"

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

No branches or pull requests

2 participants