ROL
ROL_Bounds.hpp
Go to the documentation of this file.
1// @HEADER
2// ************************************************************************
3//
4// Rapid Optimization Library (ROL) Package
5// Copyright (2014) Sandia Corporation
6//
7// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8// license for use of this work by or on behalf of the U.S. Government.
9//
10// Redistribution and use in source and binary forms, with or without
11// modification, are permitted provided that the following conditions are
12// met:
13//
14// 1. Redistributions of source code must retain the above copyright
15// notice, this list of conditions and the following disclaimer.
16//
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// 3. Neither the name of the Corporation nor the names of the
22// contributors may be used to endorse or promote products derived from
23// this software without specific prior written permission.
24//
25// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36//
37// Questions? Contact lead developers:
38// Drew Kouri (dpkouri@sandia.gov) and
39// Denis Ridzal (dridzal@sandia.gov)
40//
41// ************************************************************************
42// @HEADER
43
44#ifndef ROL_BOUNDS_H
45#define ROL_BOUNDS_H
46
48
56namespace ROL {
57
58template<typename Real>
59class Bounds : public BoundConstraint<Real> {
60private:
61 const Real scale_;
62 const Real feasTol_;
63
64 using BoundConstraint<Real>::lower_;
65 using BoundConstraint<Real>::upper_;
66
67 Ptr<Vector<Real>> mask_;
68
70
71 Elementwise::ReductionMin<Real> minimum_;
72
73 class Active : public Elementwise::BinaryFunction<Real> {
74 public:
75 Active(Real offset) : offset_(offset) {}
76 Real apply( const Real &x, const Real &y ) const {
77 return ((y <= offset_) ? 0 : x);
78 }
79 private:
80 Real offset_;
81 };
82
83 class UpperBinding : public Elementwise::BinaryFunction<Real> {
84 public:
85 UpperBinding(Real xeps, Real geps) : xeps_(xeps), geps_(geps) {}
86 Real apply( const Real &x, const Real &y ) const {
87 return ((y < -geps_ && x <= xeps_) ? 0 : 1);
88 }
89 private:
90 Real xeps_, geps_;
91 };
92
93 class LowerBinding : public Elementwise::BinaryFunction<Real> {
94 public:
95 LowerBinding(Real xeps, Real geps) : xeps_(xeps), geps_(geps) {}
96 Real apply( const Real &x, const Real &y ) const {
97 return ((y > geps_ && x <= xeps_) ? 0 : 1);
98 }
99 private:
101 };
102
103 class PruneBinding : public Elementwise::BinaryFunction<Real> {
104 public:
105 Real apply( const Real &x, const Real &y ) const {
106 return ((y == 1) ? x : 0);
107 }
109
110 class BuildC : public Elementwise::UnaryFunction<Real> {
111 public:
112 Real apply( const Real &x ) const {
113 const Real zeta(0.5), kappa(1);
114 return std::min(zeta * x, kappa);
115 }
117
118 class SetZeroEntry : public Elementwise::BinaryFunction<Real> {
119 public:
120 Real apply(const Real &x, const Real &y) const {
121 const Real zero(0);
122 return (x==zero ? y : x);
123 }
125
126 void buildScalingFunction(Vector<Real> &d, const Vector<Real> &x, const Vector<Real> &g) const;
127
128public:
129
130 Bounds(const Vector<Real> &x,
131 bool isLower = true,
132 Real scale = 1,
133 Real feasTol = std::sqrt(ROL_EPSILON<Real>()));
134
135 Bounds(const Ptr<Vector<Real>> &x_lo,
136 const Ptr<Vector<Real>> &x_up,
137 const Real scale = 1,
138 const Real feasTol = std::sqrt(ROL_EPSILON<Real>()));
139
140 void project( Vector<Real> &x ) override;
141
142 void projectInterior( Vector<Real> &x ) override;
143
144 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) override;
145
146 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) override;
147
148 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) override;
149
150 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) override;
151
152 bool isFeasible( const Vector<Real> &v ) override;
153
154 void applyInverseScalingFunction(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const override;
155
156 void applyScalingFunctionJacobian(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const override;
157}; // class Bounds
158
159} // namespace ROL
160
161#include "ROL_Bounds_Def.hpp"
162
163#endif
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Provides the interface to apply upper and lower bound constraints.
Ptr< Vector< Real > > upper_
Ptr< Vector< Real > > lower_
Active(Real offset)
Definition: ROL_Bounds.hpp:75
Real apply(const Real &x, const Real &y) const
Definition: ROL_Bounds.hpp:76
Real apply(const Real &x) const
Definition: ROL_Bounds.hpp:112
LowerBinding(Real xeps, Real geps)
Definition: ROL_Bounds.hpp:95
Real apply(const Real &x, const Real &y) const
Definition: ROL_Bounds.hpp:96
Real apply(const Real &x, const Real &y) const
Definition: ROL_Bounds.hpp:105
Real apply(const Real &x, const Real &y) const
Definition: ROL_Bounds.hpp:120
UpperBinding(Real xeps, Real geps)
Definition: ROL_Bounds.hpp:85
Real apply(const Real &x, const Real &y) const
Definition: ROL_Bounds.hpp:86
Provides the elementwise interface to apply upper and lower bound constraints.
Definition: ROL_Bounds.hpp:59
Elementwise::ReductionMin< Real > minimum_
Definition: ROL_Bounds.hpp:71
const Real feasTol_
Definition: ROL_Bounds.hpp:62
void buildScalingFunction(Vector< Real > &d, const Vector< Real > &x, const Vector< Real > &g) const
void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const override
Apply inverse scaling function.
const Real scale_
Definition: ROL_Bounds.hpp:61
Real min_diff_
Definition: ROL_Bounds.hpp:69
ROL::Bounds::SetZeroEntry setZeroEntry_
void project(Vector< Real > &x) override
Project optimization variables onto the bounds.
ROL::Bounds::BuildC buildC_
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0)) override
Set variables to zero if they correspond to the upper -active set.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0)) override
Set variables to zero if they correspond to the lower -active set.
Ptr< Vector< Real > > mask_
Definition: ROL_Bounds.hpp:67
void projectInterior(Vector< Real > &x) override
Project optimization variables into the interior of the feasible set.
void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const override
Apply scaling function Jacobian.
ROL::Bounds::PruneBinding prune_
bool isFeasible(const Vector< Real > &v) override
Check if the vector, v, is feasible.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:84