slsqp_jax.inner.hr_stcg

HRInexactSTCG — Heinkenschloss-Ridzal (2014) Algorithm 4.5 Steihaug-Toint CG composed with another inner solver’s projector, robust to inexact W̃_k.

slsqp_jax.inner.hr_stcg

Heinkenschloss-Ridzal (2014) Algorithm 4.5 — STCG with inexact projections.

class slsqp_jax.inner.hr_stcg.HRInexactSTCG[source]

Bases: AbstractInnerSolver

Heinkenschloss-Ridzal (2014) Algorithm 4.5 — STCG with inexact null-space projections.

Composes an existing null-space inner solver (ProjectedCGCholesky or ProjectedCGCraig) to obtain its projector W̃_k, particular solution d_p and multiplier-recovery closure, then runs a separate CG iteration on top whose three textbook three-term-recurrence cancellations are replaced by full H-conjugacy reorthogonalisation against every previous search direction.

See AGENTS.md (“Pluggable Inner QP Solvers” → HRInexactSTCG) for the full algorithmic discussion and references.

Attributes:
inner: Composed null-space inner solver supplying the

projector and multiplier-recovery infrastructure. Must implement build_projection_context; the saddle-point MinresQLPSolver does not and will raise on the first solve call.

max_cg_iter: Static upper bound on the number of inner CG

iterations. Determines the size of the reorth buffers.

cg_tol: Relative convergence tolerance for the projected

residual ‖z̃_i‖ tol · ‖r̃_0‖.

cg_regularization: Curvature-guard threshold δ² used by

the SNOPT-style scale-invariant short-circuit ⟨p̃, H p̃⟩ δ² ‖p̃‖². Defaults to 1e-6; set to 0.0 to disable.

inner: AbstractInnerSolver
max_cg_iter: int
cg_tol: Float[Array, ''] | float
cg_regularization: float = 1e-06
build_projection_context(hvp_fn, g, A, b, active_mask, precond_fn=None, free_mask=None, d_fixed=None)[source]

Build a reusable projector + multiplier-recovery context.

Composed strategies (e.g. HRInexactSTCG) call this on the underlying inner solver to obtain its null-space projector, particular solution and multiplier-recovery closure without running the projector’s own CG loop.

The default implementation raises NotImplementedError so full-KKT solvers (MinresQLPSolver) cleanly opt out — they have no separate projection step and therefore cannot supply the inexact-projector W̃_k that HR Algorithm 4.5 needs.

Return type:

ProjectionContext

Parameters:
  • hvp_fn (Callable[[Float[Array, 'n']], Float[Array, 'n']])

  • g (Float[Array, 'n'])

  • A (Float[Array, 'm n'])

  • b (Float[Array, 'm'])

  • active_mask (Bool[Array, 'm'])

  • precond_fn (Callable[[Float[Array, 'n']], Float[Array, 'n']] | None)

  • free_mask (Bool[Array, 'n'] | None)

  • d_fixed (Float[Array, 'n'] | None)

solve(hvp_fn, g, A, b, active_mask, precond_fn=None, free_mask=None, d_fixed=None, adaptive_tol=None)[source]

Solve the equality-constrained QP subproblem.

Solves:

minimize    (1/2) d^T B d + g^T d
subject to  A[active] d = b[active]
            d[i] = d_fixed[i]  for i where free_mask[i] is False

where B is given implicitly via hvp_fn(v) = B @ v.

Return type:

InnerSolveResult

Parameters:
  • hvp_fn (Callable[[Float[Array, 'n']], Float[Array, 'n']])

  • g (Float[Array, 'n'])

  • A (Float[Array, 'm n'])

  • b (Float[Array, 'm'])

  • active_mask (Bool[Array, 'm'])

  • precond_fn (Callable[[Float[Array, 'n']], Float[Array, 'n']] | None)

  • free_mask (Bool[Array, 'n'] | None)

  • d_fixed (Float[Array, 'n'] | None)

  • adaptive_tol (Float[Array, ''] | float | None)

Args:

hvp_fn: Hessian-vector product function v -> B @ v. g: Linear term (gradient of objective). A: Combined constraint matrix (m x n). b: Combined RHS vector (m,). active_mask: Boolean mask (m,) indicating active constraints. precond_fn: Optional preconditioner v -> M @ v where M ~ B^{-1}. free_mask: Optional boolean mask (n,). When provided, only

variables with free_mask[i] = True are optimized.

d_fixed: Values for fixed variables (n,). Required when

free_mask is provided.

adaptive_tol: Optional Eisenstat-Walker tolerance override.

When provided, overrides the solver’s default convergence tolerance for this call only.

Returns:

InnerSolveResult with the direction, multipliers, and convergence flag.

__init__(inner, max_cg_iter, cg_tol, cg_regularization=1e-06)
Parameters:
Return type:

None