Ejemplo n.º 1
0
def main(args):
    # Generate an analytic centering problem
    #
    #    -b1 <=  Ar*x <= b2
    #
    # with random mxn Ar and random b1, b2.

    if len(args[0]) > 0 and args[0] == "reftest":
        m, n = 10, 5
        # matrix in column order
        A0 = matrix([[-7.44e-01, 4.59e-01, -2.95e-02, -7.75e-01, -1.80e+00],
                     [1.11e-01, 7.06e-01, -2.22e-01, 1.03e-01, 1.24e+00],
                     [1.29e+00, 3.16e-01, -2.07e-01, -1.22e+00, -2.61e+00],
                     [2.62e+00, -1.06e-01, -9.11e-01, -5.74e-01, -9.31e-01],
                     [-1.82e+00, 7.80e-01, -3.92e-01, -3.32e-01, -6.38e-01]])

        b0 = matrix([
            8.38e-01, 9.92e-01, 9.56e-01, 6.14e-01, 6.56e-01, 3.57e-01,
            6.36e-01, 5.08e-01, 8.81e-03, 7.08e-02
        ])
        A = matrix([A0, -A0])
        b = b0
    else:
        m, n = 500, 500
        Ar = base.normal(m, n)
        A = matrix([Ar, -Ar])
        b = base.uniform(2 * m, 1)

    x, ntdecrs = acent(A, b)
    print "solution:\n", helpers.str2(x, "%.17f")
    print "ntdecrs :\n", ntdecrs
Ejemplo n.º 2
0
def main(args):
    # Generate an analytic centering problem  
    #
    #    -b1 <=  Ar*x <= b2 
    #
    # with random mxn Ar and random b1, b2.

    if len(args[0]) > 0 and args[0] == "reftest":
        m, n = 10, 5
        # matrix in column order
        A0 = matrix([[-7.44e-01,  4.59e-01, -2.95e-02, -7.75e-01, -1.80e+00],
                     [ 1.11e-01,  7.06e-01, -2.22e-01,  1.03e-01,  1.24e+00],
                     [ 1.29e+00,  3.16e-01, -2.07e-01, -1.22e+00, -2.61e+00],
                     [ 2.62e+00, -1.06e-01, -9.11e-01, -5.74e-01, -9.31e-01],
                     [-1.82e+00,  7.80e-01, -3.92e-01, -3.32e-01, -6.38e-01]])

        b0 = matrix([8.38e-01,
                     9.92e-01,
                     9.56e-01,
                     6.14e-01,
                     6.56e-01,
                     3.57e-01,
                     6.36e-01,
                     5.08e-01,
                     8.81e-03,
                     7.08e-02])
        A = matrix([A0, -A0])
        b = b0
    else:
        m, n  = 500, 500
        Ar = base.normal(m,n);
        A = matrix([Ar, -Ar])
        b = base.uniform(2*m,1)

    x, ntdecrs = acent(A, b)  
    print "solution:\n", helpers.str2(x, "%.17f")
    print "ntdecrs :\n", ntdecrs
Ejemplo n.º 3
0
        while 1 - step * max(y) < 0:
            step *= BETA
        while True:
            if -sum(log(1 - step * y)) < ALPHA * step * lam:
                break
            step *= BETA
        x += step * v


# Generate an analytic centering problem
#
#    -b1 <=  Ar*x <= b2
#
# with random mxn Ar and random b1, b2.

m, n = 500, 500
Ar = base.normal(m, n)
A = matrix([Ar, -Ar])
b = base.uniform(2 * m, 1)

x, ntdecrs = acent(A, b)
try:
    import pylab
except ImportError:
    pass
else:
    pylab.semilogy(range(len(ntdecrs)), ntdecrs, "o", range(len(ntdecrs)), ntdecrs, "-")
    pylab.xlabel("Iteration number")
    pylab.ylabel("Newton decrement")
    pylab.show()
Ejemplo n.º 4
0
        while 1 - step * max(y) < 0:
            step *= BETA
        while True:
            if -sum(log(1 - step * y)) < ALPHA * step * lam: break
            step *= BETA
        x += step * v


# Generate an analytic centering problem
#
#    -b1 <=  Ar*x <= b2
#
# with random mxn Ar and random b1, b2.

m, n = 500, 500
Ar = base.normal(m, n)
A = matrix([Ar, -Ar])
b = base.uniform(2 * m, 1)

x, ntdecrs = acent(A, b)
try:
    import pylab
except ImportError:
    pass
else:
    pylab.semilogy(range(len(ntdecrs)), ntdecrs, 'o', range(len(ntdecrs)),
                   ntdecrs, '-')
    pylab.xlabel('Iteration number')
    pylab.ylabel('Newton decrement')
    pylab.show()