relaxed_newton.py 470 Bytes
Newer Older
1
2
3
4
5
6
7
# -*- coding: utf-8 -*-

from .quasi_newton_minimizer import QuasiNewtonMinimizer


class RelaxedNewton(QuasiNewtonMinimizer):
    def _get_descend_direction(self, energy):
8
9
10
        gradient = energy.gradient
        curvature = energy.curvature
        descend_direction = curvature.inverse_times(gradient)
11
12
13
14
15
        norm = descend_direction.norm()
        if norm != 1:
            return descend_direction / -norm
        else:
            return descend_direction * -1