seisflows.optimize.NLCG
Nonlinear conjugate gradient method for optimization
Classes
NLCG Optimization |
Functions
|
Check for conjugacy between two vectors |
|
Ensure that the search direction is descending |
Module Contents
- class seisflows.optimize.NLCG.NLCG(nlcg_max=np.inf, nlcg_thresh=np.inf, calc_beta='pollak_ribere', **kwargs)
Bases:
seisflows.optimize.gradient.GradientNLCG Optimization
Nonlinear conjugate gradient method
Parameters
- type nlcg_max:
int
- param nlcg_max:
NLCG periodic restart interval, should be between 1 and infinity
- type nlcg_thresh:
NLCG conjugacy restart threshold, should be between 1 and infinity
- type calc_beta:
str
- param calc_beta:
method to calculate the parameter ‘beta’ in the NLCG algorithm. Available: ‘pollak_ribere’, ‘fletcher_reeves’
Paths
- __doc__ = Multiline-String
Show Value
""" Gradient Optimization [Optimize Base] ------------------------------------- Defines foundational structure for Optimization module. Applies a gradient/steepest descent optimization algorithm. Parameters ---------- :type line_search_method: str :param line_search_method: chosen line_search algorithm. Currently available are 'bracket' and 'backtrack'. See seisflows.plugins.line_search for all available options :type preconditioner: str :param preconditioner: algorithm for preconditioning gradients. Currently available: 'diagonal'. Requires `path_preconditioner` to point to a set of files that define the preconditioner, formatted the same as the input model :type step_count_max: int :param step_count_max: maximum number of trial steps to perform during the line search before a change in line search behavior is considered, or a line search is considered to have failed. :type step_len_init: float :param step_len_init: initial line search step length guess, provided as a fraction of current model parameters. :type step_len_max: float :param step_len_max: optional, maximum allowable step length during the line search. Set as a fraction of the current model parameters :type step_len_min: float :param step_len_min: optional, minimum allowable step length during the line search. Set as a fraction of the current model parameters Paths ----- :type path_preconditioner: str :param path_preconditioner: optional path to a set of preconditioner files formatted the same as the input model (or output model of solver). Required to exist and contain files if `preconditioner`==True *** Nonlinear conjugate gradient method for optimization """
- NLCG_max
- NLCG_thresh
- calc_beta = 'pollak_ribere'
- _NLCG_iter = 0
- _calc_beta
- checkpoint()
Overwrite default checkpointing to store internal L-BFGS Attributes
- compute_direction()
Compute search direction using the Nonlinear Conjugate Gradient method The potential outcomes when computing direction with NLCG
- First iteration of an NLCG optimization, search direction is
the inverse gradient
- NLCG internal iteration ticks over the maximum allowable number of
iterations, force a restart condition, search direction is the inverse gradient
- New NLCG search direction does not have conjugacy with previous
search direction, force restart, inverse gradient search direction
- New NLCG search direction is not a descent direction,
force restart, inverse gradient search direction
- New NLCG search direction has conjugacy and is a descent direction
and is set as the new search direction.
- Return type:
seisflows.tools.specfem.Model
- Returns:
search direction as a Model instance
- restart()
Overwrite the Base restart class and include a restart of the NLCG
- _fletcher_reeves(g_new, g_old)
One method for calculating beta in the NLCG Algorithm from Fletcher & Reeves, 1964
- Parameters:
g_new (np.array) – new search direction
g_old (np.array) – old search direction
- Return type:
float
- Returns:
beta, the scale factor to apply to the old search direction to determine the new search direction
- _pollak_ribere(g_new, g_old)
One method for calculating beta in the NLCG Algorithm from Polak & Ribiere, 1969
- Parameters:
g_new (np.array) – new search direction
g_old (np.array) – old search direction
- Return type:
float
- Returns:
beta, the scale factor to apply to the old search direction to determine the new search direction
- seisflows.optimize.NLCG.check_conjugacy(g_new, g_old)
Check for conjugacy between two vectors
- Parameters:
g_new (np.array) – new search direction
g_old (np.array) – old search direction
- Return type:
float
- Returns:
an element that proves conjugacy
- seisflows.optimize.NLCG.check_descent(p_new, g_new)
Ensure that the search direction is descending
- Parameters:
p_new (np.array) – search direction
g_new (np.array) – gradient direction
- Return type:
float
- Returns:
the angle between search direction and gradient direction, should be negative to ensure descent