aligator  0.14.0
A primal-dual augmented Lagrangian-type solver for nonlinear trajectory optimization.
 
Loading...
Searching...
No Matches
box-constraint.hpp
Go to the documentation of this file.
1
3#pragma once
4
6
7namespace aligator {
8
10template <typename Scalar> struct BoxConstraintTpl : ConstraintSetTpl<Scalar> {
13 using ActiveType = typename Base::ActiveType;
14
15 VectorXs lower_limit;
16 VectorXs upper_limit;
17
18 BoxConstraintTpl(const ConstVectorRef lower, const ConstVectorRef upper)
19 : Base()
20 , lower_limit(lower)
21 , upper_limit(upper) {}
26
27 decltype(auto) projection_impl(const ConstVectorRef &z) const {
28 return z.cwiseMin(upper_limit).cwiseMax(lower_limit);
29 }
30
31 void projection(const ConstVectorRef &z, VectorRef zout) const {
32 zout = projection_impl(z);
33 }
34
35 void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const {
36 zout = z - projection_impl(z);
37 }
38
39 void computeActiveSet(const ConstVectorRef &z,
40 Eigen::Ref<ActiveType> out) const {
41 out.array() =
42 (z.array() > upper_limit.array()) || (z.array() < lower_limit.array());
43 }
44};
45
46} // namespace aligator
Main package namespace.
ConstraintSetTpl< Scalar > Base
decltype(auto) projection_impl(const ConstVectorRef &z) const
void projection(const ConstVectorRef &z, VectorRef zout) const
Compute projection of variable z onto the constraint set.
void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const
Compute projection of z onto the normal cone to the set. The default implementation is just .
BoxConstraintTpl(const BoxConstraintTpl &)=default
BoxConstraintTpl & operator=(BoxConstraintTpl &&)=default
void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const
BoxConstraintTpl(BoxConstraintTpl &&)=default
typename Base::ActiveType ActiveType
BoxConstraintTpl & operator=(const BoxConstraintTpl &)=default
BoxConstraintTpl(const ConstVectorRef lower, const ConstVectorRef upper)
Eigen::Matrix< bool, Eigen::Dynamic, 1 > ActiveType