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

Dual number cache for use with ForwardDiff.jl #243

Open
ctessum opened this issue Aug 5, 2024 · 2 comments
Open

Dual number cache for use with ForwardDiff.jl #243

ctessum opened this issue Aug 5, 2024 · 2 comments

Comments

@ctessum
Copy link

ctessum commented Aug 5, 2024

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

The problem is described here: https://discourse.julialang.org/t/how-to-use-scimloperators-jl-with-autograd-in-differentialequations-jl/117731

Describe the solution you’d like

I would like to be able to use SciMLOperators in an in-place ODEFunction, with a solver that does autodiff using ForwardDiff.jl. Here is an example:

using SciMLOperators, DifferentialEquations

op = FunctionOperator((du,u,p,t) -> du .= u .* u, rand(10), t=0.0, p=[0.0], batch=true)
op = cache_operator(op, rand(10))

prob = ODEProblem{true}(op, rand(10), (0.0,1.0), [0.0])

solve(prob, Rosenbrock23())

Currently, the above code doesn't work, presumably owing to the operator cache being Float64s rather than dual numbers.

@vpuri3
Copy link
Member

vpuri3 commented Aug 5, 2024

trying calling cache_operator with a dual array

@ChrisRackauckas
Copy link
Member

The cache in this case would need to be a PreallocationTools.DualCache object so it could dispatch to different forms on command. That's definitely possible.

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

3 participants