ROL
ROL_SlacklessConstraint_Def.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Rapid Optimization Library (ROL) Package
4 //
5 // Copyright 2014 NTESS and the ROL contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ROL_SLACKLESSCONSTRAINT_DEF_HPP
11 #define ROL_SLACKLESSCONSTRAINT_DEF_HPP
12 
13 namespace ROL {
14 
15 template<typename Real>
17 
18 template<typename Real>
19 void SlacklessConstraint<Real>::update( const Vector<Real> &x, UpdateType type, int iter ) {
20  con_->update( *getOpt(x), type, iter );
21 }
22 
23 template<typename Real>
24 void SlacklessConstraint<Real>::update( const Vector<Real> &x, bool flag, int iter ) {
25  con_->update( *getOpt(x), flag, iter );
26 }
27 
28 template<typename Real>
30  con_->value( c, *getOpt(x), tol );
31 }
32 
33 template<typename Real>
35  con_->applyJacobian( jv, *getOpt(v), *getOpt(x), tol );
36 }
37 
38 template<typename Real>
39 void SlacklessConstraint<Real>::applyAdjointJacobian( Vector<Real> &ajv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &dualv, Real &tol ) {
40  zeroSlack(ajv);
41  con_->applyAdjointJacobian( *getOpt(ajv), v, *getOpt(x), dualv, tol );
42 }
43 
44 template<typename Real>
46  zeroSlack(ahuv);
47  con_->applyAdjointHessian( *getOpt(ahuv), u, *getOpt(v), *getOpt(x), tol );
48 }
49 
50 template<typename Real>
51 void SlacklessConstraint<Real>::setParameter(const std::vector<Real> &param) {
53  con_->setParameter(param);
54 }
55 
56 template<typename Real>
57 Ptr<Vector<Real>> SlacklessConstraint<Real>::getOpt( Vector<Real> &xs ) const {
58  return dynamic_cast<PartitionedVector<Real>&>(xs).get(0);
59 }
60 
61 template<typename Real>
62 Ptr<const Vector<Real>> SlacklessConstraint<Real>::getOpt( const Vector<Real> &xs ) const {
63  return dynamic_cast<const PartitionedVector<Real>&>(xs).get(0);
64 }
65 
66 template<typename Real>
69  = dynamic_cast<PartitionedVector<Real>&>(x);
70  const int nvec = static_cast<int>(xpv.numVectors());
71  for (int i = 1; i < nvec; ++i) {
72  xpv.get(i)->zero();
73  }
74 }
75 
76 } // namespace ROL
77 
78 #endif // ROL__SLACKLESSCONSTRAINT_HPP
79 
ROL::Ptr< const Vector< Real > > get(size_type i) const
Defines the linear algebra of vector space on a generic partitioned vector.
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update constraint function.
SlacklessConstraint(const Ptr< Constraint< Real >> &con)
Ptr< Vector< Real > > getOpt(Vector< Real > &xs) const
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
void applyAdjointJacobian(Vector< Real > &ajv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &dualv, Real &tol) override
Apply the adjoint of the the constraint Jacobian at , , to vector .
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
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 ...
virtual void setParameter(const std::vector< Real > &param)
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
void setParameter(const std::vector< Real > &param) override
void zeroSlack(Vector< Real > &x) const
Defines the general constraint operator interface.