QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LevenbergMarquardt Class Reference

Levenberg-Marquardt optimization method. More...

#include <levenbergmarquardt.hpp>

+ Inheritance diagram for LevenbergMarquardt:
+ Collaboration diagram for LevenbergMarquardt:

Public Member Functions

 LevenbergMarquardt (Real epsfcn=1.0e-8, Real xtol=1.0e-8, Real gtol=1.0e-8, bool useCostFunctionsJacobian=false)
 
EndCriteria::Type minimize (Problem &P, const EndCriteria &endCriteria) override
 minimize the optimization problem P More...
 
virtual Integer getInfo () const
 
void fcn (int m, int n, Real *x, Real *fvec, int *)
 
void jacFcn (int m, int n, Real *x, Real *fjac, int *)
 
- Public Member Functions inherited from OptimizationMethod
virtual ~OptimizationMethod ()=default
 
virtual EndCriteria::Type minimize (Problem &P, const EndCriteria &endCriteria)=0
 minimize the optimization problem P More...
 

Private Member Functions

void fcn (int m, int n, Real *x, Real *fvec)
 
void jacFcn (int m, int n, Real *x, Real *fjac)
 

Private Attributes

ProblemcurrentProblem_
 
Array initCostValues_
 
Matrix initJacobian_
 
Integer info_ = 0
 
const Real epsfcn_
 
const Real xtol_
 
const Real gtol_
 
const bool useCostFunctionsJacobian_
 

Detailed Description

Levenberg-Marquardt optimization method.

This implementation is based on MINPACK (http://www.netlib.org/minpack, http://www.netlib.org/cephes/linalg.tgz) It has a built in fd scheme to compute the jacobian, which is used by default. If useCostFunctionsJacobian is true the corresponding method in the cost function of the problem is used instead. Note that the default implementation of the jacobian in CostFunction uses a central difference (order 2, but requiring more function evaluations) compared to the forward difference implemented here (order 1).

Examples
BermudanSwaption.cpp, and Gaussian1dModels.cpp.

Definition at line 49 of file levenbergmarquardt.hpp.

Constructor & Destructor Documentation

◆ LevenbergMarquardt()

LevenbergMarquardt ( Real  epsfcn = 1.0e-8,
Real  xtol = 1.0e-8,
Real  gtol = 1.0e-8,
bool  useCostFunctionsJacobian = false 
)

Definition at line 29 of file levenbergmarquardt.cpp.

Member Function Documentation

◆ minimize()

EndCriteria::Type minimize ( Problem P,
const EndCriteria endCriteria 
)
overridevirtual

minimize the optimization problem P

Implements OptimizationMethod.

Definition at line 36 of file levenbergmarquardt.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInfo()

virtual Integer getInfo ( ) const
virtual
Deprecated:
Don't use this method; inspect the result of minimize instead. Deprecated in version 1.36.

Definition at line 62 of file levenbergmarquardt.hpp.

◆ fcn() [1/2]

void fcn ( int  m,
int  n,
Real x,
Real fvec,
int *   
)
Deprecated:
Don't use this method; it is for internal use. Deprecated in version 1.37.

Definition at line 68 of file levenbergmarquardt.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ jacFcn() [1/2]

void jacFcn ( int  m,
int  n,
Real x,
Real fjac,
int *   
)
Deprecated:
Don't use this method; it is for internal use. Deprecated in version 1.37.

Definition at line 74 of file levenbergmarquardt.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fcn() [2/2]

void fcn ( int  m,
int  n,
Real x,
Real fvec 
)
private

Definition at line 140 of file levenbergmarquardt.cpp.

+ Here is the call graph for this function:

◆ jacFcn() [2/2]

void jacFcn ( int  m,
int  n,
Real x,
Real fjac 
)
private

Definition at line 153 of file levenbergmarquardt.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ currentProblem_

Problem* currentProblem_
private

Definition at line 79 of file levenbergmarquardt.hpp.

◆ initCostValues_

Array initCostValues_
private

Definition at line 80 of file levenbergmarquardt.hpp.

◆ initJacobian_

Matrix initJacobian_
private

Definition at line 81 of file levenbergmarquardt.hpp.

◆ info_

Integer info_ = 0
mutableprivate

Definition at line 82 of file levenbergmarquardt.hpp.

◆ epsfcn_

const Real epsfcn_
private

Definition at line 83 of file levenbergmarquardt.hpp.

◆ xtol_

const Real xtol_
private

Definition at line 83 of file levenbergmarquardt.hpp.

◆ gtol_

const Real gtol_
private

Definition at line 83 of file levenbergmarquardt.hpp.

◆ useCostFunctionsJacobian_

const bool useCostFunctionsJacobian_
private

Definition at line 84 of file levenbergmarquardt.hpp.