Repository navigation
auto_math_constraints_duality_and_shadow_prices_2
github-actions[bot] edited this page Nov 14, 2025
·
1 revision
def check_constraint_qualification(A: np.ndarray, x: np.ndarray, b: np.ndarray) -> dict:
"""Verify qualifications at x."""
slack = b - A @ x
active = np.where(slack < 1e-6)[0]
if len(active) == 0:
return {"qualified": True, "reason": "interior"}
A_active = A[active]
rank = np.linalg.matrix_rank(A_active)
qualified = (rank == len(active))
return {
"qualified": qualified,
"active": active.tolist(),
"rank": int(rank),
"expected": len(active),
"reason": "LICQ" if qualified else "violated"
}