10#ifndef ROL_BOUND_CONSTRAINT_DEF_H
11#define ROL_BOUND_CONSTRAINT_DEF_H
15template<
typename Real>
18 Real denom = (
dim > 0 ?
static_cast<Real
>(
dim) : 1e15);
19 return std::sqrt(ROL_INF<Real>() / denom);
22template<
typename Real>
24 : Lactivated_(true), Uactivated_(true) {}
26template<
typename Real>
28 : Lactivated_(false), Uactivated_(false) {
33 catch(std::exception &e) {
39template<
typename Real>
46template<
typename Real>
53template<
typename Real>
55 if (isUpperActivated()) {
60template<
typename Real>
62 if (isUpperActivated()) {
67template<
typename Real>
69 if (isLowerActivated()) {
74template<
typename Real>
76 if (isLowerActivated()) {
81template<
typename Real>
83 if (lower_ != nullPtr) {
89template<
typename Real>
91 if (upper_ != nullPtr) {
97template<
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);
111template<
typename Real>
113 throw Exception::NotImplemented(
">>> BoundConstraint::applyInverseScalingFunction : This function has not been implemeted!");
116template<
typename Real>
118 throw Exception::NotImplemented(
">>> BoundConstraint::applyScalingFunctionJacobian : This function has not been implemeted!");
121template<
typename Real>
126template<
typename Real>
131template<
typename Real>
137template<
typename Real>
142template<
typename Real>
147template<
typename Real>
153template<
typename Real>
158template<
typename Real>
163template<
typename Real>
165 return (isLowerActivated() || isUpperActivated());
168template<
typename Real>
171 pruneUpperActive(v,x,eps);
172 pruneLowerActive(v,x,eps);
176template<
typename Real>
179 pruneUpperActive(v,g,x,xeps,geps);
180 pruneLowerActive(v,g,x,xeps,geps);
184template<
typename Real>
186 if (isLowerActivated()) {
188 Ptr<Vector<Real>> tmp = v.
clone();
190 pruneLowerActive(*tmp,x,eps);
195template<
typename Real>
197 if (isUpperActivated()) {
199 Ptr<Vector<Real>> tmp = v.
clone();
201 pruneUpperActive(*tmp,x,eps);
206template<
typename Real>
208 if (isLowerActivated()) {
210 Ptr<Vector<Real>> tmp = v.
clone();
212 pruneLowerActive(*tmp,g,x,xeps,geps);
217template<
typename Real>
219 if (isUpperActivated()) {
221 Ptr<Vector<Real>> tmp = v.
clone();
223 pruneUpperActive(*tmp,g,x,xeps,geps);
228template<
typename Real>
232 Ptr<Vector<Real>> tmp = v.
clone();
234 pruneActive(*tmp,x,eps);
239template<
typename Real>
243 Ptr<Vector<Real>> tmp = v.
clone();
245 pruneActive(*tmp,g,x,xeps,geps);
250template<
typename Real>
253 Ptr<Vector<Real>> tmp = g.
clone();
255 pruneActive(g,*tmp,x);
259template<
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 .