9template <
typename Derived>
11 const std::vector<Eigen::Index> &rowBlockSizes,
13 Eigen::Index startIdx = 0;
14 for (std::size_t kk = 0; kk < rowIdx; kk++) {
15 startIdx += rowBlockSizes[kk];
17 return matrix.const_cast_derived().middleRows(startIdx,
18 rowBlockSizes[rowIdx]);
21template <
typename Derived>
23 const std::vector<Eigen::Index> &blockSizes,
24 std::size_t blockIdx) {
25 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
26 Eigen::Index startIdx = 0;
27 for (std::size_t kk = 0; kk < blockIdx; kk++) {
28 startIdx += blockSizes[kk];
30 return matrix.const_cast_derived().segment(startIdx, blockSizes[blockIdx]);
37template <
typename Scalar>
48 ALIGATOR_RUNTIME_ERROR(
"Number of components and corresponding "
49 "block sizes should be the same.");
60 for (std::size_t i = 0; i < m_components.size(); i++) {
62 res += m_components[i]->evaluate(zblock);
67 void projection(
const ConstVectorRef &z, VectorRef zout)
const override {
68 for (std::size_t i = 0; i < m_components.size(); i++) {
71 m_components[i]->projection(inblock, outblock);
76 VectorRef zout)
const override {
77 for (std::size_t i = 0; i < m_components.size(); i++) {
80 m_components[i]->normalConeProjection(inblock, outblock);
85 MatrixRef Jout)
const override {
86 for (std::size_t i = 0; i < m_components.size(); i++) {
89 m_components[i]->applyProjectionJacobian(inblock, outblock);
94 MatrixRef Jout)
const override {
95 for (std::size_t i = 0; i < m_components.size(); i++) {
98 m_components[i]->applyNormalConeProjectionJacobian(inblock, outblock);
103 Eigen::Ref<ActiveType> out)
const override {
104 for (std::size_t i = 0; i < m_components.size(); i++) {
107 m_components[i]->computeActiveSet(inblock, outblock);
111 const std::vector<xyz::polymorphic<Base>> &
components()
const {
114 const std::vector<Eigen::Index> &
blockSizes()
const {
return m_blockSizes; }
117 std::vector<xyz::polymorphic<Base>> m_components;
118 std::vector<Eigen::Index> m_blockSizes;
auto blockVectorGetRow(const Eigen::MatrixBase< Derived > &matrix, const std::vector< Eigen::Index > &blockSizes, std::size_t blockIdx)
auto blockMatrixGetRow(const Eigen::MatrixBase< Derived > &matrix, const std::vector< Eigen::Index > &rowBlockSizes, std::size_t rowIdx)
ConstraintSetProductTpl(const ConstraintSetProductTpl &)=default
Scalar evaluate(const ConstVectorRef &zproj) const override
typename Base::ActiveType ActiveType
void normalConeProjection(const ConstVectorRef &z, VectorRef zout) const override
Compute projection of z onto the normal cone to the set. The default implementation is just .
ConstraintSetProductTpl & operator=(const ConstraintSetProductTpl &)=default
ConstraintSetProductTpl & operator=(ConstraintSetProductTpl &&)=default
ConstraintSetTpl< Scalar > Base
void projection(const ConstVectorRef &z, VectorRef zout) const override
Compute projection of variable z onto the constraint set.
const std::vector< xyz::polymorphic< Base > > & components() const
ConstraintSetProductTpl(ConstraintSetProductTpl &&)=default
ALIGATOR_DYNAMIC_TYPEDEFS(Scalar)
void applyNormalConeProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const override
Apply the jacobian of the projection on the normal cone.
const std::vector< Eigen::Index > & blockSizes() const
ConstraintSetProductTpl(const std::vector< xyz::polymorphic< Base > > components, const std::vector< Eigen::Index > &blockSizes)
void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const override
void applyProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const override
Apply a jacobian of the projection/proximal operator to a matrix.
ConstraintSetTpl()=default
Eigen::Matrix< bool, Eigen::Dynamic, 1 > ActiveType