QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
levenbergmarquardt.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 Klaus Spanderen
5 Copyright (C) 2015 Peter Caspers
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file levenbergmarquardt.hpp
22 \brief Levenberg-Marquardt optimization method
23*/
24
25#ifndef quantlib_optimization_levenberg_marquardt_hpp
26#define quantlib_optimization_levenberg_marquardt_hpp
27
29
30namespace QuantLib {
31
32 //! Levenberg-Marquardt optimization method
33 /*! This implementation is based on MINPACK
34 (<http://www.netlib.org/minpack>,
35 <http://www.netlib.org/cephes/linalg.tgz>)
36 It has a built in fd scheme to compute
37 the jacobian, which is used by default.
38 If useCostFunctionsJacobian is true the
39 corresponding method in the cost function
40 of the problem is used instead. Note that
41 the default implementation of the jacobian
42 in CostFunction uses a central difference
43 (oder 2, but requiring more function
44 evaluations) compared to the forward
45 difference implemented here (order 1).
46
47 \ingroup optimizers
48 */
50 public:
51 LevenbergMarquardt(Real epsfcn = 1.0e-8,
52 Real xtol = 1.0e-8,
53 Real gtol = 1.0e-8,
54 bool useCostFunctionsJacobian = false);
56 const EndCriteria& endCriteria //= EndCriteria()
57 ) override;
58 // = EndCriteria(400, 1.0e-8, 1.0e-8)
59 virtual Integer getInfo() const;
60 void fcn(int m,
61 int n,
62 Real* x,
63 Real* fvec,
64 int* iflag);
65 void jacFcn(int m,
66 int n,
67 Real* x,
68 Real* fjac,
69 int* iflag);
70
71 private:
75 mutable Integer info_ = 0;
78 };
79
80}
81
82
83#endif
1-D array used in linear algebra.
Definition: array.hpp:52
Criteria to end optimization process:
Definition: endcriteria.hpp:40
Levenberg-Marquardt optimization method.
void fcn(int m, int n, Real *x, Real *fvec, int *iflag)
virtual Integer getInfo() const
void jacFcn(int m, int n, Real *x, Real *fjac, int *iflag)
EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria) override
minimize the optimization problem P
Matrix used in linear algebra.
Definition: matrix.hpp:41
Abstract class for constrained optimization method.
Definition: method.hpp:36
Constrained optimization problem.
Definition: problem.hpp:42
QL_REAL Real
real number
Definition: types.hpp:50
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Definition: any.hpp:35
Abstract optimization problem class.