proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
function-base.hpp
Go to the documentation of this file.
1
4#pragma once
5
7
8namespace proxsuite {
9namespace nlp {
13template <typename _Scalar> struct BaseFunctionTpl : math_types<_Scalar> {
14protected:
15 int nx_;
16 int ndx_;
17 int nr_;
18
19public:
20 using Scalar = _Scalar;
22
23 BaseFunctionTpl(const int nx, const int ndx, const int nr)
24 : nx_(nx), ndx_(ndx), nr_(nr) {}
25
27 : BaseFunctionTpl(manifold.nx(), manifold.ndx(), nr) {}
28
30 virtual VectorXs operator()(const ConstVectorRef &x) const = 0;
31
32 virtual ~BaseFunctionTpl() = default;
33
35 int nx() const { return nx_; }
37 int ndx() const { return ndx_; }
39 int nr() const { return nr_; }
40};
41
44template <typename _Scalar>
45struct C1FunctionTpl : public BaseFunctionTpl<_Scalar> {
46public:
47 using Scalar = _Scalar;
50
51 // We can't use using Base::Base because of MSVC explicit template
52 // instantiation
53 C1FunctionTpl(const int nx, const int ndx, const int nr)
54 : Base(nx, ndx, nr) {}
55 C1FunctionTpl(const ManifoldAbstractTpl<Scalar> &manifold, const int nr)
56 : C1FunctionTpl(manifold.nx(), manifold.ndx(), nr) {}
57
59 virtual void computeJacobian(const ConstVectorRef &x,
60 MatrixRef Jout) const = 0;
61
66 MatrixXs computeJacobian(const ConstVectorRef &x) const {
67 MatrixXs Jout(this->nr(), this->ndx());
68 computeJacobian(x, Jout);
69 return Jout;
70 }
71};
72
76template <typename _Scalar>
77struct C2FunctionTpl : public C1FunctionTpl<_Scalar> {
78public:
79 using Scalar = _Scalar;
82
83 // We can't use using Base::Base because of MSVC explicit template
84 // instantiation
85 C2FunctionTpl(const int nx, const int ndx, const int nr)
86 : Base(nx, ndx, nr) {}
87 C2FunctionTpl(const ManifoldAbstractTpl<Scalar> &manifold, const int nr)
88 : C2FunctionTpl(manifold.nx(), manifold.ndx(), nr) {}
89
91 virtual void vectorHessianProduct(const ConstVectorRef &,
92 const ConstVectorRef &,
93 MatrixRef Hout) const {
94 Hout.setZero();
95 }
96};
97
98} // namespace nlp
99} // namespace proxsuite
100
101#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
102#include "proxsuite-nlp/function-base.txx"
103#endif
Forward declarations and configuration macros.
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
Base function type.
Definition fwd.hpp:70
virtual VectorXs operator()(const ConstVectorRef &x) const =0
Evaluate the residual at a given point x.
BaseFunctionTpl(const ManifoldAbstractTpl< Scalar > &manifold, const int nr)
BaseFunctionTpl(const int nx, const int ndx, const int nr)
int ndx() const
Get input manifold's tangent space dimension.
int nr() const
Get function codimension.
int nx() const
Get function input vector size (representation of manifold).
virtual ~BaseFunctionTpl()=default
Differentiable function, with method for the Jacobian.
Definition fwd.hpp:73
virtual void computeJacobian(const ConstVectorRef &x, MatrixRef Jout) const =0
Jacobian matrix of the constraint function.
C1FunctionTpl(const ManifoldAbstractTpl< Scalar > &manifold, const int nr)
C1FunctionTpl(const int nx, const int ndx, const int nr)
MatrixXs computeJacobian(const ConstVectorRef &x) const
Jacobian matrix of the constraint function.
Twice-differentiable function, with method Jacobian and vector-hessian product evaluation.
Definition fwd.hpp:76
C2FunctionTpl(const ManifoldAbstractTpl< Scalar > &manifold, const int nr)
C2FunctionTpl(const int nx, const int ndx, const int nr)
virtual void vectorHessianProduct(const ConstVectorRef &, const ConstVectorRef &, MatrixRef Hout) const
Vector-hessian product.