AdjointSensitivityIntegrand(sol, adj_sol, sensealg, dgdp) is the
integrand of the parameter gradient of QuadratureAdjoint(): a function
of t returning lambda(t)' f_p(u(t), p, t) + dgdp(u(t), p, t), with
u from the dense forward solution sol and lambda the adjoint state
interpolated from the backward solution adj_sol (the first length(u0)
components; for a DAEAdjointProblem() solution the multiplier block, and
the integrand is then dgdp - lambda' F_p of the residual F). Its
integral from t0 to T is the gradient dp of
adjoint_sensitivities().
Usage
AdjointSensitivityIntegrand(
sol,
adj_sol,
sensealg = QuadratureAdjoint(),
dgdp = NULL
)Arguments
- sol
The forward solution (dense).
- adj_sol
The solution of the backward adjoint problem.
- sensealg
An adjoint method,
QuadratureAdjoint()by default.- dgdp
NULLor a function(u, p, t)returning the gradient of the continuous cost with respect to the parameters.
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)
ap <- ODEAdjointProblem(sol, QuadratureAdjoint(), Tsit5(), t = 1,
dgdu_discrete = function(u, p, t, i) 1)
adj <- solve(ap, Tsit5(), reltol = 1e-10, abstol = 1e-12)
integrand <- AdjointSensitivityIntegrand(sol, adj)
integrand(0.5) # lambda(0.5) * (-u(0.5))
#> [1] -0.1353353