コード例 #1
0
ファイル: globalProtoMethod.py プロジェクト: helme/acp
def globalProtoMethod(coords=[1,1,1,3], radi=[1,1], step=1000, infimum=0, process_handler=None):
    eps = 10 ** (-6)
    n = 0
    supremum = 10000 # calcSupremum(radi)
    orig_coords = list(coords)

    distance = abs(supremum - infimum)

    while distance > eps:
        n += 1
        prev_coords = coords
        coords = searchVectorStep(coords, radi, supremum)
        
        swap = supremum

        if n == step:
            supremum += distance / 2
            coords = orig_coords
        elif norm(coords - prev_coords) < eps:
            orig_coords = coords
            # call process handler with intermediate results to be displayed to impatient client
            if not process_handler is None:
                process_handler(coords)
            supremum -= distance / 2
        else:
            continue
        
        infimum = swap
        n = 0
        distance = abs(supremum - infimum)

    return coords, supremum
コード例 #2
0
ファイル: globalProtoMethod.py プロジェクト: helme/acp
def globalProtoMethod(x0, r, step, bsup, binf):
    eps  = 10**-6
    xnp1 = x0
    n    = 0
    bn   = binf
    bnp1 = bsup

    while abs(bnp1 - bn) > eps:
        n = n + 1
        xn = xnp1
        xnp1 = searchVectorStep(xnp1, r, bnp1)
        temp = bnp1

        if n == step:
            bnp1 = bnp1 + (abs(bnp1 - bn) / 2)
        elif norm(xnp1 - xn) < eps:
            bnp1 = bnp1 - (abs(bnp1 - bn) / 2)
        else:
            continue

        bn = temp
        n  = 0
    return xnp1, bnp1