slsqp_jax.slsqp.derivatives¶
Closure factories that build (grad, jac, hvp_contrib) from the user-supplied callables or default to JAX’s reverse-mode AD.
slsqp_jax.slsqp.derivatives
Gradient / Jacobian / HVP closure factories.
Centralises the dispatch between user-supplied derivative callables and the AD fallbacks so the SLSQP class can remain agnostic to which side provided each derivative.
Two helpers are public:
build_jacobian_impl()— returns a closure(y, args) -> Jfor a single constraint slot, parameterised by the user-supplieduser_jac(orNone) and the user-supplied constraint function.build_hvp_contrib_impl()— returns a closure(y, v, args, multipliers) -> Σ μ_i H_{c_i} vfor a single constraint slot, parameterised analogously.
The single-constraint-slot helpers eliminate the EQ/INEQ duplication
in the legacy __check_init__: each side calls the same factory
with its own slot’s user-supplied callables and m_constraints.
- slsqp_jax.slsqp.derivatives.build_grad_impl(user_grad_fn)[source]¶
Closure
(fn, y, args) -> ∇f(y)dispatching to user / AD.
- slsqp_jax.slsqp.derivatives.build_hvp_contrib_impl(*, user_hvp, constraint_fn, n_constraints)[source]¶
Closure
(y, v, args, μ) -> Σ μ_i H_{c_i}(y) vfor one slot.Mirrors
build_jacobian_impl(): dispatches between user-supplieduser_hvp, AD viajvp(grad(weighted)), or a zero-vector fallback.
- slsqp_jax.slsqp.derivatives.build_jacobian_impl(*, user_jac, constraint_fn, n_constraints)[source]¶
Closure
(y, args) -> J(y)for one constraint slot.Returns a zero-Jacobian closure when no constraint function is supplied or the slot is empty (
n_constraints == 0).
- slsqp_jax.slsqp.derivatives.build_obj_hvp_impl(*, user_obj_hvp, use_exact_hvp_in_qp)[source]¶
Optional
(fn, y, v, args) -> H_f vclosure.Returns
Nonewhen no exact HVP source is available and Newton-CG is disabled, mirroring the legacyself._obj_hvp_impl is Nonesentinel used instep()to decide whether to probe the Hessian for the L-BFGS secant pair.