ROL
ROL_BinaryConstraint_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_BINARY_CONSTRAINT_DEF_H
11#define ROL_BINARY_CONSTRAINT_DEF_H
12
13namespace ROL {
14
15template<typename Real>
17 const ROL::Ptr<const Vector<Real>> &up, Real gamma ) :
18 lo_(lo), up_(up), d_(lo_->clone()), gamma_(gamma) {}
19
20template<typename Real>
22 BinaryConstraint( bnd.getLowerBound(), bnd.getUpperBound(), gamma ) {}
23
24template<typename Real>
25BinaryConstraint<Real>::BinaryConstraint( const ROL::Ptr<const BoundConstraint<Real>> &bnd, Real gamma ) :
26 BinaryConstraint( bnd->getLowerBound(), bnd->getUpperBound(), gamma ) {}
27
28template<typename Real>
30 const Real one(1);
31 c.set( x );
32 c.axpy( -one, *lo_ ); // c = x-l
33 d_->set( *up_ );
34 d_->axpy( -one, x ); // d = u-x
35 c.applyBinary(BoundsCheck(0), *d_ );
36 c.scale( gamma_ );
37}
38
39template<typename Real>
41 const Real one(1);
42 jv.set( x );
43 jv.axpy( -one, *lo_ );
44 d_->set( *up_ );
45 d_->axpy( -one, x );
46 jv.applyBinary( BoundsCheck(1), *d_ );
47 jv.applyBinary( Elementwise::Multiply<Real>(), v );
48 jv.scale( gamma_ );
49}
50
51template<typename Real>
53 applyJacobian(ajv,v,x,tol);
54}
55
56template<typename Real>
58 const Real one(1);
59 ahuv.set( x );
60 ahuv.axpy( -one, *lo_ );
61 d_->set( *up_ );
62 d_->axpy( -one, x );
63 ahuv.applyBinary( BoundsCheck(2), *d_ );
64 ahuv.applyBinary( Elementwise::Multiply<Real>(), v );
65 ahuv.applyBinary( Elementwise::Multiply<Real>(), u );
66 ahuv.scale( gamma_ );
67}
68
69template<typename Real>
71 gamma_ = gamma;
72}
73
74} // namespace ROL
75
76#endif // ROL_BINARY_CONSTRAINT_DEF_H
Implements an equality constraint function that evaluates to zero on the surface of a bounded paralle...
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
BinaryConstraint(const ROL::Ptr< const Vector< Real > > &lo, const ROL::Ptr< const Vector< Real > > &up, Real gamma)
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 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 ,...
Provides the interface to apply upper and lower bound constraints.
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
virtual void scale(const Real alpha)=0
Compute where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void applyJacobian(ROL::Vector< Real > &jv, const ROL::Vector< Real > &v, const ROL::Vector< Real > &sol)