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

Allow EnsembleProblem to re-use integrator cache #667

Open
PerezHz opened this issue Apr 14, 2024 · 0 comments
Open

Allow EnsembleProblem to re-use integrator cache #667

PerezHz opened this issue Apr 14, 2024 · 0 comments

Comments

@PerezHz
Copy link

PerezHz commented Apr 14, 2024

Is your feature request related to a problem? Please describe.

I'm doing many ODE integrations for different initial conditions in an EnsembleProblem with OrdinaryDiffEq. In this case the integrator cache is re-built every time for every iteration, causing allocations on every iteration, with more allocations for higher-order methods.

Describe the solution you’d like

It would be useful to be able to re-use integrator caches in the iteration of an EnsembleProblem instead of having to construct it every time.

Describe alternatives you’ve considered

As suggested by @ChrisRackauckas on Slack, a workaround is to use the integrator interface, i.e. doing __init then solve! and reinit!, instead of calling solve directly.

Additional context

A simplified example of the requested feature:

using OrdinaryDiffEq
f!(du, u, p, t) = (du .= u)
q0 = [0.2, 0.0, 0.0, 3.0]
prob = ODEProblem(f!, q0, (0.0, pi))
prob_func(prob, i, repeat) = remake(prob; u0 = q0 + 1e-8randn(4))
ensprob = EnsembleProblem(prob; prob_func)
sim = solve(ensprob, Vern9(); trajectories=10) # cache is re-built on every iteration
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

No branches or pull requests

1 participant