slsqp_jax.qp.api

Thin solve_qp router dispatching to the proximal / direct / inequality strategies.

slsqp_jax.qp.api

Thin solve_qp() router dispatching to the three QP strategies.

The legacy solve_qp did three things at once: routed to the proximal or direct equality strategy, inlined the inequality-only strategy, and constructed a default ProjectedCGCholesky when none was provided. This module reduces it to the routing table and the default-inner-solver construction.

slsqp_jax.qp.api.solve_qp(hvp_fn, g, A_eq, b_eq, A_ineq, b_ineq, max_iter=100, max_cg_iter=50, tol=1e-08, expand_factor=1.0, initial_active_set=None, kkt_residual=0.0, proximal_mu=0.0, prev_multipliers_eq=None, precond_fn=None, cg_tol=None, cg_regularization=1e-06, use_proximal=True, predicted_active_set=None, active_set_method='expand', use_constraint_preconditioner=False, inner_solver=None, mult_drop_floor=1e-06, ping_pong_threshold=2147483647)[source]

Solve a QP with equality and inequality constraints.

Solves:

minimize    (1/2) d^T H d + g^T d
subject to  A_eq d = b_eq
            A_ineq d >= b_ineq

where H is provided implicitly via hvp_fn(v) = H @ v.

The QP active-set loop dispatches to one of three strategies:

  • Proximal sSQP (m_eq > 0 and use_proximal=True): equality constraints absorbed into the objective via augmented-Lagrangian penalty. See slsqp_jax.qp.proximal.

  • Direct projection (m_eq > 0 and use_proximal=False): equality constraints enforced via null-space projection in the inner solver. See slsqp_jax.qp.direct.

  • Inequality-only (m_eq == 0): no equality block; just an active-set loop on inequality constraints. See slsqp_jax.qp.inequality.

All three share the same EXPAND / ping-pong active-set loop body (see slsqp_jax.qp.active_set).

Args:

hvp_fn: Hessian-vector product function v -> H @ v. g: Linear term of the objective (gradient). A_eq: Equality constraint matrix (m_eq x n). b_eq: Equality constraint RHS (m_eq,). A_ineq: Inequality constraint matrix (m_ineq x n). b_ineq: Inequality constraint RHS (m_ineq,). max_iter: Maximum active-set iterations. max_cg_iter: Maximum CG iterations per active-set step. tol: Feasibility and optimality tolerance. expand_factor: EXPAND tolerance growth rate. initial_active_set: Optional warm-start active set from a

previous QP solve.

kkt_residual: Norm of the KKT residual from the outer solver. proximal_mu: Adaptive proximal parameter for sSQP. prev_multipliers_eq: Equality multipliers from the previous

outer iteration (proximal centre).

precond_fn: Optional preconditioner v -> M @ v. cg_tol: Optional CG convergence tolerance overriding tol

for the inner solver only.

cg_regularization: Curvature-guard threshold for CG. use_proximal: When True, equality constraints go through the

sSQP proximal path. When False, direct projection.

predicted_active_set: Optional LPEC-A predicted active set

for warm-start.

active_set_method: "expand", "lpeca_init", or "lpeca". use_constraint_preconditioner: Used only when constructing a

default inner_solver.

inner_solver: Pluggable strategy for the inner equality-

constrained QP solve. Defaults to ProjectedCGCholesky.

mult_drop_floor: Floor on the negative-multiplier drop test. ping_pong_threshold: Threshold for the explicit ping-pong

short-circuit. Defaults to 2**31 - 1 (effectively disabled).

Returns:

QPSolverResult containing the solution, multipliers, active set, and convergence info.

Return type:

QPSolverResult

Parameters:
  • hvp_fn (Callable)

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

  • A_eq (Float[Array, 'm_eq n'])

  • b_eq (Float[Array, 'm_eq'])

  • A_ineq (Float[Array, 'm_ineq n'])

  • b_ineq (Float[Array, 'm_ineq'])

  • max_iter (int)

  • max_cg_iter (int)

  • tol (Float[Array, ''] | float)

  • expand_factor (float)

  • initial_active_set (Bool[Array, 'm_ineq'] | None)

  • kkt_residual (Float[Array, ''] | float)

  • proximal_mu (Float[Array, ''] | float)

  • prev_multipliers_eq (Float[Array, 'm_eq'] | None)

  • precond_fn (Callable | None)

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

  • cg_regularization (float)

  • use_proximal (bool)

  • predicted_active_set (Bool[Array, 'm_ineq'] | None)

  • active_set_method (str)

  • use_constraint_preconditioner (bool)

  • inner_solver (AbstractInnerSolver | None)

  • mult_drop_floor (float)

  • ping_pong_threshold (int)