proxsuite-nlp  0.11.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
 
Loading...
Searching...
No Matches
tangent-bundle.hxx
1#pragma once
2
3#include "proxsuite-nlp/modelling/spaces/tangent-bundle.hpp"
4
5namespace proxsuite {
6namespace nlp {
7
8template <class Base> auto TangentBundleTpl<Base>::neutral() const -> VectorXs {
9 VectorXs out(nx());
10 out.setZero();
11 out.head(base_.nx()) = base_.neutral();
12 return out;
13}
14
15template <class Base> auto TangentBundleTpl<Base>::rand() const -> VectorXs {
16 VectorXs out(nx());
17 out.head(base_.nx()) = base_.rand();
18 out.tail(base_.ndx()) = VectorXs::Random(base_.ndx());
19 return out;
20}
21
23template <class Base>
24void TangentBundleTpl<Base>::integrate_impl(const ConstVectorRef &x,
25 const ConstVectorRef &dx,
26 VectorRef out) const {
27 const int nv_ = base_.ndx();
28 base_.integrate(getBasePoint(x), getBaseTangent(dx), out.head(base_.nx()));
29 out.tail(nv_) = x.tail(nv_) + dx.tail(nv_);
30}
31
32template <class Base>
33void TangentBundleTpl<Base>::difference_impl(const ConstVectorRef &x0,
34 const ConstVectorRef &x1,
35 VectorRef out) const {
36 const int nv_ = base_.ndx();
37 out.resize(ndx());
38 base_.difference(getBasePoint(x0), getBasePoint(x1), out.head(nv_));
39 out.tail(nv_) = x1.tail(nv_) - x0.tail(nv_);
40}
41
42template <class Base>
43void TangentBundleTpl<Base>::Jintegrate_impl(const ConstVectorRef &x,
44 const ConstVectorRef &dx,
45 MatrixRef J_, int arg) const {
46 const int nv_ = base_.ndx();
47 J_.resize(ndx(), ndx());
48 J_.setZero();
49 base_.Jintegrate(getBasePoint(x), getBaseTangent(dx), getBaseJacobian(J_),
50 arg);
51 J_.bottomRightCorner(nv_, nv_).setIdentity();
52}
54template <class Base>
55void TangentBundleTpl<Base>::Jdifference_impl(const ConstVectorRef &x0,
56 const ConstVectorRef &x1,
57 MatrixRef J_, int arg) const {
58 const int nv_ = base_.ndx();
59 J_.resize(ndx(), ndx());
60 J_.setZero();
61 base_.Jdifference(getBasePoint(x0), getBasePoint(x1), getBaseJacobian(J_),
62 arg);
63 if (arg == 0) {
64 J_.bottomRightCorner(nv_, nv_).diagonal().array() = Scalar(-1);
65 } else if (arg == 1) {
66 J_.bottomRightCorner(nv_, nv_).setIdentity();
67 }
68}
69
70template <class Base>
72 const ConstVectorRef &v,
73 MatrixRef Jout,
74 int arg) const {
75 const int nv_ = base_.ndx();
76 base_.JintegrateTransport(getBasePoint(x), getBaseTangent(v),
77 Jout.topRows(nv_), arg);
78}
79
80template <class Base>
81void TangentBundleTpl<Base>::interpolate_impl(const ConstVectorRef &x0,
82 const ConstVectorRef &x1,
83 const Scalar &u,
84 VectorRef out) const {
85 base_.interpolate(getBasePoint(x0), getBasePoint(x1), u,
86 getBasePointWrite(out));
87 out.tail(base_.ndx()) =
88 (Scalar(1.) - u) * getBaseTangent(x0) + u * getBaseTangent(x1);
89}
90
91} // namespace nlp
92} // namespace proxsuite
Main package namespace.
Definition bcl-params.hpp:5
VectorXs rand() const
Sample a random point on the manifold.
Point::ConstSegmentReturnType getBasePoint(const Point &x) const
void difference_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, VectorRef out) const
Implementation of the manifold retraction operation.
void interpolate_impl(const ConstVectorRef &x0, const ConstVectorRef &x1, const Scalar &u, VectorRef out) const
Interpolation operation.
void integrate_impl(const ConstVectorRef &x, const ConstVectorRef &dx, VectorRef out) const
Operators.
void JintegrateTransport(const ConstVectorRef &x, const ConstVectorRef &v, MatrixRef Jout, int arg) const
Perform the parallel transport operation.
VectorXs neutral() const
Get the neutral element from the manifold (if this makes sense).
int nx() const
Declare implementations.