49 #ifndef ROL_SROMBOUNDCONSTRAINT_HPP 50 #define ROL_SROMBOUNDCONSTRAINT_HPP 71 const std::vector<Real> &pt_up,
72 const Real scale = 1.0)
73 : pt_lo_(pt_lo), pt_up_(pt_up), scale_(scale) {
74 dimension_ = pt_lo_.size();
78 diff = pt_up[i] - pt_lo_[i];
79 min_diff_ = ( (min_diff_ < diff) ? min_diff_ : diff );
85 : dimension_(dimension), min_diff_(1.0), scale_(scale) {
86 pt_lo_.clear(); pt_lo_.assign(dimension_,-0.1*
ROL_OVERFLOW);
87 pt_up_.clear(); pt_up_.assign(dimension_, 0.1*
ROL_OVERFLOW);
95 cnt *= ( ( ((*ex.
getPoint(i))[j] >= pt_lo_[j]) && ((*ex.
getPoint(i))[j] <= pt_up_[j]) ) ? 1 : 0 );
99 return ((cnt==0) ?
false :
true);
104 std::vector<Real> pt(dimension_,0.0);
107 pt[j] = std::max(pt_lo_[j],std::min(pt_up_[j],(*ex.
getPoint(i))[j]));
117 Real epsn = std::min(scale_*eps,min_diff_);
118 std::vector<Real> pt(dimension_,0.0);
119 Teuchos::RCP<const std::vector<Real> > xpt, vpt;
122 vpt = ev.getPoint(i);
124 pt[j] = ( ((*xpt)[j] <= pt_lo_[j]+epsn) ? 0.0 : (*vpt)[j] );
136 Real epsn = std::min(scale_*eps,min_diff_);
137 std::vector<Real> pt(dimension_,0.0);
138 Teuchos::RCP<const std::vector<Real> > xpt, vpt;
141 vpt = ev.getPoint(i);
143 pt[j] = ( ((*xpt)[j] >= pt_up_[j]-epsn) ? 0.0 : (*vpt)[j] );
155 Real epsn = std::min(scale_*eps,min_diff_);
156 std::vector<Real> pt(dimension_,0.0);
157 Teuchos::RCP<const std::vector<Real> > xpt, vpt;
160 vpt = ev.getPoint(i);
162 pt[j] = ( ((*xpt)[j] >= pt_up_[j]-epsn || (*xpt)[j] <= pt_lo_[j]+epsn) ? 0.0 : (*vpt)[j] );
175 Real epsn = std::min(scale_*eps,min_diff_);
176 std::vector<Real> pt(dimension_,0.0);
177 Teuchos::RCP<const std::vector<Real> > xpt, vpt, gpt;
180 gpt = eg.getPoint(i);
181 vpt = ev.getPoint(i);
183 pt[j] = ( ((*xpt)[j] <= pt_lo_[j]+epsn && (*gpt)[i] > 0.0) ? 0.0 : (*vpt)[j] );
186 if ( ex.
getWeight(i) <= 0.0+epsn && eg.getWeight(i) > 0.0 ) {
196 Real epsn = std::min(scale_*eps,min_diff_);
197 std::vector<Real> pt(dimension_,0.0);
198 Teuchos::RCP<const std::vector<Real> > xpt, vpt, gpt;
201 gpt = eg.getPoint(i);
202 vpt = ev.getPoint(i);
204 pt[j] = ( ((*xpt)[j] >= pt_up_[j]-epsn && (*gpt)[i] < 0.0) ? 0.0 : (*vpt)[j] );
207 if ( ex.
getWeight(i) >= 1.0-epsn && eg.getWeight(i) < 0.0 ) {
217 Real epsn = std::min(scale_*eps,min_diff_);
218 std::vector<Real> pt(dimension_,0.0);
219 Teuchos::RCP<const std::vector<Real> > xpt, vpt, gpt;
222 gpt = eg.getPoint(i);
223 vpt = ev.getPoint(i);
225 pt[j] = ( (((*xpt)[j] >= pt_up_[j]-epsn && (*gpt)[i] < 0.0) ||
226 ((*xpt)[j] <= pt_lo_[j]+epsn && (*gpt)[i] > 0.0)) ? 0.0 : (*vpt)[j] );
229 if ( (ex.
getWeight(i) >= 1.0-epsn && eg.getWeight(i) < 0.0) ||
230 (ex.
getWeight(i) <= 0.0+epsn && eg.getWeight(i) > 0.0) ) {
std::vector< Real > pt_lo_
Teuchos::RCP< const std::vector< Element > > getPoint(const size_t i) const
std::vector< Real > pt_up_
const Element getWeight(const size_t i) const
void setWeight(const size_t i, const Element wt)
bool isFeasible(const Vector< Real > &x)
Check if the vector, v, is feasible.
Defines the linear algebra or vector space interface.
const size_t getNumSamples(void) const
void setVectorToLowerBound(ROL::Vector< Real > &l)
Set the input vector to the lower bound.
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the lower -binding set.
Provides the std::vector implementation of the ROL::Vector interface.
SROMBoundConstraint(const size_t dimension, const Real scale=1.0)
Provides the interface to apply upper and lower bound constraints.
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 pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -binding set.
SROMBoundConstraint(const std::vector< Real > &pt_lo, const std::vector< Real > &pt_up, const Real scale=1.0)
void setVectorToUpperBound(ROL::Vector< Real > &u)
Set the input vector to the 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.
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the upper -active set.
static const double ROL_OVERFLOW
Platform-dependent maximum double.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps)
Set variables to zero if they correspond to the -active set.
void setPoint(const size_t i, const std::vector< Element > &pt)