44 #ifndef ROL_BOUND_CONSTRAINT_H 45 #define ROL_BOUND_CONSTRAINT_H 76 const Teuchos::RCP<Vector<Real> >
x_lo_;
77 const Teuchos::RCP<Vector<Real> >
x_up_;
80 Teuchos::RCP<Vector<Real> >
mask_;
87 class Active :
public Elementwise::BinaryFunction<Real> {
90 Real
apply(
const Real &x,
const Real &y )
const {
91 return ((y <=
offset_) ? 0 : x);
100 Real
apply(
const Real &x,
const Real &y )
const {
101 return ((y < 0 && x <=
offset_) ? 0 : 1);
110 Real
apply(
const Real &x,
const Real &y )
const {
111 return ((y > 0 && x <=
offset_) ? 0 : 1);
119 Real
apply(
const Real &x,
const Real &y )
const {
120 return ((y == 1) ? x : 0);
129 : x_lo_(Teuchos::null), x_up_(Teuchos::null), scale_(1.0),
130 mask_(Teuchos::null), activated_(true), min_diff_(0.0) {}
138 const Real scale = 1.0)
139 : x_lo_(x_lo), x_up_(x_up), scale_(scale), activated_(true) {
140 mask_ = x_lo_->clone();
144 mask_->axpy(-1.0,*x_lo_);
147 min_diff_ = mask_->reduce(minimum_);
171 struct Lesser :
public Elementwise::BinaryFunction<Real> {
172 Real
apply(
const Real &xc,
const Real &yc)
const {
return xc<yc ? xc : yc; }
175 struct Greater :
public Elementwise::BinaryFunction<Real> {
176 Real
apply(
const Real &xc,
const Real &yc)
const {
return xc>yc ? xc : yc; }
197 Real epsn = std::min(scale_*eps,min_diff_);
222 Real epsn = std::min(scale_*eps,min_diff_);
228 mask_->applyBinary(op,g);
247 Real epsn = std::min(scale_*eps,min_diff_);
250 mask_->axpy(-1.0,*x_lo_);
272 Real epsn = std::min(scale_*eps,min_diff_);
275 mask_->axpy(-1.0,*x_lo_);
278 mask_->applyBinary(op,g);
358 Real uminusv = mask_->reduce(minimum_);
361 mask_->axpy(-1.0,*x_lo_);
362 Real vminusl = mask_->reduce(minimum_);
364 flag = (((uminusv < 0) || (vminusl<0)) ?
false :
true);
395 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
401 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
407 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
423 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
429 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
435 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
448 Teuchos::RCP<Vector<Real> > tmp = g.
clone();
bool activated_
Flag that determines whether or not the constraints are being used.
Elementwise::ReductionMin< Real > minimum_
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void activate(void)
Turn on bounds.
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
Contains definitions of custom data types in ROL.
const Teuchos::RCP< Vector< Real > > x_lo_
ROL::BoundConstraint::PruneBinding prune_
Teuchos::RCP< Vector< Real > > mask_
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the lower -active set.
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
const Teuchos::RCP< Vector< Real > > getLowerVectorRCP(void) const
Return the ref count pointer to the lower bound vector.
virtual void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update bounds.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void setVectorToUpperBound(Vector< Real > &u)
Set the input vector to the upper bound.
Defines the linear algebra or vector space interface.
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -binding set.
const Teuchos::RCP< Vector< Real > > x_up_
const Teuchos::RCP< Vector< Real > > getUpperVectorRCP(void) const
Return the ref count pointer to the upper bound vector.
bool isActivated(void)
Check if bounds are on.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the upper -active set.
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -inactive set.
virtual void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
Real apply(const Real &x, const Real &y) const
Provides the interface to apply upper and lower bound constraints.
virtual ~BoundConstraint()
Real apply(const Real &x, const Real &y) const
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
Real apply(const Real &x, const Real &y) const
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the upper -binding set.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the lower -binding set.
virtual void set(const Vector &x)
Set where .
virtual void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -active set.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
BoundConstraint(const Teuchos::RCP< Vector< Real > > &x_lo, const Teuchos::RCP< Vector< Real > > &x_up, const Real scale=1.0)
Default constructor.
UpperBinding(Real offset)
void deactivate(void)
Turn off bounds.
void pruneInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -nonbinding set.
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
Real apply(const Real &x, const Real &y) const
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
LowerBinding(Real offset)