Line data Source code
1 : #pragma once 2 : 3 : #include "LineSearchMethod.h" 4 : 5 : namespace elsa 6 : { 7 : /** 8 : * @brief Armijo Condition (Backtracking) 9 : * 10 : * ArmijoCondition is a line search method attempting to find a step size 11 : * @f$\alpha@f$ that satisfies the sufficient decrease condition (also known as the Armijo 12 : * Condition): 13 : * 14 : * @f[ 15 : * f(x_i+\alpha d_i) \le f(x_i) + c \alpha \nabla f_i^T d_i 16 : * @f] 17 : * 18 : * where @f$f: \mathbb{R}^n \to \mathbb{R}@f$ is differentiable, 19 : * @f$\nabla f_i: \mathbb{R}^n is the gradient of f at x_i@f$, 20 : * @f$ d_i: \mathbb{R}^n is the search direction @f$, and 21 : * @f$ c: is a constant @f$. 22 : * 23 : * References: 24 : * - See Wright and Nocedal, ‘Numerical Optimization’, 2nd Edition, 2006, pp. 33-37. 25 : * 26 : * @author 27 : * - Said Alghabra - initial code 28 : * 29 : * @tparam data_t data type for the domain and range of the problem, defaulting to real_t 30 : */ 31 : template <typename data_t = real_t> 32 : class ArmijoCondition : public LineSearchMethod<data_t> 33 : { 34 : public: 35 : ArmijoCondition(const Functional<data_t>& problem, data_t amax = 2, data_t c = 0.1, 36 : data_t rho = 0.5, index_t max_iterations = 10); 37 8 : ~ArmijoCondition() override = default; 38 : 39 : /// make copy constructor deletion explicit 40 : ArmijoCondition(const ArmijoCondition<data_t>&) = delete; 41 : 42 : data_t solve(DataContainer<data_t> xi, DataContainer<data_t> di) override; 43 : 44 : /// implement the polymorphic comparison operation 45 : bool isEqual(const LineSearchMethod<data_t>& other) const override; 46 : 47 : private: 48 : // initial guess and largest allowed step size 49 : data_t _amax; 50 : 51 : // parameter affecting the sufficient decrease condition 52 : data_t _c; 53 : 54 : // reduction factor for the next step size guess 55 : data_t _rho; 56 : 57 : /// implement the polymorphic clone operation 58 : ArmijoCondition<data_t>* cloneImpl() const override; 59 : }; 60 : } // namespace elsa