mrc-ide / squire

SEIR transmission model of COVID-19. Documentation at:
https://mrc-ide.github.io/squire/
Other
50 stars 28 forks source link

If the mod$run is executed again, would it continue from its previous state? #143

Open apbarraza opened 3 years ago

apbarraza commented 3 years ago

Hi,

I am interested in using your disease model to test a "dynamic" intervention policy. I understand that the current simulation run allows for applying interventions. However, the intervention plan would have to be decided beforehand, it would be "static".

I would like to know if I can execute the simulation in small consecutive time periods. For instance, the model could first run 2 days, then a change on the intervention policy might occur, and then the goal would be to execute the next time period from where the last one left off including the new intervention, and so forth.

More specifically, I am wondering, in run.R, if the mod$run is executed again, would it continue from its previous state? Setting replicates = 1 in the stochastic case.

Thank you, Andrea

OJWatson commented 3 years ago

Hey, Sorry for the delay.

mod$run will run from the initial state it is given. So if you run it again, it will use the same starting condition. The way to do that would be to run the model and then pass in the model state back to mod$run. This is what we do in the projections function here:

https://github.com/mrc-ide/squire/blob/master/R/projections.R#L368-L371

However, if you know already wht your intervention is that you want to put in place after 2 days then you can just do that when you call run the first time. If, however, you want to have an intervention come in when some condition is reached then that is harder. However, I am currently writing some functionality for that in the triggering branch which should be ready shortly.

Hope that helps,

OJ