-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add PeriodicCallback. #23
Conversation
src/periodic.jl
Outdated
|
||
# Schedule next call to `f` using `add_tstops!`, but be careful not to keep integrating forever | ||
t_new = t_next[] + Δt | ||
if any(t -> t > t_new, integrator.opts.tstops.valtree) # TODO: accessing internal data... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, there must be a better way to iterate through a heap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess it would at least be better to reverse-iterate.
Could also:
- store the maximum time in the integrator options, in addition to
tstops
(although it then becomes possible to have bugs wheretstops
is out of sync with that maximum time). - switch to a min-max heap (not yet implemented in DataStructures.jl and perhaps overkill)
Codecov Report
@@ Coverage Diff @@
## master #23 +/- ##
=========================================
+ Coverage 93.54% 94.15% +0.6%
=========================================
Files 5 6 +1
Lines 155 171 +16
=========================================
+ Hits 145 161 +16
Misses 10 10
Continue to review full report at Codecov.
|
Added README.md entry, made it so that passing in an Are you satisfied with the |
I wish there was a more generic way to iterate through a heap than that, but that's an issue for DataStructures.jl. Works for now. |
This is to support stuff like JuliaRobotics/RigidBodySim.jl#5.
I'm aware of http://docs.juliadiffeq.org/latest/features/diffeq_arrays.html#Example:-A-Control-Problem-1, but I wasn't satisfied with simply using the
tstops
kwarg tosolve
. Reasons:tspan
s (where integration continues indefinitely until some callbackterminate!
s the integrator, in my case a stop button in a GUI)tspan
s you'd end up with a length of the internaltstops
collection that is linear in the length of the integration time interval with the other method; that's not the end of the world, but it seems unnecessary.PeriodicCallback
s, you only have to pass the callback intosolve
orinit
. I think this is cleaner than having to pass in both a callback andtstops
, especially if there are multiple callbacks that each have a different period.