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

Non-linear least-square method. More...

#include <leastsquare.hpp>

+ Collaboration diagram for NonLinearLeastSquare:

Public Member Functions

 NonLinearLeastSquare (Constraint &c, Real accuracy=1e-4, Size maxiter=100)
 Default constructor. More...
 
 NonLinearLeastSquare (Constraint &c, Real accuracy, Size maxiter, ext::shared_ptr< OptimizationMethod > om)
 Default constructor. More...
 
 ~NonLinearLeastSquare ()=default
 Destructor. More...
 
Arrayperform (LeastSquareProblem &lsProblem)
 Solve least square problem using numerix solver. More...
 
void setInitialValue (const Array &initialValue)
 
Arrayresults ()
 return the results More...
 
Real residualNorm () const
 return the least square residual norm More...
 
Real lastValue () const
 return last function value More...
 
Integer exitFlag () const
 return exit flag More...
 
Integer iterationsNumber () const
 return the performed number of iterations More...
 

Private Attributes

Array results_
 solution vector More...
 
Array initialValue_
 
Real resnorm_
 least square residual norm More...
 
Integer exitFlag_
 Exit flag of the optimization process. More...
 
Real accuracy_
 required accuracy of the solver More...
 
Real bestAccuracy_
 
Size maxIterations_
 maximum and real number of iterations More...
 
Size nbIterations_
 
ext::shared_ptr< OptimizationMethodom_
 Optimization method. More...
 
Constraintc_
 

Detailed Description

Non-linear least-square method.

Using a given optimization algorithm (default is conjugate gradient),

\[ min \{ r(x) : x in R^n \} \]

where \( r(x) = |f(x)|^2 \) is the Euclidean norm of \( f(x) \) for some vector-valued function \( f \) from \( R^n \) to \( R^m \),

\[ f = (f_1, ..., f_m) \]

with \( f_i(x) = b_i - \phi(x,t_i) \) where \( b \) is the vector of target data and \( phi \) is a scalar function.

Assuming the differentiability of \( f \), the gradient of \( r \) is defined by

\[ grad r(x) = f'(x)^t.f(x) \]

Definition at line 97 of file leastsquare.hpp.

Constructor & Destructor Documentation

◆ NonLinearLeastSquare() [1/2]

NonLinearLeastSquare ( Constraint c,
Real  accuracy = 1e-4,
Size  maxiter = 100 
)

Default constructor.

Definition at line 79 of file leastsquare.cpp.

◆ NonLinearLeastSquare() [2/2]

NonLinearLeastSquare ( Constraint c,
Real  accuracy,
Size  maxiter,
ext::shared_ptr< OptimizationMethod om 
)

Default constructor.

Definition at line 87 of file leastsquare.cpp.

◆ ~NonLinearLeastSquare()

~NonLinearLeastSquare ( )
default

Destructor.

Member Function Documentation

◆ perform()

Array & perform ( LeastSquareProblem lsProblem)

Solve least square problem using numerix solver.

Definition at line 93 of file leastsquare.cpp.

+ Here is the call graph for this function:

◆ setInitialValue()

void setInitialValue ( const Array initialValue)

Definition at line 114 of file leastsquare.hpp.

◆ results()

Array & results ( )

return the results

Definition at line 119 of file leastsquare.hpp.

◆ residualNorm()

Real residualNorm ( ) const

return the least square residual norm

Definition at line 122 of file leastsquare.hpp.

◆ lastValue()

Real lastValue ( ) const

return last function value

Definition at line 125 of file leastsquare.hpp.

◆ exitFlag()

Integer exitFlag ( ) const

return exit flag

Definition at line 128 of file leastsquare.hpp.

◆ iterationsNumber()

Integer iterationsNumber ( ) const

return the performed number of iterations

Definition at line 131 of file leastsquare.hpp.

Member Data Documentation

◆ results_

Array results_
private

solution vector

Definition at line 135 of file leastsquare.hpp.

◆ initialValue_

Array initialValue_
private

Definition at line 135 of file leastsquare.hpp.

◆ resnorm_

Real resnorm_
private

least square residual norm

Definition at line 137 of file leastsquare.hpp.

◆ exitFlag_

Integer exitFlag_
private

Exit flag of the optimization process.

Definition at line 139 of file leastsquare.hpp.

◆ accuracy_

Real accuracy_
private

required accuracy of the solver

Definition at line 141 of file leastsquare.hpp.

◆ bestAccuracy_

Real bestAccuracy_
private

Definition at line 141 of file leastsquare.hpp.

◆ maxIterations_

Size maxIterations_
private

maximum and real number of iterations

Definition at line 143 of file leastsquare.hpp.

◆ nbIterations_

Size nbIterations_
private

Definition at line 143 of file leastsquare.hpp.

◆ om_

ext::shared_ptr<OptimizationMethod> om_
private

Optimization method.

Definition at line 145 of file leastsquare.hpp.

◆ c_

Constraint& c_
private

Definition at line 147 of file leastsquare.hpp.