feature: Events through root finding in controller
CGMossa opened this issue · 2 comments
Hey! First, I'd like to say, that this is a great project, and I was investigating the possibility to write something like this myself, but this is way better than what I would have scraped together.
I'd like to open the discussion, if I may, for adding event / callback functions. This was mentioned in #1.
This is available in the R-package desolve
and
the julia package DifferentialEquations.jl as callbacks.
- stopping the integration before the specified
$t_{max}$ - stopping the integration regardless of
$t_{max}$ - change the state when an event occurs, that is specified as a root for some function
Currently, I make use of the 2nd point, in that I use this to accurately determine a certain duration using deSolve
.
E.g.
deSolve::lsodar(
times = c(0, Inf),
rootfunc =
# estimate for prevalence - prevalence threshold
...
)
I'd like to be able to do (2), but (1) and (3) are cool to have. It would be nice to collate thoughts,
ideas, concerns, about this, and maybe eventually someone could do it? I would very much like to
contribute, and if it becomes somewhat clear, what needs to happen, I'd like to do it!
Hi @CGMossa,
I think it would be a nice addition to implement an event detection mechanism to the crate. I won't have time to work on it myself but feel free to propose an implementation design. For (1) and (2), how is that different than implementing solout
for your system?
Thanks for the positive reply back! I'm very happy with that. I'm not an expert myself, so I'll take a stab at it.
Right! So with the way I defined deSolve
, the system will stop at exactly the root. I will have the exact
time in which the event occurred, and not "just" when we crossed a certain threshold, that is mostly dictated by the stepsize in time.
In my work, I use this time as a measure of how long, numerically exactly, the system spent until it reached this condition.