Closed staticfloat closed 7 months ago
Update the documentation as well?
BTW, we should consider having a form of this as a serialization method for DE solutions.
It'd be nice if this provided a way to get derivatives as well. It'd basically be (u₁ - u₀) / (t₁ - t₀)
modulo the weird cursor stuff going on in interpolate
.
I can add derivative calculation fairly easily. I’ll do that when I get back to work.
What is broken in finalize? Is there something else we should be fixing downstream? Looks like it's clear that would have nothing
chunks so I'm not quite sure what that's trying to show/do.
What is broken in finalize?
It should be solved by https://github.com/SciML/OrdinaryDiffEq.jl/pull/2061 now that that is merged.
I should have fixed the issue here (all test pass locally, at least), but I am marking this as draft again as I have a feature request from @pepijndevos to add derivative saving as well.
Alright, that was easier than expected.
The original implementation of
LinearizingSavingCallback
had two modes; one with a singleSavedValues
that held allu
values, and one with multipleSavedValues
structs, one for eachu
index. Unfortunately, this second version (being the one that most users would want) was inefficient, wasteful in memory, and a pain to deal with after the fact due to eachu
index having a different time vector.This PR deletes the first mode and improves the second mode to now have a much more efficient and useful datastructure backing the independently linearized states. In particular, it now preallocates memory in chunks while solving, stores the time vector only once (with a memory-efficient bitmap storing time vector occupancy for each
u
variable) and provides easy-to-use methods to consume the output both through iteration and explicit sampling at timepoints. In my experiments with a moderate-size ODE with 22 states that takes ~2000 timesteps, adding this callback increases solve time by ~10%, and allocations by ~100%.