Coverage Report

Created: 2025-08-05 06:45

/src/quantlib/ql/math/optimization/goldstein.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2015 Cheng Li
5
 This file is part of QuantLib, a free-software/open-source library
6
 for financial quantitative analysts and developers - http://quantlib.org/
7
8
 QuantLib is free software: you can redistribute it and/or modify it
9
 under the terms of the QuantLib license.  You should have received a
10
 copy of the license along with this program; if not, please email
11
 <quantlib-dev@lists.sf.net>. The license is also available online at
12
 <http://quantlib.org/license.shtml>.
13
14
 This program is distributed in the hope that it will be useful, but WITHOUT
15
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16
 FOR A PARTICULAR PURPOSE.  See the license for more details.
17
*/
18
19
/*! \file goldstein.hpp
20
    \brief Goldstein and Price line-search class
21
*/
22
23
#ifndef quantlib_optimization_goldstein_hpp
24
#define quantlib_optimization_goldstein_hpp
25
26
#include <ql/math/optimization/linesearch.hpp>
27
28
namespace QuantLib {
29
30
    class GoldsteinLineSearch : public LineSearch {
31
      public:
32
        //! Default constructor
33
        GoldsteinLineSearch(Real eps = 1e-8,
34
                            Real alpha = 0.05,
35
                            Real beta = 0.65,
36
                            Real extrapolation = 1.5)
37
0
        : LineSearch(eps), alpha_(alpha), beta_(beta), extrapolation_(extrapolation) {}
38
39
        //! Perform line search
40
        Real operator()(Problem& P, // Optimization problem
41
                        EndCriteria::Type& ecType,
42
                        const EndCriteria&,
43
                        Real t_ini) override; // initial value of line-search step
44
45
      private:
46
        Real alpha_, beta_;
47
        Real extrapolation_;
48
    };
49
50
}
51
52
#endif