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

ForwardDiff tag error when computing Jacobian for DAE adjoint #718

Closed
taylormcd opened this issue Aug 24, 2022 · 0 comments
Closed

ForwardDiff tag error when computing Jacobian for DAE adjoint #718

taylormcd opened this issue Aug 24, 2022 · 0 comments

Comments

@taylormcd
Copy link
Contributor

Here's a MWE:

using OrdinaryDiffEq, LinearAlgebra, SciMLSensitivity, Zygote

function f!(du, u, p, t)
    x, y, vx, vy, T = u
    g, L = p
    du[1] = vx
    du[2] = x*T
    du[3] = vy
    du[4] = y*T - g
    du[5] = 2*(vx^2 + vy^2 + y*(y*T - g) + T*x^2)
    return nothing
end

func = ODEFunction(f!, mass_matrix=collect(Diagonal([1,1,1,1,0])))
u0 = [1.0, 0, 0, 0, 0]; p = [9.8, 1]; tspan = (0, 10.0)
prob = ODEProblem(func, u0, tspan, p)
solve(prob,Rodas5())

function sum_of_solution(p)
    _prob = remake(prob,p=p)
    sum(solve(_prob,Rodas5(),saveat=0.1,sensealg=QuadratureAdjoint(autojacvec=false)))
end

dp = Zygote.gradient(sum_of_solution,p)

ERROR: Invalid Tag object:
  Expected ForwardDiff.Tag{SciMLBase.UJacobianWrapper{ODEFunction{true, typeof(f!), Matrix{Int64}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}},
  Observed ForwardDiff.Tag{SciMLBase.UJacobianWrapper{ODEFunction{true, typeof(f!), Matrix{Int64}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Float64, Vector{Float64}}, ForwardDiff.Dual{ForwardDiff.Tag{DiffEqBase.OrdinaryDiffEqTag, Float64}, Float64, 1}}.
taylormcd added a commit to taylormcd/SciMLSensitivity.jl that referenced this issue Aug 24, 2022
ChrisRackauckas added a commit that referenced this issue Aug 30, 2022
fix tag error for fallback case, fixes #718
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