Expand description
Gradient trait and adapters (Analytic / FiniteDiff) plus
DifferentiableObjective. “Native” gradients when the caller can
supply them (Ceres-style); explicit central differences otherwise.
Gradient<T> and DifferentiableObjective<T>: first-derivative support
for the typed Obj algebra.
This is the “native gradient” path, modeled on how Ceres accepts analytic
derivatives: when a caller (HMC, projected-gradient polish, GLE with
optimal drift, NEB/saddle search in sibling crates, …) can supply a
true derivative it is used directly; otherwise an explicit
FiniteDiffGradient adapter falls back to central differences (costing
2·dim extra objective evaluations per gradient).
The separation (value-only Objective vs. Gradient provider) mirrors
Stan’s log-density / gradient split and Ceres’ residual + optional
Jacobian in a single Evaluate. A type can implement both (via
DifferentiableObjective) and supply an efficient fused
value_and_gradient to avoid redundant work.
Surrogates (ChebyshevSurrogate, AdditiveSurrogate, ReducedObjective)
implement the traits analytically where possible. Built-in test
objectives ship with closed-form gradients. Python callables can
provide a matching grad_fn at construction time of PyObjective.
Structs§
- Analytic
Gradient - Closure-based analytic gradient (the common case for user Rust code
that has a hand-derived or AD-produced
x |-> ∇f(x)). - Finite
Diff Gradient - Central-difference adapter around any
Objective<f64>. Use only when no native gradient is available.
Traits§
- Differentiable
Objective - An
Objectivethat can also supply its gradient (natively or via adapter). - Gradient
- First-derivative interface. Types that know an analytic gradient
implement this directly (or via
DifferentiableObjective).