proxsuite-nlp  0.10.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
Loading...
Searching...
No Matches
manifold-base.hpp
Go to the documentation of this file.
1
3#pragma once
4
6
7namespace proxsuite {
8namespace nlp {
9
13template <typename _Scalar, int _Options> struct ManifoldAbstractTpl {
14public:
15 using Scalar = _Scalar;
16 static constexpr int Options = _Options;
17
19
20 virtual ~ManifoldAbstractTpl() = default;
21
23 virtual int nx() const = 0;
25 virtual int ndx() const = 0;
26
29 virtual VectorXs neutral() const { return VectorXs::Zero(nx()); }
31 virtual VectorXs rand() const { return VectorXs::Random(nx()); }
34 virtual bool isNormalized(const ConstVectorRef & /*x*/) const { return true; }
35
38
41 return TangentSpaceType(this->ndx());
42 }
43
45
47 void integrate(const ConstVectorRef &x, const ConstVectorRef &v,
48 VectorRef out) const;
49
51 void Jintegrate(const ConstVectorRef &x, const ConstVectorRef &v,
52 MatrixRef Jout, int arg) const;
53
56 virtual void JintegrateTransport(const ConstVectorRef &x,
57 const ConstVectorRef &v, MatrixRef Jout,
58 int arg) const = 0;
59
61 void difference(const ConstVectorRef &x0, const ConstVectorRef &x1,
62 VectorRef out) const;
63
65 void Jdifference(const ConstVectorRef &x0, const ConstVectorRef &x1,
66 MatrixRef Jout, int arg) const;
67
68 void interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1,
69 const Scalar &u, VectorRef out) const;
70
73
77 VectorXs integrate(const ConstVectorRef &x, const ConstVectorRef &v) const {
78 VectorXs out(nx());
79 integrate_impl(x, v, out);
80 return out;
81 }
82
86 VectorXs difference(const ConstVectorRef &x0,
87 const ConstVectorRef &x1) const {
88 VectorXs out(ndx());
89 difference_impl(x0, x1, out);
90 return out;
91 }
92
94 VectorXs interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1,
95 const Scalar &u) const {
96 VectorXs out(nx());
97 interpolate_impl(x0, x1, u, out);
98 return out;
99 }
100
102
103protected:
105 virtual void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
106 VectorRef out) const = 0;
107
108 virtual void Jintegrate_impl(const ConstVectorRef &x, const ConstVectorRef &v,
109 MatrixRef Jout, int arg) const = 0;
110
112 virtual void difference_impl(const ConstVectorRef &x0,
113 const ConstVectorRef &x1,
114 VectorRef out) const = 0;
115
116 virtual void Jdifference_impl(const ConstVectorRef &x0,
117 const ConstVectorRef &x1, MatrixRef Jout,
118 int arg) const = 0;
119
121 virtual void interpolate_impl(const ConstVectorRef &x0,
122 const ConstVectorRef &x1, const Scalar &u,
123 VectorRef out) const {
124 // default implementation
125 integrate(x0, u * difference(x0, x1), out);
126 }
127};
128
129} // namespace nlp
130} // namespace proxsuite
131
132#include "proxsuite-nlp/manifold-base.hxx"
133
134#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
135#include "proxsuite-nlp/manifold-base.txx"
136#endif
Forward declarations and configuration macros.
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
static constexpr int Options
Scalar type.
virtual VectorXs neutral() const
Get the neutral element from the manifold (if this makes sense).
VectorSpaceTpl< Scalar, Eigen::Dynamic, Options > TangentSpaceType
Typedef for the tangent space, as a manifold.
virtual int nx() const =0
Get manifold representation dimension.
VectorXs difference(const ConstVectorRef &x0, const ConstVectorRef &x1) const
Manifold difference/retraction operation .
virtual void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const =0
Perform the manifold integration operation.
virtual void Jintegrate_impl(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const =0
virtual int ndx() const =0
Get manifold tangent space dimension.
void integrate(const ConstVectorRef &x, const ConstVectorRef &v, VectorRef out) const
Manifold integration operation .
void difference(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
Manifold difference/retraction operation .
virtual VectorXs rand() const
Sample a random point on the manifold.
const TangentSpaceType tangentSpace() const
Return an object representing the tangent space as a manifold.
void interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
VectorXs interpolate(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u) const
Interpolation operation.
virtual void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const =0
Perform the parallel transport operation.
virtual void interpolate_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
Interpolation operation.
virtual void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const =0
Implementation of the manifold retraction operation.
void Jdifference(const ConstVectorRef &x0, const ConstVectorRef &x1, MatrixRef Jout, int arg) const
Jacobian of the retraction operation.
virtual ~ManifoldAbstractTpl()=default
void Jintegrate(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
Jacobian of the integation operation.
virtual void Jdifference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, MatrixRef Jout, int arg) const =0
virtual bool isNormalized(const ConstVectorRef &) const
Check if the input vector x is a viable element of the manifold.
VectorXs integrate(const ConstVectorRef &x, const ConstVectorRef &v) const
Manifold integration operation .
Standard Euclidean vector space.