49 #ifndef ROL_STDBOUNDCONSTRAINT_HPP
50 #define ROL_STDBOUNDCONSTRAINT_HPP
66 ROL::Ptr<Vector<Real> >
l_;
67 ROL::Ptr<Vector<Real> >
u_;
75 x_lo_.assign(x.begin(),x.end());
81 x_up_.assign(x.begin(),x.end());
86 l_ = ROL::makePtr<StdVector<Real>>(ROL::makePtrFromRef(
x_lo_));
87 u_ = ROL::makePtr<StdVector<Real>>(ROL::makePtrFromRef(
x_up_));
94 for (
int i = 0; i <
dim_; i++ ) {
104 l_ = ROL::makePtr<StdVector<Real>>(ROL::makePtrFromRef(
x_lo_));
105 u_ = ROL::makePtr<StdVector<Real>>(ROL::makePtrFromRef(
x_up_));
109 bool lflag =
true, uflag =
true;
111 ROL::Ptr<const std::vector<Real> > ex =
114 for (
int i = 0; i <
dim_; ++i ) {
115 if ( (*ex)[i] <
x_lo_[i] ) {
122 for (
int i = 0; i <
dim_; ++i ) {
123 if ( (*ex)[i] >
x_up_[i] ) {
130 return (lflag && uflag);
135 ROL::Ptr<std::vector<Real> > ex =
138 for (
int i = 0; i <
dim_; ++i ) {
139 (*ex)[i] = std::max(
x_lo_[i],(*ex)[i]);
143 for (
int i = 0; i <
dim_; ++i ) {
144 (*ex)[i] = std::min(
x_up_[i],(*ex)[i]);
152 ROL::Ptr<std::vector<Real> > ex =
154 const Real eps(1e-1), tol(100.0*ROL_EPSILON<Real>()), one(1);
156 for (
int i = 0; i <
dim_; ++i ) {
157 Real val = ((
x_lo_[i] < -tol) ? (one-eps)*
x_lo_[i]
161 (*ex)[i] = ((*ex)[i] <
x_lo_[i]+tol) ? val : (*ex)[i];
165 for (
int i = 0; i <
dim_; ++i ) {
166 Real val = ((
x_up_[i] < -tol) ? (one+eps)*
x_up_[i]
170 (*ex)[i] = ((*ex)[i] >
x_up_[i]-tol) ? val : (*ex)[i];
178 ROL::Ptr<const std::vector<Real> > ex =
180 ROL::Ptr<std::vector<Real> > ev =
183 for (
int i = 0; i <
dim_; ++i ) {
184 if ( ((*ex)[i] <=
x_lo_[i]+epsn) ) {
185 (*ev)[i] =
static_cast<Real
>(0);
193 ROL::Ptr<const std::vector<Real> > ex =
195 ROL::Ptr<std::vector<Real> > ev =
198 for (
int i = 0; i <
dim_; ++i ) {
199 if ( ((*ex)[i] >=
x_up_[i]-epsn) ) {
200 (*ev)[i] =
static_cast<Real
>(0);
208 ROL::Ptr<const std::vector<Real> > ex =
210 ROL::Ptr<const std::vector<Real> > eg =
212 ROL::Ptr<std::vector<Real> > ev =
215 for (
int i = 0; i <
dim_; ++i ) {
216 if ( ((*ex)[i] <=
x_lo_[i]+epsn && (*eg)[i] > static_cast<Real>(0)) ) {
217 (*ev)[i] =
static_cast<Real
>(0);
225 ROL::Ptr<const std::vector<Real> > ex =
227 ROL::Ptr<const std::vector<Real> > eg =
229 ROL::Ptr<std::vector<Real> > ev =
232 for (
int i = 0; i <
dim_; ++i ) {
233 if ( ((*ex)[i] >=
x_up_[i]-epsn && (*eg)[i] < static_cast<Real>(0)) ) {
234 (*ev)[i] =
static_cast<Real
>(0);
const ROL::Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
ROL::Ptr< Vector< Real > > l_
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -binding set.
void activateLower(void)
Turn on lower bound.
void activate(void)
Turn on bounds.
std::vector< Real > x_lo_
StdBoundConstraint(std::vector< Real > &x, bool isLower=false, Real scale=1.0)
Defines the linear algebra or vector space interface.
StdBoundConstraint(std::vector< Real > &l, std::vector< Real > &u, Real scale=1.0)
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
ROL::Ptr< Vector< Real > > u_
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -active set.
void activateUpper(void)
Turn on upper bound.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -active set.
const ROL::Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
Provides the interface to apply upper and lower bound constraints.
void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -binding set.
bool isFeasible(const Vector< Real > &x)
Check if the vector, v, is feasible.
std::vector< Real > x_up_