Für Nico
This commit is contained in:
@@ -29,7 +29,7 @@ def Bogenlaenge(P1: NDArray, P2: NDArray) -> float:
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def gha2_ES(ell: EllipsoidTriaxial, P0: NDArray, Pk: NDArray, stepLenTarget: float = None, sigmaStep: float = 1e-7, stopeval: int = 1000, maxSteps: int = 10000, all_points: bool = False):
|
def gha2_ES(ell: EllipsoidTriaxial, P0: NDArray, Pk: NDArray, stepLenTarget: float = None, sigmaStep: float = 1e-5, stopeval: int = 1000, maxSteps: int = 10000, all_points: bool = False):
|
||||||
"""
|
"""
|
||||||
Berechnen der 2. GHA mithilfe der CMA-ES.
|
Berechnen der 2. GHA mithilfe der CMA-ES.
|
||||||
Die CMA-ES optimiert sukzessive einzelne Punkte, die einen definierten Abstand (stepLenTarget) zum vorherigen und den kürzesten
|
Die CMA-ES optimiert sukzessive einzelne Punkte, die einen definierten Abstand (stepLenTarget) zum vorherigen und den kürzesten
|
||||||
@@ -92,13 +92,12 @@ def gha2_ES(ell: EllipsoidTriaxial, P0: NDArray, Pk: NDArray, stepLenTarget: flo
|
|||||||
# sin(v);
|
# sin(v);
|
||||||
# sin(u)] auf
|
# sin(u)] auf
|
||||||
# Einheitskugel
|
# Einheitskugel
|
||||||
# % arg_u = max(-1, min(1, q(3)));
|
#arg_u = max(-1, min(1, q(3)));
|
||||||
#
|
#
|
||||||
# %Quadrantenabfrage
|
# %Quadrantenabfrage
|
||||||
# % u0 = mod(asin(arg_u) + pi / 2, pi) - pi / 2;
|
#u0 = mod(asin(arg_u) + pi / 2, pi) - pi / 2;
|
||||||
# % v0 = atan2(q(2), q(1));
|
#v0 = atan2(q(2), q(1));
|
||||||
# % xmean_init = [u0;
|
#xmean_init = [u0;v0];
|
||||||
# v0];
|
|
||||||
xmean_init = ell.point_onto_ellipsoid(P_prev + stepLen * (P_end - P_prev) / np.linalg.norm(P_end - P_prev))
|
xmean_init = ell.point_onto_ellipsoid(P_prev + stepLen * (P_end - P_prev) / np.linalg.norm(P_end - P_prev))
|
||||||
|
|
||||||
# [~, ~, aux] = geoLength(xmean_init);
|
# [~, ~, aux] = geoLength(xmean_init);
|
||||||
@@ -218,11 +217,12 @@ if __name__ == '__main__':
|
|||||||
beta1, lamb1 = (0.7, 0.3)
|
beta1, lamb1 = (0.7, 0.3)
|
||||||
P1 = ell.ell2cart(beta1, lamb1)
|
P1 = ell.ell2cart(beta1, lamb1)
|
||||||
|
|
||||||
alpha0, alpha1, s, betas, lambs = gha2_num(ell, beta0, lamb0, beta1, lamb1, n=5000, all_points=True)
|
alpha0, alpha1, s_num, betas, lambs = gha2_num(ell, beta0, lamb0, beta1, lamb1, n=10000, all_points=True)
|
||||||
points_num = []
|
points_num = []
|
||||||
for beta, lamb in zip(betas, lambs):
|
for beta, lamb in zip(betas, lambs):
|
||||||
points_num.append(ell.ell2cart(beta, lamb))
|
points_num.append(ell.ell2cart(beta, lamb))
|
||||||
points_num = np.array(points_num)
|
points_num = np.array(points_num)
|
||||||
|
|
||||||
alpha0, alpha1, s, points = gha2_ES(ell, P0, P1)
|
alpha0, alpha1, s, points = gha2_ES(ell, P0, P1, all_points=True, sigmaStep=1e-5)
|
||||||
|
print(s - s_num)
|
||||||
show_points(points, points_num, P0, P1)
|
show_points(points, points_num, P0, P1)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ def felli(x):
|
|||||||
|
|
||||||
def escma(func, *, N=10, xmean=None, sigma=0.5, stopfitness=1e-10, stopeval=None,
|
def escma(func, *, N=10, xmean=None, sigma=0.5, stopfitness=1e-10, stopeval=None,
|
||||||
func_args=(), func_kwargs=None, seed=None,
|
func_args=(), func_kwargs=None, seed=None,
|
||||||
bestEver = np.inf, noImproveGen = 0, absTolImprove = 1e-10, maxNoImproveGen = 100, sigmaImprove = 1e-12):
|
bestEver = np.inf, noImproveGen = 0, absTolImprove = 1e-12, maxNoImproveGen = 100, sigmaImprove = 1e-12):
|
||||||
|
|
||||||
if func_kwargs is None:
|
if func_kwargs is None:
|
||||||
func_kwargs = {}
|
func_kwargs = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user