mrc-ide / odin

ᚩ A DSL for describing and solving differential equations in R
https://mrc-ide.github.io/odin
Other
104 stars 13 forks source link

ir_serialise_expression() error on compiling models with user() #314

Closed JenLSheffield closed 2 months ago

JenLSheffield commented 3 months ago

After a recent update of R and odin I'm experiencing a new error on all odin models that make use of the user() functionality.
A straightfoward e.g. from the odin tutorial, the code:

generator <- odin::odin({
  deriv(N) <- r * N * (1 - N / K)
  initial(N) <- N0

  N0 <- user(1)
  K <- user(100)
  r <- user()
})

returns the error

Error in ir_serialise_expression(eq$user$min) : unhandled expression [odin bug]

If I remove the user() statements this compiles with no problems.

I am currently using: R version 4.4.0 (2024-04-24 ucrt) -- "Puppy Cup" Platform: x8664-w64-mingw32/x64 using C compiler: 'gcc.exe (GCC) 13.2.0' odin v1.5.4 (This seems to be the most recent version available for Win?)_

My colleague is not experiencing this error - his current setup: R version 4.4.0 (2024-04-24) -- "Puppy Cup" Platform: x86_64-pc-linux-gnu (64-bit) using C compiler: ‘gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0’ odin: 1.5.10

richfitz commented 3 months ago

Hi @JenLSheffield - apologies for the delay.

I think that you have hit a bug we fixed in https://github.com/mrc-ide/odin/pull/306 which was merged into 1.5.9

I'm afraid that the installation instructions are out of date, pointing at our drat repo, which is indeed at 1.5.4. I've updated these instructions in #315, and the new installation instructions should get you a new version. Please run in a new session:

install.packages(
  "odin",
  repos = c("https://mrc-ide.r-universe.dev/", "https://cloud.r-project.org/"))

which will install 1.5.10 (or 1.5.11 in an hour or so).

JenLSheffield commented 2 months ago

Fixed, with thanks!