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
13namespace ROL {
14
15template<typename Real>
17
18template<typename Real>
20 con_->update( *getOpt(x), type, iter );
21}
22
23template<typename Real>
24void SlacklessConstraint<Real>::update( const Vector<Real> &x, bool flag, int iter ) {
25 con_->update( *getOpt(x), flag, iter );
26}
27
28template<typename Real>
30 con_->value( c, *getOpt(x), tol );
31}
32
33template<typename Real>
35 con_->applyJacobian( jv, *getOpt(v), *getOpt(x), tol );
36}
37
38template<typename Real>
40 zeroSlack(ajv);
41 con_->applyAdjointJacobian( *getOpt(ajv), v, *getOpt(x), dualv, tol );
42}
43
44template<typename Real>
46 zeroSlack(ahuv);
47 con_->applyAdjointHessian( *getOpt(ahuv), u, *getOpt(v), *getOpt(x), tol );
48}
49
50template<typename Real>
51void SlacklessConstraint<Real>::setParameter(const std::vector<Real> &param) {
53 con_->setParameter(param);
54}
55
56template<typename Real>
57Ptr<Vector<Real>> SlacklessConstraint<Real>::getOpt( Vector<Real> &xs ) const {
58 return dynamic_cast<PartitionedVector<Real>&>(xs).get(0);
59}
60
61template<typename Real>
62Ptr<const Vector<Real>> SlacklessConstraint<Real>::getOpt( const Vector<Real> &xs ) const {
63 return dynamic_cast<const PartitionedVector<Real>&>(xs).get(0);
64}
65
66template<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
Defines the general constraint operator interface.
virtual void setParameter(const std::vector< Real > &param)
Defines the linear algebra of vector space on a generic partitioned vector.
ROL::Ptr< const Vector< Real > > get(size_type i) const
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
void setParameter(const std::vector< Real > &param) override
SlacklessConstraint(const Ptr< Constraint< Real > > &con)
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
void zeroSlack(Vector< Real > &x) const
Ptr< Vector< Real > > getOpt(Vector< Real > &xs) const
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 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 update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update constraint function.
Defines the linear algebra or vector space interface.