Solve small dense quadratic programs with inequality constraints and certify the answer with the KKT conditions (Murphy, Probabilistic Machine Learning):
with symmetric positive definite, of shape .
kkt_residuals(H, c, A, b, theta, mu) returns a dict of four non-negative floats:
"primal": (feasibility),"stationarity": ,"dual": (dual feasibility),"complementary": (complementary slackness).solve_qp_active_set(H, c, A, b, tol=1e-9) returns (theta, mu) with mu of length (zero for inactive constraints). Search the candidate active sets in order of size , and within one size in itertools.combinations order. Skip a set whose rows are linearly dependent (rank below ). Otherwise treat the constraints in as equalities and solve the KKT system
Return the first candidate with and . If none qualifies, return (None, None).