Commit 9f1c0f3b authored by Theo Steininger's avatar Theo Steininger

Added prefered_initial_step_size to LineSearch class.

parent 1e450dc6
Pipeline #10016 failed with stages
in 17 minutes and 55 seconds
......@@ -31,6 +31,7 @@ class LineSearch(Loggable, object):
self.pk = None
self.line_energy = None
self.f_k_minus_1 = None
self.prefered_initial_step_size = None
def _set_line_energy(self, energy, pk, f_k_minus_1=None):
"""
......
......@@ -64,7 +64,9 @@ class LineSearchStrongWolfe(LineSearch):
# set alphas
alpha0 = 0.
if old_phi_0 is not None and phiprime_0 != 0:
if self.prefered_initial_step_size is not None:
alpha1 = self.prefered_initial_step_size
elif old_phi_0 is not None and phiprime_0 != 0:
alpha1 = min(1.0, 1.01*2*(phi_0 - old_phi_0)/phiprime_0)
if alpha1 < 0:
alpha1 = 1.0
......
# -*- coding: utf-8 -*-
from .quasi_newton_minimizer import QuasiNewtonMinimizer
from .line_searching import LineSearchStrongWolfe
class RelaxedNewton(QuasiNewtonMinimizer):
def __init__(self, line_searcher=LineSearchStrongWolfe(), callback=None,
convergence_tolerance=1E-4, convergence_level=3,
iteration_limit=None):
super(RelaxedNewton, self).__init__(
line_searcher=line_searcher,
callback=callback,
convergence_tolerance=convergence_tolerance,
convergence_level=convergence_level,
iteration_limit=iteration_limit)
self.line_searcher.prefered_initial_step_size = 1.
def _get_descend_direction(self, energy):
gradient = energy.gradient
curvature = energy.curvature
......
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