10 #ifndef ROL_BOUND_CONSTRAINT_DEF_H
11 #define ROL_BOUND_CONSTRAINT_DEF_H
15 template<
typename Real>
18 Real denom = (dim > 0 ?
static_cast<Real
>(
dim) : 1e15);
19 return std::sqrt(ROL_INF<Real>() / denom);
22 template<
typename Real>
24 : Lactivated_(true), Uactivated_(true) {}
26 template<
typename Real>
28 : Lactivated_(false), Uactivated_(false) {
33 catch(std::exception &e) {
39 template<
typename Real>
46 template<
typename Real>
53 template<
typename Real>
55 if (isUpperActivated()) {
60 template<
typename Real>
62 if (isUpperActivated()) {
67 template<
typename Real>
69 if (isLowerActivated()) {
74 template<
typename Real>
76 if (isLowerActivated()) {
81 template<
typename Real>
83 if (lower_ != nullPtr) {
89 template<
typename Real>
91 if (upper_ != nullPtr) {
97 template<
typename Real>
100 const Real tol(static_cast<Real>(1e-2)*std::sqrt(ROL_EPSILON<Real>()));
101 Ptr<Vector<Real>> Pv = v.
clone();
104 Pv->axpy(static_cast<Real>(-1),v);
105 Real diff = Pv->norm();
106 return (diff <= tol);
111 template<
typename Real>
113 throw Exception::NotImplemented(
">>> BoundConstraint::applyInverseScalingFunction : This function has not been implemeted!");
116 template<
typename Real>
118 throw Exception::NotImplemented(
">>> BoundConstraint::applyScalingFunctionJacobian : This function has not been implemeted!");
121 template<
typename Real>
126 template<
typename Real>
131 template<
typename Real>
137 template<
typename Real>
142 template<
typename Real>
147 template<
typename Real>
153 template<
typename Real>
158 template<
typename Real>
163 template<
typename Real>
165 return (isLowerActivated() || isUpperActivated());
168 template<
typename Real>
171 pruneUpperActive(v,x,eps);
172 pruneLowerActive(v,x,eps);
176 template<
typename Real>
179 pruneUpperActive(v,g,x,xeps,geps);
180 pruneLowerActive(v,g,x,xeps,geps);
184 template<
typename Real>
186 if (isLowerActivated()) {
188 Ptr<Vector<Real>> tmp = v.
clone();
190 pruneLowerActive(*tmp,x,eps);
195 template<
typename Real>
197 if (isUpperActivated()) {
199 Ptr<Vector<Real>> tmp = v.
clone();
201 pruneUpperActive(*tmp,x,eps);
206 template<
typename Real>
208 if (isLowerActivated()) {
210 Ptr<Vector<Real>> tmp = v.
clone();
212 pruneLowerActive(*tmp,g,x,xeps,geps);
217 template<
typename Real>
219 if (isUpperActivated()) {
221 Ptr<Vector<Real>> tmp = v.
clone();
223 pruneUpperActive(*tmp,g,x,xeps,geps);
228 template<
typename Real>
232 Ptr<Vector<Real>> tmp = v.
clone();
234 pruneActive(*tmp,x,eps);
239 template<
typename Real>
243 Ptr<Vector<Real>> tmp = v.
clone();
245 pruneActive(*tmp,g,x,xeps,geps);
250 template<
typename Real>
253 Ptr<Vector<Real>> tmp = g.
clone();
255 pruneActive(g,*tmp,x);
259 template<
typename Real>
virtual bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
Ptr< Vector< Real > > upper_
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 plus(const Vector &x)=0
Compute , where .
virtual void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
void activateLower(void)
Turn on lower bound.
void activate(void)
Turn on bounds.
bool isActivated(void) const
Check if bounds are on.
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.
void pruneUpperInactive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0))
Set variables to zero if they correspond to the -inactive set.
Defines the linear algebra or vector space interface.
virtual const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
virtual void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
void activateUpper(void)
Turn on upper bound.
Ptr< Vector< Real > > lower_
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 deactivateUpper(void)
Turn off upper bound.
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 computeProjectedStep(Vector< Real > &v, const Vector< Real > &x)
Compute projected step.
void deactivateLower(void)
Turn off lower bound.
virtual void project(Vector< Real > &x)
Project optimization variables onto the bounds.
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
void pruneInactive(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.
Real computeInf(const Vector< Real > &x) const
void computeProjectedGradient(Vector< Real > &g, const Vector< Real > &x)
Compute projected gradient.
virtual void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
void deactivate(void)
Turn off bounds.
bool isLowerActivated(void) const
Check if lower bound are on.
bool isUpperActivated(void) const
Check if upper bound are on.