Sensitivity Algorithms for Nonlinear Problems with Automatic Differentiation (AD)
DiffEqSensitivity.SteadyStateAdjoint
— TypeSteadyStateAdjoint{CS,AD,FDT,VJP,LS} <: AbstractAdjointSensitivityAlgorithm{CS,AD,FDT}
An implementation of the adjoint differentiation of a nonlinear solve. Uses the implicit function theorem to directly compute the derivative of the solution to $f(u,p) = 0$ with respect to p
.
Constructor
SteadyStateAdjoint(;chunk_size = 0, autodiff = true,
diff_type = Val{:central},
autojacvec = autodiff, linsolve = nothing)
Keyword Arguments
autodiff
: Use automatic differentiation for constructing the Jacobian if the Jacobian needs to be constructed. Defaults totrue
.chunk_size
: Chunk size for forward-mode differentiation if full Jacobians are built (autojacvec=false
andautodiff=true
). Default is0
for automatic choice of chunk size.diff_type
: The method used by FiniteDiff.jl for constructing the Jacobian if the full Jacobian is required withautodiff=false
.autojacvec
: Calculate the vector-Jacobian product (J'*v
) via automatic differentiation with special seeding. The default isnothing
. The total set of choices are:false
: the Jacobian is constructed via FiniteDiff.jltrue
: the Jacobian is constructed via ForwardDiff.jlTrackerVJP
: Uses Tracker.jl for the vjp.ZygoteVJP
: Uses Zygote.jl for the vjp.EnzymeVJP
: Uses Enzyme.jl for the vjp.ReverseDiffVJP(compile=false)
: Uses ReverseDiff.jl for the vjp.compile
is a boolean for whether to precompile the tape, which should only be done if there are no branches (if
orwhile
statements) in thef
function.
linsolve
: the linear solver used in the adjoint solve. Defaults tonothing
, which uses a polyalgorithm to attempt to automatically choose an efficient algorithm.
For more details on the vjp choices, please consult the sensitivity algorithms documentation page or the docstrings of the vjp types.
References
Johnson, S. G., Notes on Adjoint Methods for 18.336, Online at http://math.mit.edu/stevenj/18.336/adjoint.pdf (2007)