Planned maintenance on Wednesday, 2021-01-20, 17:00-18:00. Expect some interruptions during that time

Commit d4806087 authored by Theo Steininger's avatar Theo Steininger

Updated Interface of QuasiNewtonMinimizer BaseClass.

parent a6d099d6
......@@ -80,9 +80,8 @@ class QuasiNewtonMinimizer(Loggable, object):
convergence = self.convergence_level+2
break
current_position = energy.position
descend_direction = self._get_descend_direction(current_position,
gradient)
# current position is encoded in energy object
descend_direction = self._get_descend_direction(energy)
# compute the step length, which minimizes energy.value along the
# search direction
......@@ -124,5 +123,5 @@ class QuasiNewtonMinimizer(Loggable, object):
return energy, convergence
@abc.abstractmethod
def _get_descend_direction(self, gradient, gradient_norm):
def _get_descend_direction(self, energy):
raise NotImplementedError
......@@ -4,8 +4,8 @@ from .quasi_newton_minimizer import QuasiNewtonMinimizer
class SteepestDescent(QuasiNewtonMinimizer):
def _get_descend_direction(self, x, gradient):
descend_direction = gradient
def _get_descend_direction(self, energy):
descend_direction = energy.gradient
norm = descend_direction.norm()
if norm != 1:
return descend_direction / -norm
......
......@@ -24,7 +24,9 @@ class VL_BFGS(QuasiNewtonMinimizer):
self._information_store = None
return super(VL_BFGS, self).__call__(energy)
def _get_descend_direction(self, x, gradient):
def _get_descend_direction(self, energy):
x = energy.position
gradient = energy.gradient
# initialize the information store if it doesn't already exist
try:
self._information_store.add_new_point(x, gradient)
......
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