seisflows.plugins.line_search.bracket
A bracketing line search (a.k.a direct line search) attempts to find an appropriate step length by identifying two points between which the minimum misfit lies. Contains some functionality for saving line search history to disk so that a line search may be resumed in the case of a failure/reset.
https://en.wikipedia.org/wiki/Line_search
Note
Line search is called on by the optimization procedure and should not really have any agency (i.e. it should not be able to iterate its own step count etc., this should be completely left to the optimization algorithm to keep everything in one place)
Module Contents
Classes
[line_search.bracket] The bracketing line search identifies two points |
Functions
|
Checks if minimum has been bracketed |
|
Checks if step length is reasonably close to quadratic estimate |
- class seisflows.plugins.line_search.bracket.Bracket(step_count_max, step_len_max, path=None)
[line_search.bracket] The bracketing line search identifies two points between which the minimum misfit lies between.
- Parameters
step_count_max (int) – maximum number of step counts before changing line search behavior. set by PAR.STEP_COUNT_MAX
step_len_max (int) – maximum length of the step, defaults to infinity, that is unbounded step length. set by PAR.STEP_LEN_MAX
- update_search_history(func_val, step_len, gtg=None, gtp=None)
Update the internal list of search history attributes. Lists like func_vals get appended to, while values like step_count are overwritten. Allowed to increment func_val and step_len by themselves
- clear_search_history()
Clears internal line search history for a new line search attempt
- check_search_history()
Since the line search is just a wrapper for list of numbers, check that search history hasn’t been muddled up by ensuring that internal lists are the correct length for the given evaluation
- get_search_history(sort=True)
A convenience function, collects information based on the current evaluation of the line search, needed to determine search status and calculate step length. From the full collection of the search history, only returns values relevant to the current line search.
- Parameters
sort (bool) – sort the search history by step length
- Rtype x
np.array
- Return x
list of step lenths from current line search
- Rtype f
np.array
- Return f
correpsonding list of function values
- Rtype gtg
list
- Return gtg
dot product dot product of gradient with itself
- Rtype gtp
list
- Return gtp
dot product of gradient and search direction
- Rtype i
int
- Return i
step_count
- Rtype j
int
- Return j
number of iterations corresponding to 0 step length, i.e., the update count
- _print_stats(x, f)
Print out misfit values and step lengths to the logger
- calculate_step_length()
Determines step length (alpha) and search status (status) using a bracketing line search. Evaluates Wolfe conditions to determine if a step length is acceptable.
- Return type
tuple (float, str)
- Returns
(alpha==calculated step length, status==how to treat the next step count evaluation)
- seisflows.plugins.line_search.bracket._check_bracket(step_lens, func_vals)
Checks if minimum has been bracketed
Looks at the minimum of the misfit values calculated through eval func to see if the misfit has been reduced w.r.t the initial misfit
- Parameters
step_lens (numpy.array) – an array of the step lengths taken during iteration
func_vals (numpy.array) – array of misfit values from eval func function
- Return type
bool
- Returns
status of function as a bool
- seisflows.plugins.line_search.bracket._good_enough(step_lens, func_vals, thresh=np.log10(1.2))
Checks if step length is reasonably close to quadratic estimate
- Parameters
step_lens (np.array) – an array of the step lengths taken during iteration
func_vals (np.array) – array of misfit values from eval func function
thresh (numpy.float64) – threshold value for comparison against quadratic estimate
- Return type
bool
- Returns
status of function as a bool