SciML / SciMLSensitivity.jl

A component of the DiffEq ecosystem for enabling sensitivity analysis for scientific machine learning (SciML). Optimize-then-discretize, discretize-then-optimize, adjoint methods, and more for ODEs, SDEs, DDEs, DAEs, etc.
https://docs.sciml.ai/SciMLSensitivity/stable/
Other
330 stars 70 forks source link

Adjoints of SteadyStateProblem #182

Closed arnavs closed 4 years ago

arnavs commented 4 years ago

Perhaps because it's a multidimensional problem?

using DiffEqFlux, Flux, DifferentialEquations

z_grid = -5:0.1:5.
v̄(z) = 2*exp(z)
N = length(z_grid)

function f(du, u, p, t)
    v = u[1, :]
    dv = u[2, :]
    du[1, :] .= dv
    du[2, :] .= 2 * (v .- exp.(z_grid)) 
end 

u₀ = zeros(2, N)
prob = ODEProblem(f, u₀, (0., 0.))

function predict_adjoint() # Our 1-layer neural network
    Array(concrete_solve(prob, Tsit5(), u₀, (0., 0.)))[:, :, 1]
end

function loss_adjoint()
    v_sol = predict_adjoint()[1, :]
    return sum(abs2.(v_sol - v̄.(z_grid)))
end

data = Iterators.repeated((), 200)
opt = ADAM(0.1)
Flux.train!(loss_adjoint, Flux.params(u₀), data, opt)

With stack trace

BoundsError: attempt to access 1-element Array{Float64,1} at index [2]

Stacktrace:
 [1] getindex(::Array{Float64,1}, ::Int64) at ./array.jl:744
 [2] ode_interpolation!(::Array{Float64,2}, ::Float64, ::Function, ::Nothing, ::Type, ::Tuple{Float64,Float64}, ::Symbol) at /Users/arnavsood/.julia/packages/OrdinaryDiffEq/6TJck/src/dense/generic_dense.jl:319
 [3] InterpolationData at /Users/arnavsood/.julia/packages/OrdinaryDiffEq/6TJck/src/interp_func.jl:75 [inlined]
 [4] #_#14 at /Users/arnavsood/.julia/packages/DiffEqBase/5h7rF/src/solutions/ode_solutions.jl:19 [inlined]
 [5] ODESolution at /Users/arnavsood/.julia/packages/DiffEqBase/5h7rF/src/solutions/ode_solutions.jl:19 [inlined] (repeats 2 times)
 [6] (::DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing})(::Array{Float64,1}, ::Array{Float64,1}, ::Tuple{Float64,Float64}, ::Float64) at /Users/arnavsood/.julia/packages/DiffEqSensitivity/SESk2/src/local_sensitivity/interpolating_adjoint.jl:57
 [7] ODEFunction at /Users/arnavsood/.julia/packages/DiffEqBase/5h7rF/src/diffeqfunction.jl:219 [inlined]
 [8] initialize!(::OrdinaryDiffEq.ODEIntegrator{Tsit5,true,Array{Float64,1},Float64,Tuple{Float64,Float64},Float64,Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}},Tuple{Symbol},NamedTuple{(:callback,),Tuple{CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}}}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},Float64},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Float64,2}},Bool,Float64,Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Array{Float64,1},Float64,Nothing}, ::OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}) at /Users/arnavsood/.julia/packages/OrdinaryDiffEq/6TJck/src/perform_step/low_order_rk_perform_step.jl:623
arnavs commented 4 years ago

Can also try various formulations (e.g. predict_adjoint() = concrete_solve(...).u[...], or predict_adjoint() = concrete_solve(...) with the stuff in loss_adjoint()) to see different errors.

ChrisRackauckas commented 4 years ago

Please include the stack trace next time.

arnavs commented 4 years ago

Added.

ChrisRackauckas commented 4 years ago

No saveat?

arnavs commented 4 years ago

The problem is stationary (tspan = (0., 0.).) Let's see if it makes a difference.

ChrisRackauckas commented 4 years ago

oh, what does this even mean then?

YingboMa commented 4 years ago

Maybe just gradient(u->loss(f(u, p, t)), u)?

arnavs commented 4 years ago

f(du, u, p, t) is time-independent (e.g., the condition for SteadyStateProblem)... we can change to tspan = (something, something) and pick an arbitrary point to save from, but it doesn't seem to be making a difference.

@YingboMa can you give an example of how we'd use that?

arnavs commented 4 years ago

In the latter case the stacktrace is

MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type Float64
Closest candidates are:
  convert(::Type{Float64}, !Matched::LLVM.ConstantFP) at /Users/arnavsood/.julia/packages/LLVM/DAnFH/src/core/value/constant.jl:85
  convert(::Type{T}, !Matched::T) where T<:Number at number.jl:6
  convert(::Type{T}, !Matched::Number) where T<:Number at number.jl:7
  ...

Stacktrace:
 [1] setindex!(::Array{Float64,1}, ::Array{Float64,2}, ::Int64) at ./array.jl:782
 [2] setindex! at ./subarray.jl:295 [inlined]
 [3] macro expansion at ./broadcast.jl:909 [inlined]
 [4] macro expansion at ./simdloop.jl:77 [inlined]
 [5] copyto! at ./broadcast.jl:908 [inlined]
 [6] copyto! at ./broadcast.jl:863 [inlined]
 [7] materialize! at ./broadcast.jl:822 [inlined]
 [8] (::DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}})(::SubArray{Float64,1,Array{Float64,1},Tuple{UnitRange{Int64}},true}, ::Array{Float64,2}, ::Tuple{Float64,Float64}, ::Float64, ::Int64) at /Users/arnavsood/.julia/packages/DiffEqSensitivity/SESk2/src/local_sensitivity/concrete_solve.jl:65
 [9] (::DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64})(::OrdinaryDiffEq.ODEIntegrator{Tsit5,true,Array{Float64,1},Float64,Tuple{Float64,Float64},Float64,Float64,Float64,Array{Array{Float64,1},1},ODESolution{Float64,2,Array{Array{Float64,1},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,1},1},1},ODEProblem{Array{Float64,1},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Symbol,CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}},Tuple{Symbol},NamedTuple{(:callback,),Tuple{CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}}}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,1},1},Array{Float64,1},Array{Array{Array{Float64,1},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},ODEFunction{true,DiffEqSensitivity.ODEInterpolatingAdjointSensitivityFunction{DiffEqSensitivity.AdjointDiffCache{Nothing,Nothing,Nothing,Nothing,Nothing,Array{Float64,1},Nothing,Nothing,Nothing,Array{Float64,2},Nothing},DiffEqSensitivity.InterpolatingAdjoint{0,true,Val{:central}},Array{Float64,2},ODESolution{Float64,3,Array{Array{Float64,2},1},Nothing,Nothing,Array{Float64,1},Array{Array{Array{Float64,2},1},1},ODEProblem{Array{Float64,2},Tuple{Float64,Float64},true,Tuple{Float64,Float64},ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{,Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{true,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Array{Float64,2},1},Array{Float64,1},Array{Array{Array{Float64,2},1},1},OrdinaryDiffEq.Tsit5Cache{Array{Float64,2},Array{Float64,2},Array{Float64,2},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}}},DiffEqBase.DEStats},Nothing,Nothing},LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5Cache{Array{Float64,1},Array{Float64,1},Array{Float64,1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{DiscreteCallback{DiffEqCallbacks.var"#33#36"{Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}},DiffEqCallbacks.var"#35#38"{typeof(DiffEqBase.INITIALIZE_DEFAULT),Bool,DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},Base.RefValue{Union{Nothing, Float64}},DiffEqCallbacks.var"#34#37"{DiffEqSensitivity.var"#40#42"{Base.RefValue{Int64},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}},DiffEqSensitivity.var"#41#43"{DiffEqSensitivity.var"#df#62"{Array{Union{Nothing, Array{Float64,2}},1}},Bool,StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}},Array{Float64,2},Base.RefValue{Int64},Int64},Base.RefValue{Union{Nothing, Float64}}}}}}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Array{Float64,1},Array{Float64,1},Array{Float64,1}},Array{Float64,1},Float64,Nothing}) at /Users/arnavsood/.julia/packages/DiffEqSensitivity/SESk2/src/local_sensitivity/adjoint_common.jl:84
YingboMa commented 4 years ago

I don't know what are you trying to do. If there is no time span, why are you trying to solve an ODE?

arnavs commented 4 years ago

Because there is an independent variable (think of variation in space)... it's just not time-varying.

ChrisRackauckas commented 4 years ago

Okay, there's a lot going on here buddy. First of all, tspan = (0., 0.). is the exact opposite of a stationary problem. tspan = (0., Inf) is a stationary problem. But secondly, we don't have an adjoint defined on it. The way that we would do it is we would add it to https://github.com/JuliaDiffEq/DiffEqSensitivity.jl/blob/master/src/local_sensitivity/concrete_solve.jl . The steady state problem is just a nonlinear solve for f(u,p,t) = 0, and so its adjoint is defined in these notes:

https://math.mit.edu/~stevenj/18.336/adjoint.pdf

ChrisRackauckas commented 4 years ago

Moving to DiffEqSensitivity

ChrisRackauckas commented 4 years ago

Done