Exemple #1
0
def getOrthogonalGradStart( cD , eps_array ):

    eps = eps_array[0]
    posGrad = getPosGradStart( cD )
    print( 'habe pos grad gefunden')
    print(posGrad)

    steps = 3
    stepSize = 0.5
    negGrad = []


    while len(negGrad) ==   0:
        grid_neg = getDistOrderedGrid( steps , stepSize )
        transGridMid( grid_neg , posGrad )
        negGrad = getNearestNegGrad( grid_neg , cD , posGrad )
        stepSize = stepSize / 2.0
        if stepSize / 2.0 <= mE.getMachEps():
            steps = steps + 1
            stepSize = 0.5

    print( 'habe neg grad gefunden ')
    print( negGrad )

    return getZeroGradOnLine( cD , negGrad , posGrad , eps )
def supportFunctionPolar(K_polar, u):
    angle = getAngle(u)
    neighbours = getPolarNeighbours(K_polar, angle)
    v = getCartesian([neighbours[1]])[0]
    w = getCartesian([neighbours[2]])[0]
    h_tilde = getMin(v, w, angle)
    divisor = M.norm(u)
    if divisor == 0:
        print('warum ist u als Normalenvektor so klein?')
        print(u)
        return h_tilde / mE.getMachEps()
    return h_tilde / M.norm(u)
Exemple #3
0
def getConeVol(vertices):
    result = []
    n = len(vertices)
    for i in range(n):
        v = M.subVek(vertices[i], vertices[(i - 1 + n) % n])
        u_tilde = getClockRotation(v)
        divisor = M.norm(v)
        if u_tilde[0] == 0 and u_tilde[1] == 0:
            divisor = mE.getMachEps()
        u = M.scaleVek(1.0 / divisor, u_tilde)

        height = M.scal(u, vertices[i - 1])
        if height < 0:
            print('height is negativ at ')
            print(i)
        facetVolume = M.norm(v)
        coneVolume = 0.5 * height * facetVolume

        result.append([u[0], u[1], coneVolume])
    return result
Exemple #4
0
import matrix as M
import math
import coneVol2 as cV
import machEps as mE

eps = 100 * mE.getMachEps()


def stepSize_posGrad(cD, point, d, n):
    alpha = 0.5
    nextPoint = M.addVek(point, M.scaleVek(alpha, d))
    while (cV.phi(point, cD) + eps < cV.phi(
            nextPoint, cD)):  #or pS.scalGrad( cD , nextPoint ) < 0 ):
        alpha = alpha * 0.5
        nextPoint = M.addVek(point, M.scaleVek(alpha, d))
    if n % 300 == 0:
        print(alpha)
    if alpha < eps == 1:
        return 0
    return alpha


def notEfficient(cD, point, d, stepSize, crease):
    v = M.addVek(point, M.scaleVek(stepSize, d))
    upper_bound = cV.phi(point, cD) + crease * stepSize * M.scal(
        cV.gradPhi(point, cD), d) / M.norm(d)
    return cV.phi(v, cD) > upper_bound


def stepSizeArmijo(cD, point, d, crease, efficiency, beta_1, beta_2):
    result = -efficiency * (M.scal(cV.gradPhi(point, cD), d) / (M.norm(d)**2))
from cmath import sqrt
import math
import numpy
import random
import coneVol2 as cV
import matrix as M
import matplotlib.pyplot as mp
import machEps as mE
import fractions as f

eps_max = 4096 * mE.getMachEps()
eps_min = 4096 * mE.getMachEps()

generalMaxRadiusBound = 1


def getRandomPolygon(number):
    polarResult = getRandomNoncenteredPolarPolygon(number)
    result = getCartesian(polarResult)
    # maybe this should be done in every step. But then again,
    makeCentered(result)
    #makeUnitVolume( result )

    return result


def getRandomNoncenteredPolarPolygon(m):
    polarResult = getRandomOriginPolarTriangle()
    steps = 3
    while (steps < m):
        # maybe it works fine, if the start triangle is just centered....