proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
quadratic-residual.hpp
Go to the documentation of this file.
1
3#pragma once
4
7
8namespace proxsuite {
9namespace nlp {
10
21template <typename _Scalar>
23public:
24 using Scalar = _Scalar;
25 using FunctionType = C2FunctionTpl<Scalar>; // base constraint func to use
27 using RowMatrixXs = Eigen::Matrix<Scalar, -1, -1, Eigen::RowMajor>;
31 using FunctionPtr = shared_ptr<FunctionType>;
32
36 MatrixXs weights_;
38 VectorXs slope_;
42
43 QuadraticResidualCostTpl(FunctionPtr residual, const ConstMatrixRef &weights,
44 const ConstVectorRef &slope,
45 const Scalar constant = Scalar(0.));
46
47 QuadraticResidualCostTpl(FunctionPtr residual, const ConstMatrixRef &weights,
48 const Scalar constant = Scalar(0.))
49 : QuadraticResidualCostTpl(residual, weights,
50 VectorXs::Zero(residual->nr()), constant) {}
51
54 template <typename Underlying, typename... ResidualArgs>
55 QuadraticResidualCostTpl(const ConstMatrixRef &weights,
56 const ConstVectorRef &slope, const Scalar constant,
57 ResidualArgs &...args)
58 : QuadraticResidualCostTpl(std::make_shared<Underlying>(args...), weights,
59 slope, constant) {}
60
61 Scalar call(const ConstVectorRef &x) const;
62
63 void computeGradient(const ConstVectorRef &x, VectorRef out) const;
64
65 void computeHessian(const ConstVectorRef &x, MatrixRef out) const;
66
67protected:
68 mutable VectorXs err;
69 mutable VectorXs tmp_w_err;
70 mutable MatrixXs Jres;
72 mutable MatrixXs H;
73};
74
75} // namespace nlp
76} // namespace proxsuite
77
78#include "proxsuite-nlp/modelling/costs/quadratic-residual.hxx"
79
80#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
81#include "proxsuite-nlp/modelling/costs/quadratic-residual.txx"
82#endif
Base definitions for function classes.
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
Twice-differentiable function, with method Jacobian and vector-hessian product evaluation.
Definition fwd.hpp:76
Base class for differentiable cost functions.
Definition fwd.hpp:89
virtual void computeHessian(const ConstVectorRef &x, MatrixRef out) const =0
virtual void computeGradient(const ConstVectorRef &x, VectorRef out) const =0
Quadratic function of a residual.
QuadraticResidualCostTpl(const ConstMatrixRef &weights, const ConstVectorRef &slope, const Scalar constant, ResidualArgs &...args)
Constructor using the template parameter as the underlying type of the residual.
void computeGradient(const ConstVectorRef &x, VectorRef out) const
Scalar call(const ConstVectorRef &x) const
Evaluate the cost function.
QuadraticResidualCostTpl(FunctionPtr residual, const ConstMatrixRef &weights, const Scalar constant=Scalar(0.))
void computeHessian(const ConstVectorRef &x, MatrixRef out) const
QuadraticResidualCostTpl(FunctionPtr residual, const ConstMatrixRef &weights, const ConstVectorRef &slope, const Scalar constant=Scalar(0.))
FunctionPtr residual_
Residual function the composite cost is constructed over.
Eigen::Matrix< Scalar, -1, -1, Eigen::RowMajor > RowMatrixXs