def test_ir_kkt_solver(): Q, p, G, h, A, b, d, D, rx, rs, rz, ry = get_kkt_problem() dx, ds, dz, dy = pdipm_b.factor_solve_kkt(Q, D, G, A, rx, rs, rz, ry) dx_, ds_, dz_, dy_ = pdipm_b.solve_kkt_ir( Q, D, G, A, rx, rs, rz, ry, niter=1) npt.assert_allclose(dx.numpy(), dx_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(ds.numpy(), ds_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(dz.numpy(), dz_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(dy.numpy(), dy_.numpy(), rtol=RTOL, atol=ATOL)
def test_lu_kkt_solver(): Q, p, G, h, A, b, d, D, rx, rs, rz, ry = get_kkt_problem() dx, ds, dz, dy = pdipm_b.factor_solve_kkt(Q, D, G, A, rx, rs, rz, ry) Q_LU, S_LU, R = pdipm_b.pre_factor_kkt(Q, G, A) pdipm_b.factor_kkt(S_LU, R, d) dx_, ds_, dz_, dy_ = pdipm_b.solve_kkt(Q_LU, d, G, A, S_LU, rx, rs, rz, ry) npt.assert_allclose(dx.numpy(), dx_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(ds.numpy(), ds_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(dz.numpy(), dz_.numpy(), rtol=RTOL, atol=ATOL) npt.assert_allclose(dy.numpy(), dy_.numpy(), rtol=RTOL, atol=ATOL)