10 #ifndef ROL_CONSTRAINT_PARTITIONED_DEF_H
11 #define ROL_CONSTRAINT_PARTITIONED_DEF_H
15 template<
typename Real>
19 : cvec_(cvec), offset_(offset),
20 scratch_(nullPtr), ncval_(0), initialized_(false) {
24 template<
typename Real>
26 std::vector<bool> isInequality,
28 : cvec_(cvec), isInequality_(isInequality), offset_(offset),
29 scratch_(nullPtr), ncval_(0), initialized_(false) {}
31 template<
typename Real>
36 template<
typename Real>
38 if (ind < 0 || ind > static_cast<int>(cvec_.size())) {
44 template<
typename Real>
46 const int ncon =
static_cast<int>(cvec_.size());
47 for (
int i = 0; i < ncon; ++i) {
48 cvec_[i]->update(getOpt(x),type,iter);
52 template<
typename Real>
54 const int ncon =
static_cast<int>(cvec_.size());
55 for (
int i = 0; i < ncon; ++i) {
56 cvec_[i]->update(getOpt(x),flag,iter);
60 template<
typename Real>
65 const int ncon =
static_cast<int>(cvec_.size());
67 for (
int i = 0; i < ncon; ++i) {
68 cvec_[i]->value(*cpv.
get(i), getOpt(x), tol);
69 if (isInequality_[i]) {
70 cpv.
get(i)->axpy(static_cast<Real>(-1),getSlack(x,cnt));
77 template<
typename Real>
85 const int ncon =
static_cast<int>(cvec_.size());
87 for (
int i = 0; i < ncon; ++i) {
88 cvec_[i]->applyJacobian(*jvpv.
get(i), getOpt(v), getOpt(x), tol);
89 if (isInequality_[i]) {
90 jvpv.
get(i)->axpy(static_cast<Real>(-1),getSlack(v,cnt));
96 template<
typename Real>
102 scratch_ = getOpt(ajv).clone();
109 const int ncon =
static_cast<int>(cvec_.size());
112 for (
int i = 0; i < ncon; ++i) {
114 cvec_[i]->applyAdjointJacobian(*scratch_, *vpv.
get(i), getOpt(x), tol);
115 getOpt(ajv).plus(*scratch_);
116 if (isInequality_[i]) {
117 getSlack(ajv,cnt).set(*vpv.
get(i));
118 getSlack(ajv,cnt).scale(static_cast<Real>(-1));
124 template<
typename Real>
131 scratch_ = getOpt(ahuv).clone();
138 const int ncon =
static_cast<int>(cvec_.size());
141 for (
int i = 0; i < ncon; ++i) {
142 Ptr<const Vector<Real>> ui = upv.
get(i);
144 cvec_[i]->applyAdjointHessian(*scratch_, *ui, getOpt(v), getOpt(x), tol);
145 getOpt(ahuv).plus(*scratch_);
146 if (isInequality_[i]) {
147 getSlack(ahuv,cnt).zero();
153 template<
typename Real>
164 const int ncon =
static_cast<int>(cvec_.size());
165 for (
int i = 0; i < ncon; ++i) {
166 cvec_[i]->applyPreconditioner(*pvpv.
get(i), *vpv.
get(i), getOpt(x), getOpt(g), tol);
170 template<
typename Real>
173 const int ncon =
static_cast<int>(cvec_.size());
174 for (
int i = 0; i < ncon; ++i) {
175 cvec_[i]->setParameter(param);
179 template<
typename Real>
184 catch (std::exception &e) {
189 template<
typename Real>
194 catch (std::exception &e) {
199 template<
typename Real>
204 template<
typename Real>
void applyAdjointHessian(Vector< Real > &ahuv, const Vector< Real > &u, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the derivative of the adjoint of the constraint Jacobian at to vector in direction ...
void setParameter(const std::vector< Real > ¶m) override
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the linear algebra of vector space on a generic partitioned vector.
Defines the linear algebra or vector space interface.
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the adjoint of the the constraint Jacobian at , , to vector .
virtual void applyPreconditioner(Vector< Real > &pv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g, Real &tol) override
Apply a constraint preconditioner at , , to vector . Ideally, this preconditioner satisfies the follo...
void zero()
Set to zero vector.
Vector< Real > & getOpt(Vector< Real > &xs) const
Constraint_Partitioned(const std::vector< Ptr< Constraint< Real >>> &cvec, bool isInequality=false, int offset=0)
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
virtual void setParameter(const std::vector< Real > ¶m)
int getNumberConstraintEvaluations(void) const
Vector< Real > & getSlack(Vector< Real > &xs, int ind) const
std::vector< bool > isInequality_
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update constraint function.
Defines the general constraint operator interface.
Ptr< Constraint< Real > > get(int ind=0) const