forte2.helpers.lbfgs ==================== .. py:module:: forte2.helpers.lbfgs Module Contents --------------- .. py:class:: LBFGS Limited-memory Broyden-Fletcher-Goldfarb-Shanno (L-BFGS) optimizer. :Parameters: **m** : int, optional, default=6 The number of vectors to keep in memory for the L-BFGS update. **epsilon** : float, optional, default=1.0e-5 Convergence threshold to terminate the minimization: |g| < ε * max(1, |x|). **maxiter** : int, optional, default=20 Maximum number of iterations for the optimization. **maxiter_linesearch** : int, optional, default=5 Maximum number of trials for line search to find the optimal step length. **max_dir** : float, optional, default=1.0e15 Maximum absolute value allowed in the direction vector. **line_search_condition** : str, optional, default='strong_wolfe' Condition to terminate line search backtracking. Options are 'armijo', 'wolfe', or 'strong_wolfe'. **step_length_method** : str, optional, default='line_bracketing_zoom' Method to determine step lengths. Options are 'max_correction', 'line_backtracking', or 'line_bracketing_zoom'. **min_step** : float, optional, default=1.0e-15 Minimum step length allowed during line search. **max_step** : float, optional, default=1.0e15 Maximum step length allowed during line search. **c1** : float, optional, default=1.0e-4 Parameter for the Armijo condition in line search. **c2** : float, optional, default=0.9 Parameter for the Wolfe curvature condition in line search. .. rubric:: Notes Translated into Python from Forte v1: https://github.com/evangelistalab/forte/tree/main/forte/helpers/lbfgs For implementation details, see Wikipedia https://en.wikipedia.org/wiki/Limited-memory_BFGS and Numerical Optimization 2nd Ed. by Jorge Nocedal and Stephen J. Wright .. !! processed by numpydoc !! .. py:attribute:: m :type: int :value: 6 .. py:attribute:: epsilon :type: float :value: 1e-05 .. py:attribute:: maxiter :type: int :value: 20 .. py:attribute:: maxiter_linesearch :type: int :value: 5 .. py:attribute:: max_dir :type: float :value: 1000000000000000.0 .. py:attribute:: line_search_condition :type: str :value: 'strong_wolfe' .. py:attribute:: step_length_method :type: str :value: 'line_bracketing_zoom' .. py:attribute:: min_step :type: float :value: 1e-15 .. py:attribute:: max_step :type: float :value: 1000000000000000.0 .. py:attribute:: c1 :type: float :value: 0.0001 .. py:attribute:: c2 :type: float :value: 0.9 .. py:attribute:: log_level :type: int .. py:attribute:: warn_if_not_converged :type: bool :value: False .. py:attribute:: dtype :type: type .. py:attribute:: converged :type: bool :value: False .. py:attribute:: iter :type: int :value: 0 .. py:attribute:: p :type: numpy.typing.NDArray .. py:method:: minimize(obj, x) The minimization for the objective function :Parameters: **obj** : object Target function to minimize, it should should be encapsulated in a class that has the following methods: ``fx, g = obj.evaluate(x, g, do_g=True)`` where gradient ``g`` is modified by the function, ``fx`` is the function return value, and ``g`` is computed when ``do_g==True``. If diagonal Hessian is specified, ``h0 = obj.hess_diag(x)`` should be available. **x** : NDArray The initial value of ``x`` as input, the final value of ``x`` as output. :Returns: **fx** : float The function value at optimized ``x``. .. !! processed by numpydoc !! .. py:class:: LBFGS_scipy A wrapper for the SciPy L-BFGS optimization. For debug use only. .. !! processed by numpydoc !! .. py:attribute:: epsilon :type: float :value: 1e-05 .. py:attribute:: maxiter :type: int :value: 20 .. py:attribute:: c1 :type: float :value: 0.0001 .. py:attribute:: c2 :type: float :value: 0.9 .. py:attribute:: print :type: int :value: 1 .. py:attribute:: m :type: int :value: 6 .. py:attribute:: maxiter_linesearch :type: int :value: 5 .. py:attribute:: max_dir :type: float :value: 1000000000000000.0 .. py:attribute:: line_search_condition :type: str :value: 'strong_wolfe' .. py:attribute:: step_length_method :type: str :value: 'line_bracketing_zoom' .. py:attribute:: min_step :type: float :value: 1e-15 .. py:attribute:: max_step :type: float :value: 1000000000000000.0 .. py:method:: minimize(obj, x) .. py:class:: NewtonRaphson .. py:attribute:: epsilon :type: float :value: 1e-05 .. py:attribute:: maxiter :type: int :value: 20 .. py:attribute:: c1 :type: float :value: 0.0001 .. py:attribute:: c2 :type: float :value: 0.9 .. py:attribute:: print :type: int :value: 1 .. py:attribute:: m :type: int :value: 6 .. py:attribute:: maxiter_linesearch :type: int :value: 5 .. py:attribute:: max_dir :type: float :value: 1000000000000000.0 .. py:attribute:: line_search_condition :type: str :value: 'strong_wolfe' .. py:attribute:: step_length_method :type: str :value: 'line_bracketing_zoom' .. py:attribute:: min_step :type: float :value: 1e-15 .. py:attribute:: max_step :type: float :value: 1000000000000000.0 .. py:method:: minimize(obj, x)