ROL
ROL_AffineTransformConstraint_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_AFFINE_TRANSFORM_CONSTRAINT_DEF_H
11#define ROL_AFFINE_TRANSFORM_CONSTRAINT_DEF_H
12
13namespace ROL {
14
15template<typename Real>
17 const Ptr<Constraint<Real>> &acon,
18 const Vector<Real> &range,
19 const Ptr<VectorController<Real>> &storage)
20 : con_(con), acon_(acon), storage_(storage) {
21 primal_ = range.clone();
22 Av_ = range.clone();
23 dual_ = range.dual().clone();
24 if (storage == nullPtr) storage_ = makePtr<VectorController<Real>>();
25}
26
27template<typename Real>
29 const Ptr<LinearConstraint<Real>> &acon,
30 const Ptr<VectorController<Real>> &storage)
31 : con_(con), acon_(acon), storage_(storage) {
32 primal_ = acon->createRangeSpaceVector();
33 Av_ = acon->createRangeSpaceVector();
34 dual_ = primal_->dual().clone();
35 if (storage == nullPtr) storage_ = makePtr<VectorController<Real>>();
36}
37
38template<typename Real>
40 const Ptr<const LinearOperator<Real>> &A,
41 const Ptr<const Vector<Real>> &b,
42 const Ptr<VectorController<Real>> &storage)
43 : con_(con), acon_(makePtr<LinearConstraint<Real>>(A,b)), storage_(storage) {
44 primal_ = b->clone();
45 Av_ = b->clone();
46 dual_ = b->dual().clone();
47 if (storage == nullPtr) storage_ = makePtr<VectorController<Real>>();
48}
49
50template<typename Real>
52 storage_->constraintUpdate(type);
53 acon_->update(x,type,iter);
54 con_->update(*transform(x),type,iter);
55}
56
57template<typename Real>
58void AffineTransformConstraint<Real>::update( const Vector<Real> &x, bool flag, int iter ) {
59 storage_->constraintUpdate(true);
60 acon_->update(x,flag,iter);
61 con_->update(*transform(x),flag,iter);
62}
63
64template<typename Real>
66 con_->value(c,*transform(x),tol);
67}
68
69template<typename Real>
71 acon_->applyJacobian(*Av_,v,x,tol);
72 con_->applyJacobian(jv,*Av_,*transform(x),tol);
73}
74
75template<typename Real>
77 con_->applyAdjointJacobian(*dual_,v,*transform(x),tol);
78 acon_->applyAdjointJacobian(ajv,*dual_,x,tol);
79}
80
81template<typename Real>
83 acon_->applyJacobian(*Av_,v,x,tol);
84 con_->applyAdjointHessian(*dual_,u,*Av_,*transform(x),tol);
85 acon_->applyAdjointJacobian(ahuv,*dual_,x,tol);
86}
87
88template<typename Real>
90 bool isApplied = storage_->get(*primal_,Constraint<Real>::getParameter());
91 if (!isApplied) {
92 Real tol = std::sqrt(ROL_EPSILON<Real>());
93 acon_->value(*primal_,x,tol);
94 storage_->set(*primal_,Constraint<Real>::getParameter());
95 }
96 return primal_;
97}
98
99} // namespace ROL
100
101#endif // ROL_AFFINE_TRANSFORM_OBJECTIVE_H
void update(const Vector< Real > &x, UpdateType type, int iter=-1) override
Update constraint function.
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 ,...
AffineTransformConstraint(const Ptr< Constraint< Real > > &con, const Ptr< Constraint< Real > > &acon, const Vector< Real > &range, const Ptr< VectorController< Real > > &storage=nullPtr)
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
Ptr< const Vector< Real > > transform(const Vector< Real > &x)
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 .
Ptr< VectorController< Real > > storage_
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
Defines the general constraint operator interface.
Defines the general affine constraint with the form .
Provides the interface to apply a linear operator.
Defines the linear algebra or vector space interface.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.