Skip to contents

The backends of ADTypes.jl, for the autodiff arguments of the solvers. Without a Jacobian in the problem, AutoForwardDiff() and every backend that differentiates exactly (AutoZygote(), AutoEnzyme(), AutoReverseDiff(), AutoSymbolics(), ...) differentiate with dual numbers, falling back to forward differences when the residual cannot run on them. AutoFiniteDiff() uses finite differences (forward, central or complex step, with the steps of FiniteDiff.jl) and AutoFiniteDifferences() central differences; the bounded solvers use their bound aware differences for AutoFiniteDiff() itself. NoAutoDiff() selects no differentiation: the bounded solvers (TrustRegionReflective() and the others) signal NoAutoDiffSelectedError() when the problem has no Jacobian; the other solvers fall back to the default.

Usage

AutoChainRules(ruleconfig = NULL)

AutoDiffractor()

AutoEnzyme(mode = NULL, function_annotation = NULL)

AutoReactant(mode = NULL)

AutoFastDifferentiation()

AutoFiniteDifferences(fdm = NULL)

AutoGTPSA(descriptor = NULL)

AutoHyperHessians(chunksize = NULL, simd = FALSE, jet = FALSE)

AutoMooncake(config = NULL)

AutoMooncakeForward(config = NULL)

AutoPolyesterForwardDiff(chunksize = NULL, tag = NULL)

AutoReverseDiff(compile = FALSE)

AutoSymbolics()

AutoTapir(safe_mode = TRUE)

AutoTaylorDiff(order = 1L)

AutoTracker()

AutoZygote()

AutoModelingToolkit(obj_sparse = FALSE, cons_sparse = FALSE)

AutoSparseFastDifferentiation()

AutoSparseFiniteDiff(fdtype = c("forward", "central", "complex"))

AutoSparseForwardDiff(chunksize = NULL, tag = NULL)

AutoSparsePolyesterForwardDiff(chunksize = NULL, tag = NULL)

AutoSparseReverseDiff(compile = FALSE)

AutoSparseZygote()

NoAutoDiff()

NoAutoDiffSelectedError(
  msg = "Automatic differentiation can not be used with NoAutoDiff()"
)

pickchunksize(x, threshold = 12L)

Arguments

ruleconfig, mode, function_annotation, fdm, descriptor, config, chunksize, tag, compile, safe_mode, order, simd, jet

Options of the Julia constructors, stored in the object.

obj_sparse, cons_sparse

Sparsity flags of AutoModelingToolkit().

fdtype

Difference type of AutoSparseFiniteDiff().

msg

The message of the condition.

x

An input length, or a vector.

threshold

The largest chunk size.

Value

An ADType object; NoAutoDiffSelectedError() a condition; pickchunksize() an integer.

Details

The deprecated constructors of ADTypes return their replacements: AutoSparseForwardDiff() is AutoSparse(AutoForwardDiff()) and so on, AutoModelingToolkit() is AutoSymbolics() (sparse when either flag is set) and AutoTapir() is kept for AutoMooncake().

pickchunksize(x) is the chunk size ForwardDiff would use for an input of length x (a single whole number) or of the length of the vector x: the length itself up to 12, otherwise the length divided evenly into chunks of at most 12.

Examples

f <- function(u, p) c(u[1] * u[1] - 2, u[2] - 1)
prob <- NonlinearProblem(f, u0 = c(1, 0), lb = c(0, 0), ub = c(2, 2))
solve(prob, TrustRegionReflective(autodiff = AutoZygote()))$u
#> [1] 1.414214 1.000000
AutoSparseForwardDiff()
#> AutoSparse()
pickchunksize(30)
#> [1] 10
tryCatch(stop(NoAutoDiffSelectedError()), NoAutoDiffSelectedError = conditionMessage)
#> [1] "Automatic differentiation can not be used with NoAutoDiff()"