# 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
        name = kwargs.pop("name", "Armijo linesearch")
        super(ArmijoLineSearch, self).__init__(*args, name=name, **kwargs)
        self.__ftol = max(min(kwargs.get("ftol", 1.0e-4), 1 - sqeps), sqeps)
        self.__bkmax = max(kwargs.get("bkmax", 20), 0)
        self.__decr = max(min(kwargs.get("decr", 1.5), 100), 1.001)
        self._bk = 0
        return

    @property
    def ftol(self):
        return self.__ftol

    @property
    def bkmax(self):
        return self.__bkmax

    @property
    def decr(self):
        return self.__decr

    @property
    def bk(self):
        return self._bk

    def next(self):
        if self.trial_value <= self.value + self.step * self.ftol * self.slope:
            raise StopIteration()

        self._bk += 1
        if self._bk > self.__bkmax:

# 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

        name = kwargs.pop("name", "Armijo linesearch")
        super(ArmijoLineSearch, self).__init__(*args, name=name, **kwargs)
        self.__ftol = max(min(kwargs.get("ftol", 1.0e-4), 1 - sqeps), sqeps)
        self.__bkmax = max(kwargs.get("bkmax", 20), 0)
        self.__decr = max(min(kwargs.get("decr", 1.5), 100), 1.001)
        self._bk = 0
        return

    @property
    def ftol(self):
        return self.__ftol

    @property
    def bkmax(self):
        return self.__bkmax

    @property
    def decr(self):
        return self.__decr

    @property
    def bk(self):
        return self._bk

    def next(self):
        if self.trial_value <= self.value + self.step * self.ftol * self.slope:
            raise StopIteration()

        self._bk += 1
        if self._bk > self.__bkmax:

            raise LineSearchFailure("backtracking limit exceeded")