Commit 36066654 authored by Matevz, Sraml (sraml)'s avatar Matevz, Sraml (sraml)
Browse files

some changes in Line search and started LineSearchStrongWolf

parent 7412dcc3
......@@ -57,14 +57,13 @@ class LineSearch(Loggable, object):
Parameters
----------
energy : Energy object
Energy object from which we can calculate the
energy, gradient and curvature at a specific point.
Energy object from which we can calculate the energy, gradient and
curvature at a specific point.
pk : Field
Unit vector in search direction.
f_k_minus_1 : float *optional*
Value of the field at the k-1 iteration of the line search
procedure.
Unit vector pointing into the search direction.
f_k_minus_1 : float
Value of the fuction (energy) which will be minimized at the k-1
iteration of the line search procedure. (Default: None)
"""
self.line_energy = LineEnergy(position=0.,
......
......@@ -22,38 +22,50 @@ from .line_search import LineSearch
class LineSearchStrongWolfe(LineSearch):
"""
Class for finding a step size that satisfies the strong Wolfe conditions.
"""
"""Class for finding a step size that satisfies the strong Wolfe conditions.
def __init__(self, c1=1e-4, c2=0.9,
max_step_size=50, max_iterations=10,
max_zoom_iterations=10):
Algorithm contains two stages. It begins whit a trial step length and it
keeps increasing the it until it finds an acceptable step length or an
interval. In the second stage the Zoom algorithm is performed which
decreases the size of the interval until an acceptable step length is found.
"""
Parameters
----------
f : callable f(x, *args)
Objective function.
fprime : callable f'(x, *args)
Objective functions gradient.
f_args : tuple (optional)
Additional arguments passed to objective function and its
derivation.
c1 : float (optional)
c1 : scalar
Parameter for Armijo condition rule. (Default: 1e-4)
c2 : scalar
Parameter for curvature condition rule. (Default: 0.9)
max_step_size : scalar
Maximum step allowed in to be made in the descent direction.
(Default: 50)
max_iterations : integer
Maximum number of iterations performed by the line search algorithm.
(Default: 10)
max_zoom_iterations : integer
Maximum number of iterations performed by the zoom algorithm.
(Default: 10)
Attributes
----------
c1 : float
Parameter for Armijo condition rule.
c2 : float (optional)
c2 : float
Parameter for curvature condition rule.
max_step_size : scalar
Maximum step allowed in to be made in the descent direction.
max_iterations : integer
Maximum number of iterations performed by the line search algorithm.
max_zoom_iterations : integer
Maximum number of iterations performed by the zoom algorithm.
max_step_size : float (optional)
Maximum step size
"""
def __init__(self, c1=1e-4, c2=0.9,
max_step_size=50, max_iterations=10,
max_zoom_iterations=10):
super(LineSearchStrongWolfe, self).__init__()
self.c1 = np.float(c1)
......@@ -63,6 +75,24 @@ class LineSearchStrongWolfe(LineSearch):
self.max_zoom_iterations = int(max_zoom_iterations)
def perform_line_search(self, energy, pk, f_k_minus_1=None):
"""Performs the first stage of the algorithm.
Its starts with a trial step size and it keeps increasing it until it
satisfy the strong Wolf conditions.
Parameters
----------
energy : Energy object
Energy object from which we will calculate the energy and the
gradient at a specific point.
pk : Field
Unit vector pointing into the search direction.
f_k_minus_1 : float
Value of the function (energy) which will be minimized at the k-1
iteration of the line search procedure. (Default: None)
"""
self._set_line_energy(energy, pk, f_k_minus_1=f_k_minus_1)
c1 = self.c1
c2 = self.c2
......
......@@ -104,7 +104,7 @@ class QuasiNewtonMinimizer(Loggable, object):
Returns
-------
x : field
x : Field
Latest `energy` of the minimization.
convergence : integer
Latest convergence level indicating whether the minimization
......
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