aquakin.implicit_euler_adjoint_solve#
- aquakin.implicit_euler_adjoint_solve(rhs, y0, params, t_span, t_eval=None, *, rtol=1e-06, atol=1e-09, dt0=1e-06, max_steps=200000, time_dependent=False, primal_rhs=None)[source]#
Integrate over
t_spanwith a cap-free discrete-adjoint reverse-mode rule.The forward pass is a robust adaptive implicit-Euler diffrax solve. The custom VJP is the exact discrete adjoint of that solve, evaluated by a backward scan of bounded transposed linear solves – finite for stiff models at any step size, with no
dtmaxcap. The first-orders=1special case ofesdirk_adjoint_solve(); both share the_discrete_adjoint_solve()harness.- Parameters:
rhs (callable) – Vector field
rhs(t, y, params) -> dy(the reactor RHS), differentiable inyandparams.y0 (jnp.ndarray) – Initial state, shape
(n,).params (jnp.ndarray) – Parameter vector, shape
(n_params,).t_span (tuple of float) –
(t0, t1)integration interval.t_eval (jnp.ndarray, optional) – Observation times at which to return the state. Must be strictly ascending and lie in
(t0, t1](a time equal tot0returnsy0). The forward is forced to step exactly onto these times so the adjoint is exact.None(default) returns only the final state.rtol (float) – Forward-solve tolerances (the adaptive controller meets these; the adjoint is exact for whatever step sequence results).
atol (float) – Forward-solve tolerances (the adaptive controller meets these; the adjoint is exact for whatever step sequence results).
dt0 (float) – Initial step.
max_steps (int) – Maximum number of accepted steps (also the size of the saved trajectory the backward scan walks).
time_dependent (bool, optional) – If
False(default) the right-hand side is assumed autonomous, as the reaction RHS is for fixed conditions. IfTruethe field’s explicit time dependence (e.g. a time-varying influent) is handled exactly by carrying time in the state, so the gradient is exact through a transient solve. See_autonomize().primal_rhs (callable, optional) – Fast alternate RHS for the forward solve and the
df/dyJacobian, whilerhssupplies thedf/dthetavjp. Seeesdirk_adjoint_solve()for the full contract (it must matchrhsin value anddf/dy; only the parameter derivative is taken fromrhs;stop_gradientanyparams-derived value closed over).Noneusesrhsthroughout.
- Returns:
If
t_eval is None, the final statey(t1), shape(n,). Otherwise the states att_eval, shape(len(t_eval), n). Either way the result carries the discrete-adjoint VJP w.r.t.y0andparams.- Return type:
jnp.ndarray