AutoDiff
Variables
ExaPF.AutoDiff.AbstractStack — Type
AbstractStack{VT}Abstract variable storing the inputs and the intermediate values in the expression tree.
Expressions
ExaPF.AutoDiff.AbstractExpression — Type
AbstractExpressionAbstract type for differentiable function $f(x)$. Any AbstractExpression implements two functions: a forward mode to evaluate $f(x)$, and an adjoint to evaluate $∂f(x)$.
Forward mode
The direct evaluation of the function $f$ is implemented as
(expr::AbstractExpression)(output::VT, stack::AbstractStack{VT}) where VT<:AbstractArray
the input being specified in stack, the results being stored in the array output.
Reverse mode
The adjoint of the function is specified by the function adjoint!, with the signature:
adjoint!(expr::AbstractExpression, ∂stack::AbstractStack{VT}, stack::AbstractStack{VT}, ̄v::VT) where VT<:AbstractArray
The variable stack stores the result of the direct evaluation, and is not modified in adjoint!. The results are stored inside the adjoint stack ∂stack.
ExaPF.AutoDiff.adjoint! — Function
adjoint!(expr::AbstractExpression, ∂stack::AbstractStack{VT}, stack::AbstractStack{VT}, ̄v::VT) where VT<:AbstractArrayCompute the adjoint of the AbstractExpression expr with relation to the adjoint vector ̄v. The results are stored in the adjoint stack ∂stack. The variable stack stores the result of a previous direct evaluation, and is not modified in adjoint!.
First and second-order derivatives
ExaPF.AutoDiff.AbstractJacobian — Type
AbstractJacobianAutomatic differentiation for the compressed Jacobian of any nonlinear constraint $h(x)$.
ExaPF.AutoDiff.AbstractHessianProd — Type
AbstractHessianProdReturns the adjoint-Hessian-vector product $λ^⊤ H v$ of any nonlinear constraint $h(x)$.
ExaPF.AutoDiff.AbstractFullHessian — Type
AbstractHessianProdFull sparse Hessian $H$ of any nonlinear constraint $h(x)$.
Utils
ExaPF.AutoDiff.seed! — Function
seed!(
H::AbstractHessianProd,
v::AbstractVector{T},
) where {T}Seed the duals with v to compute the Hessian vector product $λ^⊤ H v$.
ExaPF.AutoDiff.seed_coloring! — Function
seed_coloring!(
M::Union{AbstractJacobian, AbstractFullHessian}
coloring::AbstractVector,
)Seed the duals with the coloring based seeds to compute the Jacobian or Hessian $M$.
ExaPF.AutoDiff.partials! — Function
partials!(jac::AbstractJacobian)Extract partials from Jacobian jac in jac.J.
partials!(hess::AbstractFullHessian)Extract partials from Hessian hess into hess.H.
ExaPF.AutoDiff.set_value! — Function
set_value!(
jac,
primals::AbstractVector{T}
) where {T}Set values of ForwardDiff.Dual numbers in jac to primals.