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
13namespace ROL {
14
15template<typename Real>
17 const Real b)
18 : a_(a), b_(b) {}
19
20template<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
27template<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
36template<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
45template<typename Real>
47 const Vector<Real> &u,
48 const Vector<Real> &v,
49 const Vector<Real> &x, Real &tol) {
50 ahuv.zero();
51}
52
53template<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
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 .
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 ,...
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
void applyJacobian(Vector< Real > &jv, const Vector< Real > &v, const Vector< Real > &x, Real &tol) override
Apply the constraint Jacobian at , , to vector .
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
ScalarLinearConstraint(const Ptr< const Vector< Real > > &a, const Real b)
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void scale(const Real alpha)=0
Compute where .
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis,...
virtual void zero()
Set to zero vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .