proxsuite-nlp  0.11.0
A primal-dual augmented Lagrangian-type solver for nonlinear programming on manifolds.
 
Loading...
Searching...
No Matches
l1-penalty.hpp
1
2#pragma once
3
5
6namespace proxsuite {
7namespace nlp {
8
17template <typename _Scalar>
18struct NonsmoothPenaltyL1Tpl : ConstraintSetTpl<_Scalar> {
19 using Scalar = _Scalar;
21
22 NonsmoothPenaltyL1Tpl() = default;
23 NonsmoothPenaltyL1Tpl(const NonsmoothPenaltyL1Tpl &) = default;
24 NonsmoothPenaltyL1Tpl &operator=(const NonsmoothPenaltyL1Tpl &) = default;
25 NonsmoothPenaltyL1Tpl(NonsmoothPenaltyL1Tpl &&) = default;
26 NonsmoothPenaltyL1Tpl &operator=(NonsmoothPenaltyL1Tpl &&) = default;
27
28 using Base = ConstraintSetTpl<Scalar>;
29 using ActiveType = typename Base::ActiveType;
30 using Base::mu_;
31
32 Scalar evaluate(const ConstVectorRef &zproj) const {
33 return zproj.template lpNorm<1>();
34 }
35
36 decltype(auto) projection_impl(const ConstVectorRef &z) const {
37 return z.array().sign() *
38 (z.array().abs() - mu_).max(static_cast<Scalar>(0.));
39 }
40
41 void projection(const ConstVectorRef &z, VectorRef zout) const {
42 zout = projection_impl(z);
43 }
44
45 void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const {
46 zout = z - projection_impl(z).matrix();
47 }
48
49 void computeActiveSet(const ConstVectorRef &z,
50 Eigen::Ref<ActiveType> out) const {
51 out = z.array().abs() <= mu_;
52 }
53};
54
55#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
56extern template struct PROXSUITE_NLP_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
57 NonsmoothPenaltyL1Tpl<context::Scalar>;
58#endif
59
60} // namespace nlp
61} // namespace proxsuite
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
Definition math.hpp:26
Main package namespace.
Definition bcl-params.hpp:5
void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const
Compute projection of z onto the normal cone to the set. The default implementation is just .
void projection(const ConstVectorRef &z, VectorRef zout) const
Compute projection of variable z onto the constraint set.
void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const
Scalar evaluate(const ConstVectorRef &zproj) const