7template <
typename Derived>
9 const std::vector<Eigen::Index> &rowBlockSizes,
11 Eigen::Index startIdx = 0;
12 for (std::size_t kk = 0; kk < rowIdx; kk++) {
13 startIdx += rowBlockSizes[kk];
15 return matrix.const_cast_derived().middleRows(startIdx,
16 rowBlockSizes[rowIdx]);
19template <
typename Derived>
21 const std::vector<Eigen::Index> &blockSizes,
22 std::size_t blockIdx) {
23 EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived);
24 Eigen::Index startIdx = 0;
25 for (std::size_t kk = 0; kk < blockIdx; kk++) {
26 startIdx += blockSizes[kk];
28 return matrix.const_cast_derived().segment(startIdx, blockSizes[blockIdx]);
35template <
typename Scalar>
46 "block sizes should be the same.");
57 for (std::size_t i = 0; i < m_components.size(); i++) {
59 res += m_components[i]->evaluate(zblock);
64 void projection(
const ConstVectorRef &z, VectorRef zout)
const override {
65 for (std::size_t i = 0; i < m_components.size(); i++) {
68 m_components[i]->projection(inblock, outblock);
73 VectorRef zout)
const override {
74 for (std::size_t i = 0; i < m_components.size(); i++) {
77 m_components[i]->normalConeProjection(inblock, outblock);
82 MatrixRef Jout)
const override {
83 for (std::size_t i = 0; i < m_components.size(); i++) {
86 m_components[i]->applyProjectionJacobian(inblock, outblock);
91 MatrixRef Jout)
const override {
92 for (std::size_t i = 0; i < m_components.size(); i++) {
95 m_components[i]->applyNormalConeProjectionJacobian(inblock, outblock);
100 Eigen::Ref<ActiveType> out)
const override {
101 for (std::size_t i = 0; i < m_components.size(); i++) {
104 m_components[i]->computeActiveSet(inblock, outblock);
108 const std::vector<xyz::polymorphic<Base>> &
components()
const {
111 const std::vector<Eigen::Index> &
blockSizes()
const {
return m_blockSizes; }
114 std::vector<xyz::polymorphic<Base>> m_components;
115 std::vector<Eigen::Index> m_blockSizes;
118#ifdef PROXSUITE_NLP_ENABLE_TEMPLATE_INSTANTIATION
119extern template struct PROXSUITE_NLP_EXPLICIT_INSTANTIATION_DECLARATION_DLLAPI
120 ConstraintSetProductTpl<context::Scalar>;
#define PROXSUITE_NLP_RUNTIME_ERROR(msg)
#define PROXSUITE_NLP_DYNAMIC_TYPEDEFS(Scalar)
auto blockMatrixGetRow(const Eigen::MatrixBase< Derived > &matrix, const std::vector< Eigen::Index > &rowBlockSizes, std::size_t rowIdx)
auto blockVectorGetRow(const Eigen::MatrixBase< Derived > &matrix, const std::vector< Eigen::Index > &blockSizes, std::size_t blockIdx)
Cartesian product of multiple constraint sets. This class makes computing multipliers and Jacobian ma...
void computeActiveSet(const ConstVectorRef &z, Eigen::Ref< ActiveType > out) const override
const std::vector< Eigen::Index > & blockSizes() const
ConstraintSetProductTpl(const ConstraintSetProductTpl &)=default
ConstraintSetProductTpl & operator=(const ConstraintSetProductTpl &)=default
const std::vector< xyz::polymorphic< Base > > & components() const
void applyNormalConeProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const override
Apply the jacobian of the projection on the normal cone.
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 .
typename Base::ActiveType ActiveType
void applyProjectionJacobian(const ConstVectorRef &z, MatrixRef Jout) const override
Apply a jacobian of the projection/proximal operator to a matrix.
ConstraintSetProductTpl(const std::vector< xyz::polymorphic< Base > > components, const std::vector< Eigen::Index > &blockSizes)
ConstraintSetProductTpl & operator=(ConstraintSetProductTpl &&)=default
void projection(const ConstVectorRef &z, VectorRef zout) const override
Compute projection of variable z onto the constraint set.
ConstraintSetProductTpl(ConstraintSetProductTpl &&)=default
Scalar evaluate(const ConstVectorRef &zproj) const override
Base constraint set type.
Eigen::Matrix< bool, Eigen::Dynamic, 1 > ActiveType