Skip to content

Reversediff with in optimization problem #2968

Open
@mmbosschaert

Description

@mmbosschaert

Question❓

If I change the differentiation method in the optimization example in Optimizing through an ODE solve and re-creating MTK Problems to AutoReverseDiff() I obtain the following error when solving the problem:

julia> sol = solve(optprob, BFGS())
ERROR: ForwardDiffSensitivity assumes the `AbstractArray` interface for `p`. Thus while
DifferentialEquations.jl can support any parameter struct type, usage
with ForwardDiffSensitivity requires that `p` could be a valid
type for being the initial condition `u0` of an array. This means that
many simple types, such as `Tuple`s and `NamedTuple`s, will work as
parameters in normal contexts but will fail during ForwardDiffSensitivity
construction. To work around this issue for complicated cases like nested structs,
look into defining `p` using `AbstractArray` libraries such as RecursiveArrayTools.jl
or ComponentArrays.jl.

Stacktrace:
  [1] _concrete_solve_adjoint(::ODEProblem{…}, ::CompositeAlgorithm{…}, ::ForwardDiffSensitivity{…}, ::Vector{…}, ::ModelingToolkit.MTKParameters{…}, ::SciMLBase.Cha
inRulesOriginator; saveat::StepRangeLen{…}, kwargs::@Kwargs{…})
    @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/PstNN/src/concrete_solve.jl:772
  [2] _concrete_solve_adjoint(::ODEProblem{…}, ::CompositeAlgorithm{…}, ::Nothing, ::Vector{…}, ::ModelingToolkit.MTKParameters{…}, ::SciMLBase.ChainRulesOriginator;
 verbose::Bool, kwargs::@Kwargs{…})
    @ SciMLSensitivity ~/.julia/packages/SciMLSensitivity/PstNN/src/concrete_solve.jl:270
...

This has to do with changing the parameter values of the ODE problem using Tunable() and remake.

Is there a way to use reverse differentiation in this case?

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions