Beispiel #1
0
def diffF(cD, params):
    A = diffGamma(cD, params)
    B = diffConeVolumeIterator(cD, gamma(cD, params))
    C = M.idMatrix(2)
    C.scale(-1)
    B.add(C)
    return B.mult(A)
Beispiel #2
0
def coneVolumeDescendBFGSApprox(cD, params_new, params_prev, crease,
                                efficiency, beta_1, beta_2):
    A_k = M.idMatrix(2)
    n = 0
    while (cV.phi(params_new, cD) > eps_descend):
        while (True):
            try:
                A_k = BFGS.getBFGSApprox(cD, params_new, params_prev, A_k)
                break
            except ZeroDivisionError:
                print('es geht nicht besser mit BFGSApprox')
                return params_new
                break

        antiGrad = M.scaleVek(-1, cV.gradPhiApprox(params_new, cD, 0.0001))
        d = A_k.lgsSolve(antiGrad)
        d = M.scaleVek(1.0 / M.norm(d), d)

        alpha = sS.stepSizeArmijo(cD, params_new, d, crease, efficiency,
                                  beta_1, beta_2)
        d = M.scaleVek(alpha, d)

        params_prev = [params_new[0], params_new[1]]
        params_new = M.addVek(params_new, d)

        if (M.dist(params_new, params_prev) < minimalStep_BFGSApprox):
            print(' distance is lower than minimalStep of BFGSApprox ')
            break
        n = n + 1

    return params_new
Beispiel #3
0
def isNilpotent( point , cD ):
    A = cV.diffConeVolumeIterator( cD , point )
    A.scale(-1)
    A.add(M.idMatrix(2))
    A.makeMatrixNormalized()
    #result = diff.rows[0][0] * diff.rows[1][1] - diff.rows[0][1] * diff.rows[1][0]
    result = A.mult(A)
    return result.rows[0][0]**2 + result.rows[1][1]**2 + result.rows[1][0]**2 + result.rows[0][1]**2
Beispiel #4
0
def diffGetNextVertex(u, volume, point):
    B = M.Matrix([[-u[1]], [u[0]]])
    A = M.Matrix([[-u[0], -u[1]]])
    C = B.mult(A)
    c = M.scal(point, u)
    c = 2 * volume / (c**2)
    C.scale(c)
    # Matrix.plus oder Matrix.add verwenden?
    C.add(M.idMatrix(2))
    return C
Beispiel #5
0
def gradPolyFunctional(coneData, point):
    B = M.idMatrix(2)
    A = gradConeVolumeIterator(coneData, point)
    A.scale(-1)
    B.add(A)

    b = M.subVek(point, getConeVolIterator(coneData, point))
    b = M.scaleVek(2, b)

    result = B.image(b)
    return result
Beispiel #6
0
def scalarDifferenceGradient( point , cD):
    v = cV.getConeVolIterator( cD , point )
    d = M.subVek( v , point )

    diff = cV.diffConeVolumeIterator( cD , point )
    diff.scale(-1)
    diff.add(M.idMatrix(2))

    u = M.Matrix([d]).mult(diff)

    # equal to scalar product of u and d :
    return u.image(d)[0]
Beispiel #7
0
def diffConeVolumeIterator(coneData, point):
    result = M.idMatrix(2)
    n = len(coneData)

    for i in range(n):
        facet = coneData[(i + 1) % n]
        result = diffGetNextVertex([facet[0], facet[1]], facet[2],
                                   point).mult(result)
        nextVertex([facet[0], facet[1]], facet[2], point)
    return result

    diff_test = diffConeVolumeIterator(cD_test, point_test)
    exspectedDiff_test = Matrix([[0, 0], [0, 0]])
    if M.distMatrix(diff_test, exspectedDiff_test) > 0.00001:
        print('Fehler bei diffConeVolume')
Beispiel #8
0
def coneVolumeDescendBFGS(cD, params_new, params_prev, crease, efficiency,
                          beta_1, beta_2):
    A_k = M.idMatrix(2)
    n = 0

    while (cV.phi(params_new, cD) > eps_descend):

        # ICH VERÄNDERE HIER MEIN CREASE...
        crease = 0.000001  #cV.phi( params_new , cD) * 0.00000001

        while (True):
            try:
                A_k = BFGS.getBFGS(cD, params_new, params_prev, A_k)
                break
            except ZeroDivisionError:
                print('es geht nicht besser')
                return params_new
                break

        antiGrad = M.scaleVek(-1, cV.gradPhi(params_new, cD))
        d = A_k.lgsSolve(antiGrad)
        d = M.scaleVek(1.0 / M.norm(d), d)

        alpha = sS.stepSize_posGrad(
            cD, params_new, d, n)  # crease , efficiency , beta_1 , beta_2 )
        d = M.scaleVek(alpha, d)

        params_prev = [params_new[0], params_new[1]]
        params_new = M.addVek(params_new, d)

        if (M.dist(params_new, params_prev) < minimalStep_BFGS):
            print(' distance is lower than minimalStep of BFGS ')
            break

        n = n + 1

    return params_new