Commit 64a02e2c authored by Philipp Arras's avatar Philipp Arras

Merge branch 'paranoid_linesearch' into 'NIFTy_7'

Paranoid linesearch

See merge request !557
parents bf947d1b 216f3aa8
Pipeline #78445 passed with stages
in 26 minutes and 6 seconds
...@@ -210,8 +210,16 @@ class LineSearch(metaclass=NiftyMeta): ...@@ -210,8 +210,16 @@ class LineSearch(metaclass=NiftyMeta):
if alpha1 == 0: if alpha1 == 0:
return le_0.energy, False return le_0.energy, False
le_alpha1 = le_0.at(alpha1) try:
phi_alpha1 = le_alpha1.value le_alpha1 = le_0.at(alpha1)
phi_alpha1 = le_alpha1.value
except FloatingPointError: # backtrack
alpha1 = (alpha0+alpha1)/2
continue # next iteration
if np.isnan(phi_alpha1) or np.abs(phi_alpha1) > 1e100: # also backtrack
alpha1 = (alpha0+alpha1)/2
continue # next iteration
if (phi_alpha1 > phi_0 + self.c1*alpha1*phiprime_0) or \ if (phi_alpha1 > phi_0 + self.c1*alpha1*phiprime_0) or \
((phi_alpha1 >= phi_alpha0) and (iteration_number > 1)): ((phi_alpha1 >= phi_alpha0) and (iteration_number > 1)):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment