diff --git a/nifty/energies/energy.py b/nifty/energies/energy.py index a4ea61a84b85f461ce4e8c0044794fbea28eda8f..3cb70172917ab87e12ee4292b01ecb955fdd5b1d 100644 --- a/nifty/energies/energy.py +++ b/nifty/energies/energy.py @@ -39,10 +39,6 @@ class Energy(Loggable, object): def position(self): return self._position - @position.setter - def position(self, position): - self._position = position - @property def value(self): raise NotImplementedError diff --git a/nifty/minimization/__init__.py b/nifty/minimization/__init__.py index 06a16780d110dd830d3411a6f61a9e4606a8eee8..bcb5964029f2b889835e0f2001fdfb53f2a49e59 100644 --- a/nifty/minimization/__init__.py +++ b/nifty/minimization/__init__.py @@ -18,7 +18,7 @@ from line_searching import * from conjugate_gradient import ConjugateGradient -from quasi_newton_minimizer import QuasiNewtonMinimizer +from descent_minimizer import QuasiNewtonMinimizer from steepest_descent import SteepestDescent from vl_bfgs import VL_BFGS from relaxed_newton import RelaxedNewton diff --git a/nifty/minimization/quasi_newton_minimizer.py b/nifty/minimization/descent_minimizer.py similarity index 99% rename from nifty/minimization/quasi_newton_minimizer.py rename to nifty/minimization/descent_minimizer.py index be35294c53cc6bd4d820179cc34dadab252da47a..f544427a79e5851d244e88d055e0078da9ed0a74 100644 --- a/nifty/minimization/quasi_newton_minimizer.py +++ b/nifty/minimization/descent_minimizer.py @@ -26,7 +26,7 @@ from keepers import Loggable from .line_searching import LineSearchStrongWolfe -class QuasiNewtonMinimizer(Loggable, object): +class DescentMinimizer(Loggable, object): __metaclass__ = NiftyMeta def __init__(self, line_searcher=LineSearchStrongWolfe(), callback=None, diff --git a/nifty/minimization/line_searching/line_search_strong_wolfe.py b/nifty/minimization/line_searching/line_search_strong_wolfe.py index 81ecb3e886a17a455ba94ba43c3e7fa3a2b5d78c..084775eedd038357ef9bbdd9044bc9ac243ee1d8 100644 --- a/nifty/minimization/line_searching/line_search_strong_wolfe.py +++ b/nifty/minimization/line_searching/line_search_strong_wolfe.py @@ -148,8 +148,9 @@ class LineSearchStrongWolfe(LineSearch): # extract the full energy from the line_energy energy_star = energy_star.energy - - return alpha_star, phi_star, energy_star + length_direction = pk.norm + step_length = alpha_star * length_direction + return step_length, phi_star, energy_star def _zoom(self, alpha_lo, alpha_hi, phi_0, phiprime_0, phi_lo, phiprime_lo, phi_hi, c1, c2): diff --git a/nifty/minimization/relaxed_newton.py b/nifty/minimization/relaxed_newton.py index 0d7d9bf7aba5f7f1ec1e8b1086b7c853b718bc8e..467029317bba8a780627db6bad8d57858370c2a2 100644 --- a/nifty/minimization/relaxed_newton.py +++ b/nifty/minimization/relaxed_newton.py @@ -16,11 +16,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from .quasi_newton_minimizer import QuasiNewtonMinimizer +from .descent_minimizer import DescentMinimizer from .line_searching import LineSearchStrongWolfe -class RelaxedNewton(QuasiNewtonMinimizer): +class RelaxedNewton(DescentMinimizer): def __init__(self, line_searcher=LineSearchStrongWolfe(), callback=None, convergence_tolerance=1E-4, convergence_level=3, iteration_limit=None): @@ -38,8 +38,3 @@ class RelaxedNewton(QuasiNewtonMinimizer): curvature = energy.curvature descend_direction = curvature.inverse_times(gradient) return descend_direction * -1 - #norm = descend_direction.norm() -# if norm != 1: -# return descend_direction / -norm -# else: -# return descend_direction * -1 diff --git a/nifty/minimization/steepest_descent.py b/nifty/minimization/steepest_descent.py index 87d8ef4cd4d88f5ce7751da61eeff8c5136e023b..ba125a9c5c0089cd4e017dca9a133b67c39fe73e 100644 --- a/nifty/minimization/steepest_descent.py +++ b/nifty/minimization/steepest_descent.py @@ -16,10 +16,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from .quasi_newton_minimizer import QuasiNewtonMinimizer +from .descent_minimizer import DescentMinimizer -class SteepestDescent(QuasiNewtonMinimizer): +class SteepestDescent(DescentMinimizer): def _get_descend_direction(self, energy): descend_direction = energy.gradient norm = descend_direction.norm() diff --git a/nifty/minimization/vl_bfgs.py b/nifty/minimization/vl_bfgs.py index db47d5797c04c66d94e89110f1ffc32ade6a176f..2e55af98facb11707a0df44083e8091d7c9bf755 100644 --- a/nifty/minimization/vl_bfgs.py +++ b/nifty/minimization/vl_bfgs.py @@ -18,11 +18,11 @@ import numpy as np -from .quasi_newton_minimizer import QuasiNewtonMinimizer +from .descent_minimizer import DescentMinimizer from .line_searching import LineSearchStrongWolfe -class VL_BFGS(QuasiNewtonMinimizer): +class VL_BFGS(DescentMinimizer): def __init__(self, line_searcher=LineSearchStrongWolfe(), callback=None, convergence_tolerance=1E-4, convergence_level=3, iteration_limit=None, max_history_length=10):