slsqp_jax.inner.masking¶
Shared make_active_subproblem helper that masks (A, b, hvp_fn, g) down to the active rows / free variables — used identically by every inner solver.
slsqp_jax.inner.masking
Shared active-row masking + bound-fix helper for inner solvers.
The three projector-based inner solvers (ProjectedCGCholesky,
ProjectedCGCraig, MinresQLPSolver) all start from the same
five-line preamble: mask A and b to the active rows, optionally
project away the bound-fixed columns, and build a working HVP and
effective gradient that hide the fixed coordinates from the iteration.
Before this module that preamble was copy-pasted in three places. This module hosts the single shared implementation.
- class slsqp_jax.inner.masking.ActiveSubproblem[source]¶
Bases:
NamedTupleData carried by every projector-based inner solver after masking.
- Attributes:
- A_work:
Awith inactive rows zeroed and (when bound-fixing is in effect) fixed columns zeroed.
- b_work:
bwith inactive entries zeroed and the fixed-column contribution
A_masked @ d_fixedsubtracted.- free_mask: Boolean mask of free variables (
ones(n)when no bound fixing).
- d_fixed: Fixed-variable values on bound-active coordinates
(zeros elsewhere; zeros everywhere when no bound fixing).
has_fixed:
Trueiff any coordinate is bound-fixed. hvp_work: Working-subspace HVP. Equalshvp_fnwhen nobound-fixing; otherwise
v -> _free * hvp_fn(_free * v)so the iteration only sees the free coordinates.- g_eff: Effective gradient. Equals
gwhen no bound-fixing; otherwise
_free * (g + hvp_fn(d_fixed))to absorb the fixed-column cross-coupling into the linear term.
- A_work:
- A_work: Float[Array, 'm n']¶
Alias for field number 0
- b_work: Float[Array, 'm']¶
Alias for field number 1
- free_mask: Bool[Array, 'n']¶
Alias for field number 2
- d_fixed: Float[Array, 'n']¶
Alias for field number 3
- g_eff: Float[Array, 'n']¶
Alias for field number 6
- slsqp_jax.inner.masking.make_active_subproblem(hvp_fn, g, A, b, active_mask, free_mask=None, d_fixed=None)[source]¶
Build the masked subproblem consumed by every projector-based solver.
Implements the shared preamble:
A_masked = Awith inactive rows zeroed.b_masked = bwith inactive entries zeroed.If bound-fixing is in effect (
free_maskandd_fixedboth provided), zero the fixed columns ofA_maskedand absorb the fixed-column contribution intob_work.Build
hvp_workandg_effso the iteration only sees the free coordinates.
See
ActiveSubproblemfor the field semantics.- Return type:
- 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'])
free_mask (Bool[Array, 'n'] | None)
d_fixed (Float[Array, 'n'] | None)