dot-rxDiscreteAdjointGrad: Discrete adjoint gradient of a trajectory objective

.rxDiscreteAdjointGradR Documentation

Discrete adjoint gradient of a trajectory objective

Description

Given the RK4 stages from .rxDiscreteForwardSens() and, per observation step, the objective covector ⁠c_n = dG/dX_{step_n}⁠, computes dG/dtheta by reverse-mode differentiation through the RK4 steps – equal to ⁠sum_n c_n^T S_{step_n}⁠ to machine precision, in one backward pass.

Usage

.rxDiscreteAdjointGrad(
  build,
  stages,
  params,
  h,
  obsSteps,
  cov,
  doses = NULL,
  lam0Cov = NULL
)

Arguments

build

object from .rxDiscreteAdjointBuild().

stages

RK4 stage list from .rxDiscreteForwardSens().

params

named numeric parameter vector.

h

fixed step size (same as the forward solve).

obsSteps

integer step indices at which observation covectors apply.

cov

list of covector vectors (length ns), aligned with obsSteps.

doses

optional list of additive-bolus dose specs (same format as .rxDiscreteForwardSens()); the exact transpose of the forward dose jump is applied, contributing amt * dF/dtheta * lambda_c to dG/dtheta.

lam0Cov

optional initial-condition sensitivity dX0/dtheta (⁠ns x np⁠) to add the terminal transversality ⁠lambda(t0)^T dX0/dtheta⁠; default none.

Value

named numeric vector dG/dtheta over build$calcSens.

Author(s)

Matthew L. Fidler


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