25#ifndef quantlib_least_square_hpp
26#define quantlib_least_square_hpp
35 class OptimizationMethod;
101 Real accuracy = 1e-4,
107 ext::shared_ptr<OptimizationMethod> om);
145 ext::shared_ptr<OptimizationMethod>
om_;
1-D array used in linear algebra.
Cost function abstract class for optimization problem.
Cost function for least-square problems.
~LeastSquareFunction() override=default
Destructor.
Real value(const Array &x) const override
compute value of the least square function
LeastSquareFunction(LeastSquareProblem &lsp)
Default constructor.
LeastSquareProblem & lsp_
least square problem
Array values(const Array &) const override
method to overload to compute the cost function values in x
void gradient(Array &grad_f, const Array &x) const override
compute vector of derivatives of the least square function
Real valueAndGradient(Array &grad_f, const Array &x) const override
compute value and gradient of the least square function
Base class for least square problem.
virtual void targetAndValue(const Array &x, Array &target, Array &fct2fit)=0
compute the target vector and the values of the function to fit
virtual void targetValueAndGradient(const Array &x, Matrix &grad_fct2fit, Array &target, Array &fct2fit)=0
virtual Size size()=0
size of the problem ie size of target vector
virtual ~LeastSquareProblem()=default
Matrix used in linear algebra.
Non-linear least-square method.
Integer exitFlag() const
return exit flag
void setInitialValue(const Array &initialValue)
Real lastValue() const
return last function value
Array & results()
return the results
ext::shared_ptr< OptimizationMethod > om_
Optimization method.
Real accuracy_
required accuracy of the solver
Integer exitFlag_
Exit flag of the optimization process.
Array & perform(LeastSquareProblem &lsProblem)
Solve least square problem using numerix solver.
Array results_
solution vector
Real residualNorm() const
return the least square residual norm
Real resnorm_
least square residual norm
~NonLinearLeastSquare()=default
Destructor.
Integer iterationsNumber() const
return the performed number of iterations
Size maxIterations_
maximum and real number of iterations
Conjugate gradient optimization method.
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
matrix used in linear algebra.
Abstract optimization problem class.