jackolney / baldr

Epidemiological modelling in R
https://jackolney.github.io/baldr/
MIT License
3 stars 0 forks source link

odin speed #10

Open jackolney opened 7 years ago

jackolney commented 7 years ago
richfitz commented 6 years ago

yeah, what we need to do is to detect all user parameters and shift them out into boxes in the shiny interface. I don't know if that's possible, but it would be super cool

richfitz commented 6 years ago

(in the odin generator function you can get at the user variables by using the formals:

gen <- odin::odin({
  deriv(N) <- r * N * (1 - N / K)
  initial(N) <- N0
  N0 <- user(1)
  K <- user(100)
  r <- user()
})
formals(gen)$user
# list(r = r, N0 = N0, K = K)
names(lapply(formals(gen)$user[-1], identity))
# [1] "r"  "N0" "K" 

I should probably write something to allow better interrogation of this though!

jackolney commented 6 years ago

Thanks. Will have to test how odin reacts when user variables are manipulated from outside odin::odin({})

richfitz commented 6 years ago

you'll want to fire them in (on a change) via $set_user to the existing model. Recompile when the source code is changed only. I can elaborate further if that's useful (was just showing off your thing to someone and remembered how cool it was)

jackolney commented 6 years ago

Noted.

Lets be honest, its a pretty wrapper around all your hard work 😄