Пример #1
0
def test_linsys():
    A = np.random.randn(50, 20)
    x = np.random.randn(20, )
    y = A.dot(x)

    op = proxops.linsys(A, y)

    assert np.allclose(op(x, 1.), x)
    assert np.allclose(op(np.zeros(x.size), 0.), x)
Пример #2
0
def test_linsys():
    A = np.random.randn(50,20)
    x = np.random.randn(20,)
    y = A.dot(x)

    op = proxops.linsys(A, y)

    assert np.allclose(op(x, 1.), x)
    assert np.allclose(op(np.zeros(x.size), 0.), x)
Пример #3
0
def test_consensus():
    """Test the consensus optimizer (ADMM)"""

    A, y, x_true, xls, ls_error = generate_sparse_system()

    # optimizer
    opt = Consensus()
    opt.add(linsys(A, y))
    opt.add(sparse(10.0))

    # run it
    res = opt.minimize(xls, display=None, maxiter=5000)

    # test
    assert relative_error(res.x, x_true, ls_error) <= 0.05
def test_consensus():
    """Test the consensus optimizer (ADMM)"""

    A, y, x_true, xls, ls_error = generate_sparse_system()

    # optimizer
    opt = Consensus()
    opt.add(linsys(A, y))
    opt.add(sparse(10.0))

    # run it
    res = opt.minimize(xls, display=None, maxiter=5000)

    # test
    assert relative_error(res.x, x_true, ls_error) <= 0.05