omnibias.convex.warm_start
Differentiable LP and QP solver paths, barrier methods, KKT sensitivities, and scoped optimality evidence.
import omnibias.convex.warm_startModule contract & mathematical conventions
Learned / geometric warm starts for the interior-point LP/QP solver.
An LP/QP constraint row a_i^T x <= b_i is a hyperplane, and the optimum of a
non-degenerate LP sits at a *vertex* -- the intersection of n **active**
hyperplanes. A model that reads the problem can therefore predict the **active
set** (which constraints bind at the optimum) far more cheaply than running the
solver.
Terminology: the "active set" here is the LP/QP feasibility sense (a constraint
binding at the optimum); it is **not** the founding delta -> 0 bias collapse
(the multi-bias derivative-generating limit). Do not conflate the two.
This module turns such a prediction into a strictly feasible starting point:
predicted_vertex-- solve thenhighest-scored constraints for the predicted vertex (the active-constraint geometry).geometry_warm_start-- pull any hint back to a strictly feasible interior point by backtracking toward a feasible anchor (a ratio test).active_set_warm_start-- compose the two: predict the vertex from per-constraint activation scores, then back off to the interior.
The returned point is a plain numpy.ndarray; pass it as x0 to either
omnibias.convex.jax.solve_qp or omnibias.convex.torch.solve_qp.
A strictly feasible x0 lets the solver **skip phase-1** entirely, which is
the measurable iteration saving (see ConvexSolution.newton_iterations).
Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.
active_set_warm_start
omnibias.convex.active_set_warm_startSource ↗active_set_warm_start(A: NDArray[np.float64], b: NDArray[np.float64], active_scores: NDArray[np.float64], *, anchor: NDArray[np.float64] | None=None, margin: float=1e-06, shrink: float=0.99) -> NDArray[np.float64] | NonePredict the active-set vertex, then back off to a strictly feasible point.
Convenience composition of predicted_vertex and
geometry_warm_start. Returns None if no vertex can be predicted
(rank-deficient selection) or no feasible anchor exists.
Parameters
| Name | Type & default | Contract |
|---|---|---|
Apositional-or-keyword | NDArray[np.float64]Required | See the operation contract and implementation below. |
bpositional-or-keyword | NDArray[np.float64]Required | See the operation contract and implementation below. |
active_scorespositional-or-keyword | NDArray[np.float64]Required | See the operation contract and implementation below. |
anchorkeyword-only | NDArray[np.float64] | NoneDefault: None | See the operation contract and implementation below. |
marginkeyword-only | floatDefault: 1e-06 | See the operation contract and implementation below. |
shrinkkeyword-only | floatDefault: 0.99 | See the operation contract and implementation below. |
NDArray[np.float64] | NoneExecuted regression · active set warm start is strictly feasible
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_active_set_warm_start_is_strictly_feasible() -> None:
scores = np.array([0.9, 0.8, 0.1, 0.05])
out = active_set_warm_start(_A, _B, scores)
assert out is not None
assert np.all(_B - _A @ out > 0.0)python -m pytest "packages/omnibias-convex/tests/test_warm_start.py::test_active_set_warm_start_is_strictly_feasible" -qRegression example · geometry warm start passthrough when feasible
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_geometry_warm_start_passthrough_when_feasible() -> None:
x = np.array([0.0, 0.0]) # strictly interior
out = geometry_warm_start(_A, _B, x)
assert out is not None
np.testing.assert_allclose(out, x)python -m pytest packages/omnibias-convex/tests/test_warm_start.py -k test_geometry_warm_start_passthrough_when_feasible -qRead the implementation
def active_set_warm_start(
A: NDArray[np.float64],
b: NDArray[np.float64],
active_scores: NDArray[np.float64],
*,
anchor: NDArray[np.float64] | None = None,
margin: float = 1e-6,
shrink: float = 0.99,
) -> NDArray[np.float64] | None:
r"""Predict the active-set vertex, then back off to a strictly feasible point.
Convenience composition of :func:`predicted_vertex` and
:func:`geometry_warm_start`. Returns ``None`` if no vertex can be predicted
(rank-deficient selection) or no feasible anchor exists.
"""
vertex = predicted_vertex(A, b, active_scores)
if vertex is None:
return None
return geometry_warm_start(
A, b, vertex, anchor=anchor, margin=margin, shrink=shrink
)Other public import paths
omnibias.convex.active_set_warm_startomnibias.convex.warm_start.active_set_warm_start
geometry_warm_start
omnibias.convex.geometry_warm_startSource ↗geometry_warm_start(A: NDArray[np.float64], b: NDArray[np.float64], x_hint: NDArray[np.float64], *, anchor: NDArray[np.float64] | None=None, margin: float=1e-06, shrink: float=0.99) -> NDArray[np.float64] | NonePull x_hint back to a strictly feasible interior point.
If x_hint already satisfies A x < b with at least margin slack it
is returned unchanged. Otherwise the segment from a strictly feasible
anchor toward x_hint is walked as far as a ratio test allows while
keeping every slack >= margin, then scaled by shrink to stay strictly
interior.
Parameters
A, b: Constraint data A x <= b.
x_hint: Candidate point (e.g. predicted_vertex).
anchor: A strictly feasible interior point to back off toward. Defaults to the origin, which is feasible iff b > 0; if neither the supplied anchor nor the origin is strictly feasible, None is returned (the caller should fall back to the solver's phase-1).
margin: Minimum slack required of the returned point.
shrink: Fraction of the feasible step length to take (0 < shrink < 1).
Returns
A strictly feasible point, or None if no feasible anchor is available.
Parameters
| Name | Type & default | Contract |
|---|---|---|
Apositional-or-keyword | NDArray[np.float64]Required | Constraint data A x <= b. |
bpositional-or-keyword | NDArray[np.float64]Required | See the operation contract and implementation below. |
x_hintpositional-or-keyword | NDArray[np.float64]Required | Candidate point (e.g. predicted_vertex). |
anchorkeyword-only | NDArray[np.float64] | NoneDefault: None | A strictly feasible interior point to back off toward. Defaults to the origin, which is feasible iff b > 0; if neither the supplied anchor nor the origin is strictly feasible, None is returned (the caller should fall back to the solver's phase-1). |
marginkeyword-only | floatDefault: 1e-06 | Minimum slack required of the returned point. |
shrinkkeyword-only | floatDefault: 0.99 | Fraction of the feasible step length to take (0 < shrink < 1). |
NDArray[np.float64] | NoneExecuted regression · active set warm start is strictly feasible
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_active_set_warm_start_is_strictly_feasible() -> None:
scores = np.array([0.9, 0.8, 0.1, 0.05])
out = active_set_warm_start(_A, _B, scores)
assert out is not None
assert np.all(_B - _A @ out > 0.0)python -m pytest "packages/omnibias-convex/tests/test_warm_start.py::test_active_set_warm_start_is_strictly_feasible" -qRegression example · geometry warm start passthrough when feasible
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_geometry_warm_start_passthrough_when_feasible() -> None:
x = np.array([0.0, 0.0]) # strictly interior
out = geometry_warm_start(_A, _B, x)
assert out is not None
np.testing.assert_allclose(out, x)python -m pytest packages/omnibias-convex/tests/test_warm_start.py -k test_geometry_warm_start_passthrough_when_feasible -qRead the implementation
def geometry_warm_start(
A: NDArray[np.float64],
b: NDArray[np.float64],
x_hint: NDArray[np.float64],
*,
anchor: NDArray[np.float64] | None = None,
margin: float = 1e-6,
shrink: float = 0.99,
) -> NDArray[np.float64] | None:
r"""Pull ``x_hint`` back to a strictly feasible interior point.
If ``x_hint`` already satisfies ``A x < b`` with at least ``margin`` slack it
is returned unchanged. Otherwise the segment from a strictly feasible
``anchor`` toward ``x_hint`` is walked as far as a ratio test allows while
keeping every slack ``>= margin``, then scaled by ``shrink`` to stay strictly
interior.
Parameters
----------
A, b:
Constraint data ``A x <= b``.
x_hint:
Candidate point (e.g. :func:`predicted_vertex`).
anchor:
A strictly feasible interior point to back off toward. Defaults to the
origin, which is feasible iff ``b > 0``; if neither the supplied anchor
nor the origin is strictly feasible, ``None`` is returned (the caller
should fall back to the solver's phase-1).
margin:
Minimum slack required of the returned point.
shrink:
Fraction of the feasible step length to take (``0 < shrink < 1``).
Returns
-------
A strictly feasible point, or ``None`` if no feasible anchor is available.
"""
A = np.asarray(A, dtype=np.float64)
b = np.asarray(b, dtype=np.float64)
x_hint = np.asarray(x_hint, dtype=np.float64)
if _strictly_feasible(A, b, x_hint, margin):
return x_hint
if anchor is None:
anchor = np.zeros(A.shape[1], dtype=np.float64)
else:
anchor = np.asarray(anchor, dtype=np.float64)
if not _strictly_feasible(A, b, anchor, margin):
return None
# Largest theta in [0, 1] with b - A(anchor + theta d) >= margin, d = x_hint - anchor.
d = x_hint - anchor
s_anchor = b - A @ anchor # > 0 by the check above
ad = A @ d
theta = 1.0
increasing = ad > 0.0 # slack shrinks where A d > 0
if np.any(increasing):
ratios = (s_anchor[increasing] - margin) / ad[increasing]
theta = float(min(1.0, np.min(ratios)))
theta = max(0.0, theta) * shrink
x0 = anchor + theta * d
return x0 if _strictly_feasible(A, b, x0, margin) else anchorOther public import paths
omnibias.convex.geometry_warm_startomnibias.convex.warm_start.geometry_warm_start
predicted_vertex
omnibias.convex.predicted_vertexSource ↗predicted_vertex(A: NDArray[np.float64], b: NDArray[np.float64], active_scores: NDArray[np.float64]) -> NDArray[np.float64] | NoneSolve the n highest-scored constraints for the predicted vertex.
Given per-constraint activation scores (high = the predictor expects that
bias to collapse onto its hyperplane at the optimum), select the n rows
with the largest scores and solve the square system A_act x = b_act.
Parameters
A, b: Constraint data A x <= b with shapes (m, n) and (m,).
active_scores: Shape (m,) predicted-active scores; only the ranking matters.
Returns
The predicted vertex x, or None if the selected rows are singular
(degenerate / rank-deficient prediction). The result is *not* guaranteed to
be feasible -- pass it through geometry_warm_start.
Parameters
| Name | Type & default | Contract |
|---|---|---|
Apositional-or-keyword | NDArray[np.float64]Required | Constraint data A x <= b with shapes (m, n) and (m,). |
bpositional-or-keyword | NDArray[np.float64]Required | See the operation contract and implementation below. |
active_scorespositional-or-keyword | NDArray[np.float64]Required | Shape (m,) predicted-active scores; only the ranking matters. |
NDArray[np.float64] | NoneExplicit validation & failure cases
- When
scores.shape != (m,), raisesValueError(f'active_scores must have shape (m,) = ({m},), got {scores.shape}').
These are explicit source guards. Backend operations may also raise for invalid shapes, dtypes, or unsupported devices.
Executed regression · active set warm start is strictly feasible
Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_active_set_warm_start_is_strictly_feasible() -> None:
scores = np.array([0.9, 0.8, 0.1, 0.05])
out = active_set_warm_start(_A, _B, scores)
assert out is not None
assert np.all(_B - _A @ out > 0.0)python -m pytest "packages/omnibias-convex/tests/test_warm_start.py::test_active_set_warm_start_is_strictly_feasible" -qRegression example · predicted vertex singular selection returns none
This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.
def test_predicted_vertex_singular_selection_returns_none() -> None:
# duplicate top-scored rows -> singular 2x2 system.
A = np.array([[1.0, 0.0], [1.0, 0.0], [0.0, 1.0]])
b = np.array([1.0, 1.0, 1.0])
scores = np.array([0.9, 0.89, 0.1])
assert predicted_vertex(A, b, scores) is Nonepython -m pytest packages/omnibias-convex/tests/test_warm_start.py -k test_predicted_vertex_singular_selection_returns_none -qRead the implementation
def predicted_vertex(
A: NDArray[np.float64],
b: NDArray[np.float64],
active_scores: NDArray[np.float64],
) -> NDArray[np.float64] | None:
r"""Solve the ``n`` highest-scored constraints for the predicted vertex.
Given per-constraint activation scores (high = the predictor expects that
bias to collapse onto its hyperplane at the optimum), select the ``n`` rows
with the largest scores and solve the square system ``A_act x = b_act``.
Parameters
----------
A, b:
Constraint data ``A x <= b`` with shapes ``(m, n)`` and ``(m,)``.
active_scores:
Shape ``(m,)`` predicted-active scores; only the ranking matters.
Returns
-------
The predicted vertex ``x``, or ``None`` if the selected rows are singular
(degenerate / rank-deficient prediction). The result is *not* guaranteed to
be feasible -- pass it through :func:`geometry_warm_start`.
"""
A = np.asarray(A, dtype=np.float64)
b = np.asarray(b, dtype=np.float64)
scores = np.asarray(active_scores, dtype=np.float64)
m, n = A.shape
if scores.shape != (m,):
raise ValueError(f"active_scores must have shape (m,) = ({m},), got {scores.shape}")
if m < n:
return None
top = np.argsort(scores)[::-1][:n]
a_act = A[top]
b_act = b[top]
try:
x = np.linalg.solve(a_act, b_act)
except np.linalg.LinAlgError:
return None
if not np.all(np.isfinite(x)):
return None
return np.asarray(x, dtype=np.float64)Other public import paths
omnibias.convex.predicted_vertexomnibias.convex.warm_start.predicted_vertex