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

Levenberg-Marquardt optimization method. More...

#include <ql/math/optimization/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 *iflag)
 
void jacFcn (int m, int n, Real *x, Real *fjac, int *iflag)
 
- 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 Attributes

ProblemcurrentProblem_
 
Array initCostValues_
 
Matrix initJacobian_
 
Integer info_ = 0
 
const Real epsfcn_
 
const Real xtol_
 
const Real gtol_
 
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 (oder 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 40 of file levenbergmarquardt.cpp.

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

◆ getInfo()

Integer getInfo ( ) const
virtual

Definition at line 36 of file levenbergmarquardt.cpp.

◆ fcn()

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

Definition at line 130 of file levenbergmarquardt.cpp.

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

◆ jacFcn()

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

Definition at line 143 of file levenbergmarquardt.cpp.

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

Member Data Documentation

◆ currentProblem_

Problem* currentProblem_
private

Definition at line 72 of file levenbergmarquardt.hpp.

◆ initCostValues_

Array initCostValues_
private

Definition at line 73 of file levenbergmarquardt.hpp.

◆ initJacobian_

Matrix initJacobian_
private

Definition at line 74 of file levenbergmarquardt.hpp.

◆ info_

Integer info_ = 0
mutableprivate

Definition at line 75 of file levenbergmarquardt.hpp.

◆ epsfcn_

const Real epsfcn_
private

Definition at line 76 of file levenbergmarquardt.hpp.

◆ xtol_

const Real xtol_
private

Definition at line 76 of file levenbergmarquardt.hpp.

◆ gtol_

const Real gtol_
private

Definition at line 76 of file levenbergmarquardt.hpp.

◆ useCostFunctionsJacobian_

bool useCostFunctionsJacobian_
private

Definition at line 77 of file levenbergmarquardt.hpp.