SundialsAdjoint() names the adjoint of SciMLSensitivity that runs the
CVODES (and IDAS) adjoint: the forward solve is checkpointed, the adjoint
state and the parameter gradient are integrated backward together, with
the forward state interpolated between checkpoints. In R it is that same
method, InterpolatingAdjoint() with checkpointing = TRUE, solved with
the backward algorithm given to adjoint_sensitivities() (the forward
algorithm by default). The SUNDIALS options are kept for the Julia
signature.
Usage
SundialsAdjoint(
chunk_size = 0,
autodiff = TRUE,
diff_type = "central",
autojacvec = NULL,
steps = 150,
interp = "hermite",
quad_error_control = TRUE
)Arguments
- chunk_size, autodiff, diff_type
Options of the Julia signature.
- autojacvec
As for
InterpolatingAdjoint().- steps
Forward steps between checkpoints of CVODES (unused: the checkpoints are the saved times).
- interp
"hermite"or"polynomial", the CVODES interpolation (checked, unused).- quad_error_control
Whether the gradient quadrature is error controlled (it always is here).
Examples
prob <- ODEProblem(function(u, p, t) -p[1] * u, 1, c(0, 1), 2)
sol <- solve(prob, Tsit5(), reltol = 1e-10, abstol = 1e-12)
adjoint_sensitivities(sol, Tsit5(), t = 1, dgdu_discrete = function(u, p, t, i) 1,
sensealg = SundialsAdjoint(), abstol = 1e-10, reltol = 1e-10)$dp
#> [1] -0.1353353