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