10#ifndef ROL_BOUNDS_DEF_H
11#define ROL_BOUNDS_DEF_H
24template<
typename Real>
41template<
typename Real>
43 const Real scale,
const Real feasTol)
47 const Real half(0.5), one(1);
56template<
typename Real>
58 struct Lesser :
public Elementwise::BinaryFunction<Real> {
59 Real
apply(
const Real &xc,
const Real &yc)
const {
return xc<yc ? xc : yc; }
62 struct Greater :
public Elementwise::BinaryFunction<Real> {
63 Real
apply(
const Real &xc,
const Real &yc)
const {
return xc>yc ? xc : yc; }
74template<
typename Real>
79 class LowerFeasible :
public Elementwise::BinaryFunction<Real> {
84 LowerFeasible(
const Real eps,
const Real diff)
85 : eps_(eps), diff_(diff) {}
86 Real
apply(
const Real &xc,
const Real &yc )
const {
89 Real val = ((yc <-tol) ? yc*(one-eps_)
90 : ((yc > tol) ? yc*(one+eps_)
92 val = std::min(yc+eps_*diff_, val);
93 return xc < val ? val : xc;
100 class UpperFeasible :
public Elementwise::BinaryFunction<Real> {
105 UpperFeasible(
const Real eps,
const Real diff)
106 : eps_(eps), diff_(diff) {}
107 Real
apply(
const Real &xc,
const Real &yc )
const {
110 Real val = ((yc <-tol) ? yc*(one+eps_)
111 : ((yc > tol) ? yc*(one-eps_)
113 val = std::max(yc-eps_*diff_, val);
114 return xc > val ? val : xc;
121template<
typename Real>
124 Real one(1), epsn(std::min(
scale_*eps,
static_cast<Real
>(0.1)*
min_diff_));
134template<
typename Real>
137 Real one(1), epsn(std::min(
scale_*xeps,
static_cast<Real
>(0.1)*
min_diff_));
143 mask_->applyBinary(op,g);
149template<
typename Real>
152 Real one(1), epsn(std::min(
scale_*eps,
static_cast<Real
>(0.1)*
min_diff_));
162template<
typename Real>
165 Real one(1), epsn(std::min(
scale_*xeps,
static_cast<Real
>(0.1)*
min_diff_));
171 mask_->applyBinary(op,g);
177template<
typename Real>
179 const Real half(0.5);
180 bool flagU =
false, flagL =
false;
191 return ((flagU || flagL) ?
false :
true);
194template<
typename Real>
198 const Real
zero(0), one(1);
217 mask_->applyBinary(Elementwise::Min<Real>(),g);
222 mask_->applyBinary(Elementwise::Min<Real>(),d);
226 mask_->setScalar(one);
231 mask_->applyUnary(Elementwise::AbsoluteValue<Real>());
241 mask_->applyBinary(Elementwise::Min<Real>(),*
upper_);
254template<
typename Real>
257 dv.
applyBinary(Elementwise::DivideAndInvert<Real>(),v);
260template<
typename Real>
262 const Real one(1), two(2), three(3);
271 mask_->axpy(-one,dv);
275 mask_->setScalar(three);
281 mask_->applyUnary(Elementwise::Sign<Real>());
288 mask_->applyUnary(Elementwise::Sign<Real>());
292 mask_->setScalar(one);
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
bool isLowerActivated(void) const
Check if lower bound are on.
Ptr< Vector< Real > > upper_
Real computeInf(const Vector< Real > &x) const
void activateLower(void)
Turn on lower bound.
Ptr< Vector< Real > > lower_
void activateUpper(void)
Turn on upper bound.
bool isUpperActivated(void) const
Check if upper bound are on.
Elementwise::ReductionMin< Real > minimum_
ROL::Bounds::isGreater isGreater_
void buildScalingFunction(Vector< Real > &d, const Vector< Real > &x, const Vector< Real > &g) const
void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const override
Apply inverse scaling function.
ROL::Bounds::SetZeroEntry setZeroEntry_
void project(Vector< Real > &x) override
Project optimization variables onto the bounds.
ROL::Bounds::BuildC buildC_
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0)) override
Set variables to zero if they correspond to the upper -active set.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=Real(0)) override
Set variables to zero if they correspond to the lower -active set.
Ptr< Vector< Real > > mask_
void projectInterior(Vector< Real > &x) override
Project optimization variables into the interior of the feasible set.
void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const override
Apply scaling function Jacobian.
ROL::Bounds::PruneBinding prune_
Bounds(const Vector< Real > &x, bool isLower=true, Real scale=1, Real feasTol=std::sqrt(ROL_EPSILON< Real >()))
bool isFeasible(const Vector< Real > &v) override
Check if the vector, v, is feasible.
Elementwise::ReductionMax< Real > maximum_
Defines the linear algebra or vector space interface.
virtual void set(const Vector &x)
Set where .
virtual void setScalar(const Real C)
Set where .
virtual void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector &x)
virtual void plus(const Vector &x)=0
Compute , where .
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
ROL::BlockOperator2Diagonal BlockOperator2 apply(V &Hv, const V &v, Real &tol) const
Real ROL_EPSILON(void)
Platform-dependent machine epsilon.