Best way to cache data during DifferentialEquations.jl integration

I have a problem which could be written (not exactly) as

\dot u = \min_w f(u,w)

Naturally, I would like use some previous value of \dot u as the starting point for the optimization problem on the r.h.s. — I might even like to store some additional data from the previous minimization (such as the solution of a dual problem) to speed up the optimization.

What’s the best way to do this? And can I rely on du being unchanged during calls to my r.h.s. function (in solve from DifferentialEquations.jl)?

EDIT: The minimization is subject to some constraints, so this is not entirely trivial.

You can cache such stuff in the “parameters”, and use a discrete callback to pullback history if you also have a step cache.

1 Like