aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
 
Loading...
Searching...
No Matches
constraint-set.hpp
Go to the documentation of this file.
1
3#pragma once
4
5#include "aligator/fwd.hpp"
7
8namespace aligator {
9
16template <typename _Scalar> struct ConstraintSetTpl {
17public:
18 using Scalar = _Scalar;
20 using ActiveType = Eigen::Matrix<bool, Eigen::Dynamic, 1>;
21
22 ConstraintSetTpl() = default;
23
26 virtual bool disableGaussNewton() const { return true; }
27
31 virtual Scalar evaluate(const ConstVectorRef & /*zproj*/) const { return 0.; }
32
37 virtual void projection(const ConstVectorRef &z, VectorRef zout) const = 0;
38
44 virtual void normalConeProjection(const ConstVectorRef &z,
45 VectorRef zout) const = 0;
46
54 virtual void applyProjectionJacobian(const ConstVectorRef &z,
55 MatrixRef Jout) const;
56
63 virtual void applyNormalConeProjectionJacobian(const ConstVectorRef &z,
64 MatrixRef Jout) const;
65
68 void setProxParameter(const Scalar mu) const {
69 mu_ = mu;
70 mu_inv_ = 1. / mu;
71 };
72
75 virtual void computeActiveSet(const ConstVectorRef &z,
76 Eigen::Ref<ActiveType> out) const = 0;
77
78 virtual ~ConstraintSetTpl() = default;
79
80 bool operator==(const ConstraintSetTpl<Scalar> &rhs) { return this == &rhs; }
81
93 Scalar evaluateMoreauEnvelope(const ConstVectorRef &zin,
94 const ConstVectorRef &zproj) const {
95 Scalar res = evaluate(zin - zproj);
96 res += static_cast<Scalar>(0.5) * mu_inv_ * zproj.squaredNorm();
97 return res;
98 }
99
102 Scalar computeMoreauEnvelope(const ConstVectorRef &zin,
103 VectorRef zprojout) const {
104 normalConeProjection(zin, zprojout);
105 return evaluateMoreauEnvelope(zin, zprojout);
106 }
107
108 Scalar mu() const { return mu_; }
109 Scalar mu_inv() const { return mu_inv_; }
110
111protected:
112 mutable Scalar mu_ = 0.;
114};
115
116#ifdef ALIGATOR_ENABLE_TEMPLATE_INSTANTIATION
117extern template struct ALIGATOR_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
119#endif
120
121} // namespace aligator
122
123#include "aligator/core/constraint-set.hxx"
Forward declarations.
Main package namespace.
Base constraint set type.
virtual ~ConstraintSetTpl()=default
virtual void applyNormalConeProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const
Apply the jacobian of the projection on the normal cone.
virtual void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const =0
Eigen::Matrix< bool, Eigen::Dynamic, 1 > ActiveType
virtual void applyProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const
Apply a jacobian of the projection/proximal operator to a matrix.
virtual Scalar evaluate(const ConstVectorRef &) const
virtual void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const =0
Compute projection of z onto the normal cone to the set. The default implementation is just .
Scalar evaluateMoreauEnvelope(const ConstVectorRef &zin, const ConstVectorRef &zproj) const
Evaluate the Moreau envelope with parameter mu for the given contraint set or nonsmooth penalty at p...
void setProxParameter(const Scalar mu) const
Update proximal parameter; this applies to when this class is a proximal operator that isn't a projec...
virtual bool disableGaussNewton() const
virtual void projection(const ConstVectorRef &z, VectorRef zout) const =0
Compute projection of variable z onto the constraint set.
bool operator==(const ConstraintSetTpl< Scalar > &rhs)
Scalar computeMoreauEnvelope(const ConstVectorRef &zin, VectorRef zprojout) const
Evaluate the Moreau envelope with parameter mu for the given contraint set or nonsmooth penalty at p...