34 Array diff = target - fct2fit;
45 Array diff = target - fct2fit;
50 const Array& x)
const {
58 Array diff = target - fct2fit;
60 grad_f = -2.0*(
transpose(grad_fct2fit)*diff);
64 const Array& x)
const {
72 Array diff = target - fct2fit;
74 grad_f = -2.0*(
transpose(grad_fct2fit)*diff);
82 : exitFlag_(-1), accuracy_ (accuracy), maxIterations_ (maxiter),
90 ext::shared_ptr<OptimizationMethod> om)
91 : exitFlag_(-1), accuracy_(accuracy), maxIterations_(maxiter), om_(
std::move(om)),
c_(c) {}
1-D array used in linear algebra.
Size size() const
dimension of the array
Multi-dimensional Conjugate Gradient class.
Criteria to end optimization process:
Cost function for least-square problems.
Real value(const Array &x) const override
compute value of the least square function
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
Matrix used in linear algebra.
ext::shared_ptr< OptimizationMethod > om_
Optimization method.
NonLinearLeastSquare(Constraint &c, Real accuracy=1e-4, Size maxiter=100)
Default constructor.
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 resnorm_
least square residual norm
Size maxIterations_
maximum and real number of iterations
Abstract class for constrained optimization method.
Constrained optimization problem.
const Array & currentValue() const
current value of the local minimum
Real functionValue() const
value of cost function
Conjugate gradient optimization method.
std::size_t Size
size of a container
Least square cost function.
Matrix transpose(const Matrix &m)
Real DotProduct(const Array &v1, const Array &v2)
Abstract optimization problem class.