- class LineEnergy(line_position, energy, line_direction, offset=0.0)¶
Evaluates an underlying Energy along a certain line direction.
Given an Energy class and a line direction, its position is parametrized by a scalar step size along the descent direction relative to a zero point.
line_position (float) – Defines the full spatial position of this energy via self.energy.position = zero_point + line_position*line_direction
energy (Energy) – The Energy object which will be evaluated along the given direction.
line_direction (Field) – Direction used for line evaluation. Does not have to be normalized.
offset (float optional) – Indirectly defines the zero point of the line via the equation energy.position = zero_point + offset*line_direction (default : 0.).
The LineEnergy is used in minimization schemes in order perform line searches. It describes an underlying Energy which is restricted along one direction, only requiring the step size parameter to determine a new position.
Returns LineEnergy at new position, memorizing the zero point.
line_position (float) – Parameter for the new position on the line direction.
- Return type
LineEnergy object at new position with same zero point as self.
- property directional_derivative¶
The directional derivative at the given position.
- property value¶
The value of the energy functional at given position.
- class LineSearch(preferred_initial_step_size=None, c1=0.0001, c2=0.9, max_step_size=1e+30, max_iterations=100, max_zoom_iterations=100)¶
Class for finding a step size that satisfies the strong Wolfe conditions.
Algorithm contains two stages. It begins with a trial step length and keeps increasing it until it finds an acceptable step length or an interval. If it does not satisfy the Wolfe conditions, it performs the Zoom algorithm (second stage). By interpolating it decreases the size of the interval until an acceptable step length is found.
preferred_initial_step_size (float, optional) – Newton-based methods should intialize this to 1.
c1 (float) – Parameter for Armijo condition rule. Default: 1e-4.
c2 (float) – Parameter for curvature condition rule. Default: 0.9.
max_step_size (float) – Maximum step allowed in to be made in the descent direction. Default: 1e30.
max_iterations (int, optional) – Maximum number of iterations performed by the line search algorithm. Default: 100.
max_zoom_iterations (int, optional) – Maximum number of iterations performed by the zoom algorithm. Default: 100.
- perform_line_search(energy, pk, f_k_minus_1=None)¶
Performs the first stage of the algorithm.
It starts with a trial step size and it keeps increasing it until it satisfies the strong Wolf conditions. It also performs the descent and returns the optimal step length and the new energy.
energy (Energy) – Energy object from which we will calculate the energy and the gradient at a specific point.
pk (Field) – Vector pointing into the search direction.
f_k_minus_1 (float, optional) – Value of the fuction (which is being minimized) at the k-1 iteration of the line search procedure. Default: None.
Energy – The new Energy object on the new position.
bool – whether the line search was considered successful or not