# Path: nlp/tools/exceptions.py
# class LineSearchFailure(Exception):
#     """Exception raised when a linesearch fails."""
# 
#     pass


from math import sqrt
from nlp.tools.exceptions import LineSearchFailure
import numpy as np
        """Initialize a linesearch method.

        :parameters:
            :linemodel: ``C1LineModel`` or ``C2LineModel`` instance

        :keywords:
            :step: initial step size (default: 1.0)
            :value: initial function value (computed if not supplied)
            :slope: initial slope (computed if not supplied)
            :trial_value: function value at `x + t*d`
                          (computed if not supplied)
            :name: linesearch procedure name.
        """
        self.__linemodel = linemodel
        self.__name = name

        self._value = kwargs.get("value", None)
        if self._value is None:
            self._value = linemodel.obj(0)

        self._slope = kwargs.get("slope", None)
        if self._slope is None:
            self._slope = linemodel.grad(0)
        self.check_slope(self.slope)

        self._step0 = max(kwargs.get("step", 1.0), 0)
        self._step = self._step0

        self._stepmin = sqrt(eps) / 100
        if self._step <= self.stepmin:

# Path: nlp/tools/exceptions.py
# class LineSearchFailure(Exception):
#     """Exception raised when a linesearch fails."""
# 
#     pass


# Path: nlp/ls/linesearch.py
from math import sqrt
from nlp.tools.exceptions import LineSearchFailure
import numpy as np

        """Initialize a linesearch method.

        :parameters:
            :linemodel: ``C1LineModel`` or ``C2LineModel`` instance

        :keywords:
            :step: initial step size (default: 1.0)
            :value: initial function value (computed if not supplied)
            :slope: initial slope (computed if not supplied)
            :trial_value: function value at `x + t*d`
                          (computed if not supplied)
            :name: linesearch procedure name.
        """
        self.__linemodel = linemodel
        self.__name = name

        self._value = kwargs.get("value", None)
        if self._value is None:
            self._value = linemodel.obj(0)

        self._slope = kwargs.get("slope", None)
        if self._slope is None:
            self._slope = linemodel.grad(0)
        self.check_slope(self.slope)

        self._step0 = max(kwargs.get("step", 1.0), 0)
        self._step = self._step0

        self._stepmin = sqrt(eps) / 100
        if self._step <= self.stepmin:

            raise LineSearchFailure("initial linesearch step too small")