ROL
ROL_BinaryConstraint.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_H
11#define ROL_BINARY_CONSTRAINT_H
12
14#include "ROL_Constraint.hpp"
15
24namespace ROL {
25
26template<typename Real>
27class BinaryConstraint : public Constraint<Real> {
28private:
29 const Ptr<const Vector<Real>> lo_; // Lower Bound Vector
30 const Ptr<const Vector<Real>> up_; // Upper Bound Vector
31 Ptr<Vector<Real>> d_; // Scratch Vector
32 Real gamma_; // Penality parameter
33
34 class BoundsCheck : public Elementwise::BinaryFunction<Real> {
35 private:
36 const int opt_;
37
38 public:
39 BoundsCheck( int option ) : opt_(option) {}
40
41 Real apply( const Real &dl, const Real &du ) const {
42 const Real zero(0), one(1), two(2);
43 if( dl < ROL_INF<Real>() ) {
44 if( du < ROL_INF<Real>() ) {
45 switch(opt_) {
46 case 0: return dl*du; break;
47 case 1: return du-dl; break;
48 case 2: return -two; break;
49 default: return zero; break; // Should never be called
50 }
51 }
52 else { // dl finite, du infinite
53 switch(opt_) {
54 case 0: return dl; break;
55 case 1: return one; break;
56 case 2: return zero; break;
57 default: return zero; break; // Should never be called
58 }
59 }
60 }
61 else { // dl infinite, du finite
62 if( du <ROL_INF<Real>() ) { // dl and du infinite
63 switch(opt_) {
64 case 0: return du; break;
65 case 1: return -one; break;
66 case 2: return zero; break;
67 default: return zero; break; // Should never be called
68 }
69 }
70 else {
71 return zero;
72 }
73 }
74 } // apply
75 }; // class BoundsCheck
76
77public:
78
79 BinaryConstraint( const ROL::Ptr<const Vector<Real>> &lo,
80 const ROL::Ptr<const Vector<Real>> &up, Real gamma );
81 BinaryConstraint( const BoundConstraint<Real> &bnd, Real gamma );
82 BinaryConstraint( const ROL::Ptr<const BoundConstraint<Real>> &bnd, Real gamma );
83
84 void value(Vector<Real> &c, const Vector<Real> &x, Real &tol) override;
85 void applyJacobian(Vector<Real> &jv, const Vector<Real> &v, const Vector<Real> &x, Real &tol) override;
86 void applyAdjointJacobian(Vector<Real> &ajv, const Vector<Real> &v, const Vector<Real> &x, Real &tol) override;
87 void applyAdjointHessian(Vector<Real> &ahuv, const Vector<Real> &u, const Vector<Real> &v, const Vector<Real> &x, Real &tol) override;
88
89 void setPenalty( Real gamma );
90};
91
92} // namespace ROL
93
95
96#endif // ROL_BINARY_CONSTRAINT_H
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Real apply(const Real &dl, const Real &du) const
Implements an equality constraint function that evaluates to zero on the surface of a bounded paralle...
const Ptr< const Vector< Real > > lo_
void value(Vector< Real > &c, const Vector< Real > &x, Real &tol) override
Evaluate the constraint operator at .
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 .
const Ptr< const Vector< Real > > up_
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 ,...
Ptr< Vector< Real > > d_
Provides the interface to apply upper and lower bound constraints.
Defines the general constraint operator interface.
Defines the linear algebra or vector space interface.