R6 wrapper for the Lorenz ODE solver.
Methods
Lorenz_Solver$new()
Initialize a solver for a Lorenz system. The solver takes
its own copy of the system as it is at this moment and steps that copy:
set_params() or set_state() on the LorenzSystem
afterwards do not reach the solver. Use the solver's own
$set_params() and $set_state().
Usage
Lorenz_Solver$new(System_xp, control_xp, method = "rkck")Arguments
System_xpExternal pointer to the Lorenz system object.
control_xpExternal pointer to the ODE control object.
methodIntegration method:
"rkck"(default, explicit Cash-Karp RK 4(5)),"dopri"(explicit Dormand-Prince 5(4)),"rodas"(implicit RODAS4(3) Rosenbrock, for stiff systems) or"ros34pw2"(Rosenbrock-W of order 3, which keeps its Jacobian across steps and cannot be differentiated).
Lorenz_Solver$set_params()
Set the parameters this solver steps with, and re-seed it
at its current state and time as $set_state() would. Call
$reset() as well to start again from the initial state.
Lorenz_Solver$set_target()
Set the calibration target for
$loss_and_gradient().
Arguments
scheduleNumeric vector: the step times
$loss_and_gradient()replays, one entry per step. Normally a reference run's$times(), so each evaluation takes the same steps and the loss is a smooth function of the inputs.targetNumeric matrix of observed states, one row per entry of
obs_indicesand one column per state variable.obs_indicesInteger indices (1-based) into
scheduleat which each row oftargetwas observed.
Lorenz_Solver$loss_and_gradient()
Least-squares loss against the target, and its exact
gradient by automatic differentiation. The schedule is stepped under
this solver's method.
Arguments
initial_stateInitial state to evaluate at, or
NULLto keep the system's.paramsParameters to evaluate at, or
NULLto keep the system's.mode"reverse": one reverse sweep, whose cost does not grow with the number of inputs."forward": the schedule walked again carrying one direction per input, whose cost does; it is the only mode under"rodas", which cannot be swept.NULL(the default) is"forward"for a"rodas"solver and"reverse"otherwise. A"ros34pw2"solver is refused in either mode.
Lorenz_Solver$sensitivities()
The state at each of times and its derivative with
respect to the parameters and to the state at times[1], by
forward-mode automatic differentiation. The solve starts from where
this solver stands, with its step size afresh, and lands a step on
every time; the solver itself does not move. Those steps are then walked again carrying one direction per
input, under the solver's own method, "rodas" included;
a "ros34pw2" solver is refused.
The cost grows with the number of inputs and not with the number of
times.
Arguments
timesNumeric vector of requested output times.
parametersThe parameters to differentiate with respect to:
TRUE(all),FALSE(none), or names ("sigma","R","b") or indices.initialThe components of the state at
times[1]to differentiate with respect to:TRUE,FALSE, or names ("x","y","z") or indices.