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
110public:
111
112 Bounds(const Vector<Real> &x,
113 bool isLower = true,
114 Real scale = 1,
115 Real feasTol = 1e-2);
116
117 Bounds(const Ptr<Vector<Real>> &x_lo,
118 const Ptr<Vector<Real>> &x_up,
119 const Real scale = 1,
120 const Real feasTol = 1e-2);
121
122 void project( Vector<Real> &x ) override;
123
124 void projectInterior( Vector<Real> &x ) override;
125
126 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) override;
127
128 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) override;
129
130 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) override;
131
132 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) override;
133
134 bool isFeasible( const Vector<Real> &v ) override;
135
136}; // class Bounds
137
138} // namespace ROL
139
140#include "ROL_Bounds_Def.hpp"
141
142#endif
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
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
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
const Real scale_
Definition: ROL_Bounds.hpp:61
Real min_diff_
Definition: ROL_Bounds.hpp:69
void project(Vector< Real > &x) override
Project optimization variables onto the bounds.
Bounds(const Vector< Real > &x, bool isLower=true, Real scale=1, Real feasTol=1e-2)
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.
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