Skip to content

ODELocalSensitvityFunction is incompatible with algorithm internal autodiff #35

@aarmey

Description

@aarmey

As exemplified in the following code, using ODELocalSensitivityProblem results in errors about missing fields that are present in ODEFunction. This code does run if switched to the ODEProblem counterpart.

using DifferentialEquations

function lorenz!(du, u, p, t)
 du[1] = p[1]*(u[2]-u[1])
 du[2] = u[1]*(p[2]-u[3]) - u[2]
 du[3] = u[1]*u[2] - p[3]*u[3]
end

u0 = [1.0;0.0;0.0]
tspan = (0.0, 100.0)
params = [10.0, 28.0, 8.0/3.0]

probS = ODELocalSensitivityProblem(lorenz!, u0, tspan, params)
prob = ODEProblem(lorenz!, u0, tspan, params)

sol = solve(probS, Rodas4())

print(sol)

Gives:

ERROR: LoadError: type ODELocalSensitvityFunction has no field tgrad
Stacktrace:
 [1] getproperty(::Any, ::Symbol) at ./sysimg.jl:18
 [2] has_tgrad(::ODELocalSensitvityFunction{true,ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Nothing,Nothing,Nothing,DiffEqDiffTools.UJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Tuple{Array{ForwardDiff.Dual{:___jac_tag,Float64,1},1},Array{ForwardDiff.Dual{:___jac_tag,Float64,1},1}},ForwardDiff.JacobianConfig{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3},1}}},SensitivityAlg{0,true,DataType,true},Array{Float64,1},Nothing,Array{Float64,2},LinearAlgebra.UniformScaling{Bool}}) at /Users/asm/.julia/packages/DiffEqBase/8usQ9/src/diffeqfunction.jl:473
 [3] build_grad_config(::Rodas4{0,true,LinSolveFactorize{typeof(LinearAlgebra.lu!)},DataType}, ::Function, ::Function, ::Array{Float64,1}, ::Float64) at /Users/asm/.julia/packages/OrdinaryDiffEq/7mKtS/src/derivative_wrappers.jl:70
 [4] alg_cache(::Rodas4{0,true,LinSolveFactorize{typeof(LinearAlgebra.lu!)},DataType}, ::Array{Float64,1}, ::Array{Float64,1}, ::Type, ::Type, ::Type, ::Array{Float64,1}, ::Array{Float64,1}, ::ODELocalSensitvityFunction{true,ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Nothing,Nothing,Nothing,DiffEqDiffTools.UJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Tuple{Array{ForwardDiff.Dual{:___jac_tag,Float64,1},1},Array{ForwardDiff.Dual{:___jac_tag,Float64,1},1}},ForwardDiff.JacobianConfig{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3,Tuple{Array{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3},1},Array{ForwardDiff.Dual{ForwardDiff.Tag{DiffEqDiffTools.ParamJacobianWrapper{ODEFunction{true,typeof(lorenz!),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Float64,Array{Float64,1}},Float64},Float64,3},1}}},SensitivityAlg{0,true,DataType,true},Array{Float64,1},Nothing,Array{Float64,2},LinearAlgebra.UniformScaling{Bool}}, ::Float64, ::Float64, ::Float64, ::Array{Float64,1}, ::Bool, ::Type{Val{true}}) at /Users/asm/.julia/packages/OrdinaryDiffEq/7mKtS/src/caches/rosenbrock_caches.jl:630
...

My actual problem is stiff and compatible with autodiff, but not ParameterizedFunctions, hence not using the macros available there. Thanks for putting together such an amazing set of tools!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions