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);
135 x_lo_->applyUnary(Elementwise::Fill<Real>(ROL_NINF<Real>()));
136 x_up_->applyUnary(Elementwise::Fill<Real>(ROL_INF<Real>()));
145 const Real scale = 1)
147 Real half(0.5), one(1);
179 struct Lesser :
public Elementwise::BinaryFunction<Real> {
180 Real apply(
const Real &xc,
const Real &yc)
const {
return xc<yc ? xc : yc; }
183 struct Greater :
public Elementwise::BinaryFunction<Real> {
184 Real apply(
const Real &xc,
const Real &yc)
const {
return xc>yc ? xc : yc; }
236 mask_->applyBinary(op,g);
286 mask_->applyBinary(op,g);
320 if(
x_up_ == Teuchos::null ) {
321 u.
applyUnary(Elementwise::Fill<Real>(ROL_INF<Real>()));
334 if(
x_lo_ == Teuchos::null ) {
335 l.
applyUnary(Elementwise::Fill<Real>(ROL_NINF<Real>()));
392 flag = (((uminusv < 0) || (vminusl<0)) ?
false :
true);
424 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
431 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
438 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
455 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
462 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
469 Teuchos::RCP<Vector<Real> > tmp = v.
clone();
482 Teuchos::RCP<Vector<Real> > tmp = g.
clone();
bool activated_
Flag that determines whether or not the constraints are being used.
Elementwise::ReductionMin< Real > minimum_
BoundConstraint(const Teuchos::RCP< Vector< Real > > &x_lo, const Teuchos::RCP< Vector< Real > > &x_up, const Real scale=1)
Default constructor.
BoundConstraint(const Vector< Real > &x)
Real apply(const Real &x, const Real &y) const
Real apply(const Real &x, const Real &y) const
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.
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
virtual const Teuchos::RCP< Vector< Real > > getLowerVectorRCP(void)
Return the ref count pointer to the lower bound vector.
Contains definitions of custom data types in ROL.
virtual const Teuchos::RCP< Vector< Real > > getUpperVectorRCP(void)
Return the ref count pointer to the upper bound vector.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the lower -binding set.
const Teuchos::RCP< Vector< Real > > x_lo_
ROL::BoundConstraint::PruneBinding prune_
Teuchos::RCP< Vector< Real > > mask_
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -inactive set.
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.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
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 > &x, Real eps=0)
Set variables to zero if they correspond to the -active set.
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -binding set.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the lower -active set.
const Teuchos::RCP< Vector< Real > > x_up_
bool isActivated(void)
Check if bounds are on.
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -active set.
virtual const Teuchos::RCP< const Vector< Real > > getUpperVectorRCP(void) const
Return the ref count pointer to the upper bound vector.
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
Real apply(const Real &x, const Real &y) const
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
virtual void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
Provides the interface to apply upper and lower bound constraints.
virtual ~BoundConstraint()
virtual void applyUnary(const Elementwise::UnaryFunction< Real > &f)
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
virtual const Teuchos::RCP< const Vector< Real > > getLowerVectorRCP(void) const
Return the ref count pointer to the lower bound vector.
virtual void set(const Vector &x)
Set where .
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
UpperBinding(Real offset)
void pruneInactive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -nonbinding set.
void deactivate(void)
Turn off bounds.
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 pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -binding set.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
LowerBinding(Real offset)