10template <
typename Derived>
12 boost::span<const Eigen::Index> rowBlockSizes,
14 Eigen::Index startIdx = 0;
15 for (std::size_t kk = 0; kk < rowIdx; kk++) {
16 startIdx += rowBlockSizes[kk];
18 return matrix.const_cast_derived().middleRows(startIdx,
19 rowBlockSizes[rowIdx]);
22template <
typename Derived>
24 boost::span<const Eigen::Index> blockSizes,
25 std::size_t blockIdx) {
26 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
27 Eigen::Index startIdx = 0;
28 for (std::size_t kk = 0; kk < blockIdx; kk++) {
29 startIdx += blockSizes[kk];
31 return matrix.const_cast_derived().segment(startIdx, blockSizes[blockIdx]);
39template <
typename Scalar>
50 ALIGATOR_RUNTIME_ERROR(
"Number of components and corresponding "
51 "block sizes should be the same.");
62 for (std::size_t i = 0; i < m_components.size(); i++) {
64 res += m_components[i]->evaluate(zblock);
69 void projection(
const ConstVectorRef &z, VectorRef zout)
const override {
70 for (std::size_t i = 0; i < m_components.size(); i++) {
73 m_components[i]->projection(inblock, outblock);
78 VectorRef zout)
const override {
79 for (std::size_t i = 0; i < m_components.size(); i++) {
82 m_components[i]->normalConeProjection(inblock, outblock);
87 MatrixRef Jout)
const override {
88 for (std::size_t i = 0; i < m_components.size(); i++) {
91 m_components[i]->applyProjectionJacobian(inblock, outblock);
96 MatrixRef Jout)
const override {
97 for (std::size_t i = 0; i < m_components.size(); i++) {
100 m_components[i]->applyNormalConeProjectionJacobian(inblock, outblock);
105 Eigen::Ref<ActiveType> out)
const override {
106 for (std::size_t i = 0; i < m_components.size(); i++) {
109 m_components[i]->computeActiveSet(inblock, outblock);
113 const std::vector<xyz::polymorphic<Base>> &
components()
const {
116 const std::vector<Eigen::Index> &
blockSizes()
const {
return m_blockSizes; }
119 std::vector<xyz::polymorphic<Base>> m_components;
120 std::vector<Eigen::Index> m_blockSizes;
auto blockMatrixGetRow(const Eigen::MatrixBase< Derived > &matrix, boost::span< const Eigen::Index > rowBlockSizes, std::size_t rowIdx)
auto blockVectorGetRow(const Eigen::MatrixBase< Derived > &matrix, boost::span< const Eigen::Index > blockSizes, std::size_t blockIdx)
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