ForwardLSSProblem(sol, ForwardLSS(g = g)) and AdjointLSSProblem(sol, AdjointLSS(g = g)) set up least squares shadowing on the saved points of
a solution sol on the attractor; shadow_forward() and
shadow_adjoint() return the derivative of the long time average of
g(u, p, t) with respect to the parameters. NILSSProblem(prob, NILSS(nseg, nstep, g = g)) and NILSASProblem(sol, NILSAS(nseg, nstep, M, g = g), alg) are the non intrusive forward and adjoint versions; they
integrate tangent (or adjoint) solutions over nseg segments with
nstep saved points each, so the cost scales with the number of unstable
directions instead of the number of states.
Usage
ForwardLSSProblem(
sol,
sensealg = ForwardLSS(),
t = NULL,
dgdu_discrete = NULL,
dgdp_discrete = NULL,
dgdu_continuous = NULL,
dgdp_continuous = NULL,
g = sensealg$g
)
AdjointLSSProblem(
sol,
sensealg = AdjointLSS(),
t = NULL,
dgdu_discrete = NULL,
dgdp_discrete = NULL,
dgdu_continuous = NULL,
dgdp_continuous = NULL,
g = sensealg$g
)
shadow_forward(lssprob, alg = NULL, ...)
shadow_adjoint(lssprob, alg = NULL, ...)
NILSSProblem(
prob,
sensealg,
t = NULL,
dgdu_discrete = NULL,
dgdp_discrete = NULL,
dgdu_continuous = NULL,
dgdp_continuous = NULL,
g = sensealg$g
)
NILSASProblem(
sol,
sensealg,
alg = NULL,
t = NULL,
dgdu_discrete = NULL,
dgdp_discrete = NULL,
dgdu_continuous = NULL,
dgdp_continuous = NULL,
g = sensealg$g,
...
)Arguments
- sol
A solution on the attractor (
saveatgives the time grid of LSS); forNILSASProblemit must be dense.- sensealg
The shadowing algorithm, see shadowing_algorithms.
- t, dgdu_discrete, dgdp_discrete, dgdu_continuous, dgdp_continuous
Gradients of the objective (see Details).
- g
The objective; by default
sensealg$g.- lssprob
A problem from
ForwardLSSProblem(),NILSSProblem(),AdjointLSSProblem()orNILSASProblem().- alg
ODE algorithm for the segment solves of NILSS and NILSAS.
- ...
Options for the segment solves (
solve()).- prob
An
ODEProblemwhose initial value is on the attractor.
Value
A problem object; shadow_forward() and shadow_adjoint()
return the gradient with respect to the parameters.
Details
The objective's gradients are taken by finite differences of g unless
given: dgdu_continuous(u, p, t) and dgdp_continuous(u, p, t), or
with t = sol$t the discrete forms dgdu_discrete(u, p, t, i) and
dgdp_discrete(u, p, t, i).
Examples
lorenz <- function(u, p, t) c(10 * (u[2] - u[1]), u[1] * (p[1] - u[3]) - u[2],
u[1] * u[2] - 8 / 3 * u[3])
prob <- ODEProblem(lorenz, c(-2.26, -2.47, 18.94), c(0, 5), 28)
sol <- solve(prob, Tsit5(), saveat = 0.01, reltol = 1e-8, abstol = 1e-8)
g <- function(u, p, t) u[3]
shadow_forward(ForwardLSSProblem(sol, ForwardLSS(g = g)))
#> [1] 0.9718374