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

Allowed delayed expressions, not just variables #129

Merged
merged 20 commits into from
Dec 19, 2024
Merged

Allowed delayed expressions, not just variables #129

merged 20 commits into from
Dec 19, 2024

Conversation

richfitz
Copy link
Member

@richfitz richfitz commented Nov 29, 2024

This is required for the malaria folk and it introduces quite a few new complexities.

After this is in, I can start on delayed delays, though first I'll probably do a bit of a triage through the odin1 tests to see what we actually do with delays

@richfitz richfitz marked this pull request as ready for review December 18, 2024 13:15
@richfitz richfitz requested a review from weshinsley December 18, 2024 13:16
Copy link
Contributor

@weshinsley weshinsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one typo in the instructions - and a couple of comments to help my understanding.

For a future ticket maybe - the error could be better if I try to do multiple delays on the same line -

dat <- odin_parse({
  deriv(x) <- a
  deriv(y) <- 2
  initial(x) <- 0
  initial(y) <- 0
  a <- (x + y) / 2
  c <- delay(a, 1) + delay(a, 2)
  output(z) <- c
})
Error in `odin_parse()`:
! Unsupported function 'delay'
→ Context:
c <- delay(a, 1) + delay(a, 2)
ℹ For more information, run odin2::odin_error_explain("E1027")

And we'll have some doc tickets for vignettes (eg, functions) / odin-monty later...

vignettes/migrating.Rmd Outdated Show resolved Hide resolved
## The delay time must be constant

We require that the delay time is known at first model initialisation and not updated subsequently (i.e., that it is numeric, a literal value assigned to symbol or a paramter with `constant = TRUE`).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does this mean:

We can't write a model that says... depending on how fat our mosquitos have grown, they will... excrete what they ate f(size) time ago - where f(size) varies in the model....

(Would anyone want such a thing...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that's right. This sort of non-constant-time delay could theoretically be interesting I'm sure, but it creates some issues in the solving and I did not add support for that into the way that delays were implemented in dust

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (04475c1) to head (7fc9c2c).
Report is 13 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main      #129      +/-   ##
===========================================
+ Coverage   99.85%   100.00%   +0.14%     
===========================================
  Files          20        20              
  Lines        3421      3504      +83     
===========================================
+ Hits         3416      3504      +88     
+ Misses          5         0       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@richfitz
Copy link
Member Author

the error could be better if I try to do multiple delays on the same line

Fixed now by 1d9ce17, we have a nice hook for this that I've reused

@richfitz richfitz merged commit df19a2e into main Dec 19, 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