dot-rxAdjoint: Adjoint (backward) sensitivity equations for a model

.rxAdjointR Documentation

Adjoint (backward) sensitivity equations for a model

Description

Symbolically generates the continuous-adjoint ODE system mirroring the forward sensitivity output (.rxSens), reusing the same ⁠rx__sens_<state>_BY_<param>__⁠ output names. For each output state k it emits two backward-in-time blocks: a costate ⁠d/dt(rx__adjLambda_<k>_<i>__) = -(J^T lambda)_i⁠ and a quadrature ⁠d/dt(rx__sens_<k>_BY_<p>__) = -(lambda^T df/dp)_p⁠. The derivatives are taken from the ⁠rx__df_*⁠ symbols .rxJacobian() already materialised, so no new differentiation is done; the costate symbols are registered as bare symengine Symbols.

Usage

.rxAdjoint(model, vars, states)

Arguments

model

symengine model environment (as returned by rxS), with .rxJacobian(model, c(rxStateOde(model), vars)) already called.

vars

character vector of parameter names to differentiate with respect to (the p in dy/dp). Defaults to model$..vars.

states

character vector of output states of interest (the k). Defaults to all ODE states, matching the full coverage of forward sensitivities.

Value

character vector of d/dt(...) = ... lines (costate block followed by quadrature block). The costate (⁠rx__adjLambda_*⁠) lines are internal scaffolding; only the quadrature (⁠rx__sens_*⁠) lines carry user-visible output. Also stashes the result in model$..adjoint.

Author(s)

Matthew L. Fidler


rxode2 documentation built on July 28, 2026, 5:08 p.m.