44#ifndef ROL_BOUND_CONSTRAINT_DEF_H
45#define ROL_BOUND_CONSTRAINT_DEF_H
49template<
typename Real>
52 Real denom = (
dim > 0 ?
static_cast<Real
>(
dim) : 1e15);
53 return std::sqrt(ROL_INF<Real>() / denom);
56template<
typename Real>
58 : Lactivated_(true), Uactivated_(true) {}
60template<
typename Real>
62 : Lactivated_(false), Uactivated_(false) {
67 catch(std::exception &e) {
73template<
typename Real>
80template<
typename Real>
87template<
typename Real>
89 if (isUpperActivated()) {
94template<
typename Real>
96 if (isUpperActivated()) {
101template<
typename Real>
103 if (isLowerActivated()) {
108template<
typename Real>
110 if (isLowerActivated()) {
115template<
typename Real>
117 if (lower_ != nullPtr) {
123template<
typename Real>
125 if (upper_ != nullPtr) {
131template<
typename Real>
134 Ptr<Vector<Real>> Pv = v.
clone();
137 Pv->axpy(
static_cast<Real
>(-1),v);
138 Real diff = Pv->norm();
139 return (diff <= ROL_EPSILON<Real>());
144template<
typename Real>
146 throw Exception::NotImplemented(
">>> BoundConstraint::applyInverseScalingFunction : This function has not been implemeted!");
149template<
typename Real>
151 throw Exception::NotImplemented(
">>> BoundConstraint::applyScalingFunctionJacobian : This function has not been implemeted!");
154template<
typename Real>
159template<
typename Real>
164template<
typename Real>
170template<
typename Real>
175template<
typename Real>
180template<
typename Real>
186template<
typename Real>
191template<
typename Real>
196template<
typename Real>
198 return (isLowerActivated() || isUpperActivated());
201template<
typename Real>
204 pruneUpperActive(v,x,eps);
205 pruneLowerActive(v,x,eps);
209template<
typename Real>
212 pruneUpperActive(v,g,x,xeps,geps);
213 pruneLowerActive(v,g,x,xeps,geps);
217template<
typename Real>
219 if (isLowerActivated()) {
221 Ptr<Vector<Real>> tmp = v.
clone();
223 pruneLowerActive(*tmp,x,eps);
228template<
typename Real>
230 if (isUpperActivated()) {
232 Ptr<Vector<Real>> tmp = v.
clone();
234 pruneUpperActive(*tmp,x,eps);
239template<
typename Real>
241 if (isLowerActivated()) {
243 Ptr<Vector<Real>> tmp = v.
clone();
245 pruneLowerActive(*tmp,g,x,xeps,geps);
250template<
typename Real>
252 if (isUpperActivated()) {
254 Ptr<Vector<Real>> tmp = v.
clone();
256 pruneUpperActive(*tmp,g,x,xeps,geps);
261template<
typename Real>
265 Ptr<Vector<Real>> tmp = v.
clone();
267 pruneActive(*tmp,x,eps);
272template<
typename Real>
276 Ptr<Vector<Real>> tmp = v.
clone();
278 pruneActive(*tmp,g,x,xeps,geps);
283template<
typename Real>
286 Ptr<Vector<Real>> tmp = g.
clone();
288 pruneActive(g,*tmp,x);
292template<
typename Real>
virtual const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
void computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
void pruneLowerInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
void pruneInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
bool isLowerActivated(void) const
Check if lower bound are on.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -active set.
Ptr< Vector< Real > > upper_
virtual void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the upper -active set.
bool isActivated(void) const
Check if bounds are on.
virtual void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
Real computeInf(const Vector< Real > &x) const
virtual void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
void deactivateLower(void)
Turn off lower bound.
void activateLower(void)
Turn on lower bound.
void deactivateUpper(void)
Turn off upper bound.
void deactivate(void)
Turn off bounds.
virtual void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the lower -active set.
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
Ptr< Vector< Real > > lower_
void activate(void)
Turn on bounds.
void activateUpper(void)
Turn on upper bound.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
virtual void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
bool isUpperActivated(void) const
Check if upper bound are on.
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
Defines the linear algebra or vector space interface.
virtual void plus(const Vector &x)=0
Compute , where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual int dimension() const
Return dimension of the vector space.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .