Source code for secml.optim.optimizers.line_search.c_line_search

.. module:: CLineSearch
   :synopsis: Interface for line search methods.

.. moduleauthor:: Battista Biggio <>

from abc import ABCMeta, abstractmethod

from secml.core import CCreator
from secml.array import CArray

[docs]class CLineSearch(CCreator, metaclass=ABCMeta): """Abstract class that implements line-search optimization algorithms. Line-search algorithms optimize the objective function along a given direction in the feasible domain, potentially subject to constraints. The search is normally stopped when the objective improves at a satisfying level, to keep the search fast. """ __super__ = 'CLineSearch' def __init__(self, fun, constr=None, bounds=None, eta=1e-4, max_iter=20): # Sets the initial value of step and max number of iterations. = fun self.constr = constr self.bounds = bounds self.eta = CArray(eta) self.max_iter = max_iter
[docs] @abstractmethod def minimize(self, x, d, **kwargs): """Line search. Parameters ---------- x : CArray The input point. d : CArray The descent direction along which fun(x) is minimized. kwargs : dict Additional parameters required to evaluate `fun(x, **kwargs)`. """ raise NotImplementedError