ROL
ROL_ScalarLinearConstraint_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_HYPERPLANE_EQUALITY_CONSTRAINT_DEF_H
11 #define ROL_AFFINE_HYPERPLANE_EQUALITY_CONSTRAINT_DEF_H
12 
13 namespace ROL {
14 
15 template<typename Real>
17  const Real b)
18  : a_(a), b_(b) {}
19 
20 template<typename Real>
22  SingletonVector<Real> &cc = dynamic_cast<SingletonVector<Real>&>(c);
23  //cc.setValue(a_->dot(x.dual()) - b_);
24  cc.setValue(a_->apply(x) - b_);
25 }
26 
27 template<typename Real>
29  const Vector<Real> &v,
30  const Vector<Real> &x, Real &tol) {
31  SingletonVector<Real> &jc = dynamic_cast<SingletonVector<Real>&>(jv);
32  //jc.setValue(a_->dot(v.dual()));
33  jc.setValue(a_->apply(v));
34 }
35 
36 template<typename Real>
38  const Vector<Real> &v,
39  const Vector<Real> &x, Real &tol) {
40  const SingletonVector<Real>& vc = dynamic_cast<const SingletonVector<Real>&>(v);
41  ajv.set(*a_);
42  ajv.scale(vc.getValue());
43 }
44 
45 template<typename Real>
47  const Vector<Real> &u,
48  const Vector<Real> &v,
49  const Vector<Real> &x, Real &tol) {
50  ahuv.zero();
51 }
52 
53 template<typename Real>
55  Vector<Real> &v2,
56  const Vector<Real> &b1,
57  const Vector<Real> &b2,
58  const Vector<Real> &x, Real &tol) {
59  SingletonVector<Real>& v2c = dynamic_cast<SingletonVector<Real>&>(v2);
60  const SingletonVector<Real>& b2c = dynamic_cast<const SingletonVector<Real>&>(b2);
61 
62  //v2c.setValue( (a_->dot(b1.dual()) - b2c.getValue() )/a_->dot(*a_) );
63  v2c.setValue( (a_->apply(b1) - b2c.getValue() )/a_->dot(*a_) );
64  v1.set(b1.dual());
65  v1.axpy(-v2c.getValue(),a_->dual());
66 
67  std::vector<Real> out;
68  return out;
69 }
70 
71 } // namespace ROL
72 
73 #endif
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
Definition: ROL_Vector.hpp:192
virtual void scale(const Real alpha)=0
Compute where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Definition: ROL_Vector.hpp:119
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
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 zero()
Set to zero vector.
Definition: ROL_Vector.hpp:133
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:46
ScalarLinearConstraint(const Ptr< const Vector< Real >> &a, const Real b)
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 set(const Vector &x)
Set where .
Definition: ROL_Vector.hpp:175
std::vector< Real > solveAugmentedSystem(Vector< Real > &v1, Vector< Real > &v2, const Vector< Real > &b1, const Vector< Real > &b2, const Vector< Real > &x, Real &tol) override
Approximately solves the augmented system where , , , , is an identity or Riesz operator...
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .