44 #ifndef ROL_BOUND_CONSTRAINT_DEF_H
45 #define ROL_BOUND_CONSTRAINT_DEF_H
49 template<
typename Real>
52 Real denom = (dim > 0 ?
static_cast<Real
>(
dim) : 1e15);
53 return std::sqrt(ROL_INF<Real>() / denom);
56 template<
typename Real>
58 : Lactivated_(true), Uactivated_(true) {}
60 template<
typename Real>
62 : Lactivated_(false), Uactivated_(false) {
67 catch(std::exception &e) {
73 template<
typename Real>
80 template<
typename Real>
87 template<
typename Real>
89 if (isUpperActivated()) {
94 template<
typename Real>
96 if (isUpperActivated()) {
101 template<
typename Real>
103 if (isLowerActivated()) {
108 template<
typename Real>
110 if (isLowerActivated()) {
115 template<
typename Real>
117 if (lower_ != nullPtr) {
123 template<
typename Real>
125 if (upper_ != nullPtr) {
131 template<
typename Real>
134 const Real tol(static_cast<Real>(1e-2)*std::sqrt(ROL_EPSILON<Real>()));
135 Ptr<Vector<Real>> Pv = v.
clone();
138 Pv->axpy(static_cast<Real>(-1),v);
139 Real diff = Pv->norm();
140 return (diff <= tol);
145 template<
typename Real>
147 throw Exception::NotImplemented(
">>> BoundConstraint::applyInverseScalingFunction : This function has not been implemeted!");
150 template<
typename Real>
152 throw Exception::NotImplemented(
">>> BoundConstraint::applyScalingFunctionJacobian : This function has not been implemeted!");
155 template<
typename Real>
160 template<
typename Real>
165 template<
typename Real>
171 template<
typename Real>
176 template<
typename Real>
181 template<
typename Real>
187 template<
typename Real>
192 template<
typename Real>
197 template<
typename Real>
199 return (isLowerActivated() || isUpperActivated());
202 template<
typename Real>
205 pruneUpperActive(v,x,eps);
206 pruneLowerActive(v,x,eps);
210 template<
typename Real>
213 pruneUpperActive(v,g,x,xeps,geps);
214 pruneLowerActive(v,g,x,xeps,geps);
218 template<
typename Real>
220 if (isLowerActivated()) {
222 Ptr<Vector<Real>> tmp = v.
clone();
224 pruneLowerActive(*tmp,x,eps);
229 template<
typename Real>
231 if (isUpperActivated()) {
233 Ptr<Vector<Real>> tmp = v.
clone();
235 pruneUpperActive(*tmp,x,eps);
240 template<
typename Real>
242 if (isLowerActivated()) {
244 Ptr<Vector<Real>> tmp = v.
clone();
246 pruneLowerActive(*tmp,g,x,xeps,geps);
251 template<
typename Real>
253 if (isUpperActivated()) {
255 Ptr<Vector<Real>> tmp = v.
clone();
257 pruneUpperActive(*tmp,g,x,xeps,geps);
262 template<
typename Real>
266 Ptr<Vector<Real>> tmp = v.
clone();
268 pruneActive(*tmp,x,eps);
273 template<
typename Real>
277 Ptr<Vector<Real>> tmp = v.
clone();
279 pruneActive(*tmp,g,x,xeps,geps);
284 template<
typename Real>
287 Ptr<Vector<Real>> tmp = g.
clone();
289 pruneActive(g,*tmp,x);
293 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.