10 #ifndef ROL_BOUND_CONSTRAINT_PARTITIONED_H
11 #define ROL_BOUND_CONSTRAINT_PARTITIONED_H
26 template<
typename Real>
34 std::vector<Ptr<BoundConstraint<Real>>>
bnd_;
59 std::vector<Ptr<Vector<Real>>> lp(dim_);
60 std::vector<Ptr<Vector<Real>>> up(dim_);
63 lp[k] = x[k]->clone();
71 catch (std::exception &e1) {
73 lp[k] = x[k]->clone();
76 catch (std::exception &e2) {
82 up[k] = x[k]->clone();
90 catch (std::exception &e1) {
92 up[k] = x[k]->clone();
95 catch (std::exception &e2) {
113 PV &xpv =
dynamic_cast<PV&
>(x);
122 PV &xpv =
dynamic_cast<PV&
>(x);
125 bnd_[k]->projectInterior(*xpv.
get(k));
131 PV &vpv =
dynamic_cast<PV&
>(v);
132 const PV &xpv =
dynamic_cast<const PV&
>(x);
135 bnd_[k]->pruneUpperActive(*(vpv.
get(k)),*(xpv.
get(k)),eps);
141 PV &vpv =
dynamic_cast<PV&
>(v);
142 const PV &gpv =
dynamic_cast<const PV&
>(g);
143 const PV &xpv =
dynamic_cast<const PV&
>(x);
146 bnd_[k]->pruneUpperActive(*(vpv.
get(k)),*(gpv.
get(k)),*(xpv.
get(k)),xeps,geps);
152 PV &vpv =
dynamic_cast<PV&
>(v);
153 const PV &xpv =
dynamic_cast<const PV&
>(x);
156 bnd_[k]->pruneLowerActive(*(vpv.
get(k)),*(xpv.
get(k)),eps);
162 PV &vpv =
dynamic_cast<PV&
>(v);
163 const PV &gpv =
dynamic_cast<const PV&
>(g);
164 const PV &xpv =
dynamic_cast<const PV&
>(x);
167 bnd_[k]->pruneLowerActive(*(vpv.
get(k)),*(gpv.
get(k)),*(xpv.
get(k)),xeps,geps);
173 bool feasible =
true;
174 const PV &vs =
dynamic_cast<const PV&
>(v);
177 feasible = feasible &&
bnd_[k]->isFeasible(*(vs.
get(k)));
184 PV &dvpv =
dynamic_cast<PV&
>(dv);
185 const PV &vpv =
dynamic_cast<const PV&
>(v);
186 const PV &xpv =
dynamic_cast<const PV&
>(x);
187 const PV &gpv =
dynamic_cast<const PV&
>(g);
190 bnd_[k]->applyInverseScalingFunction(*(dvpv.
get(k)),*(vpv.
get(k)),*(xpv.
get(k)),*(gpv.
get(k)));
196 PV &dvpv =
dynamic_cast<PV&
>(dv);
197 const PV &vpv =
dynamic_cast<const PV&
>(v);
198 const PV &xpv =
dynamic_cast<const PV&
>(x);
199 const PV &gpv =
dynamic_cast<const PV&
>(g);
202 bnd_[k]->applyScalingFunctionJacobian(*(dvpv.
get(k)),*(vpv.
get(k)),*(xpv.
get(k)),*(gpv.
get(k)));
210 template<
typename Real>
211 Ptr<BoundConstraint<Real>>
218 Ptr<BND> temp[] = {bnd1, bnd2};
219 return makePtr<BNDP>( std::vector<Ptr<BND>>(temp,temp+2) );
Ptr< Vector< Real > > upper_
typename PV< Real >::size_type size_type
BoundConstraint_Partitioned(const std::vector< Ptr< BoundConstraint< Real >>> &bnd, const std::vector< Ptr< Vector< Real >>> &x)
ROL::Ptr< const Vector< Real > > get(size_type i) const
void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
void activate(void)
Turn on bounds.
bool isActivated(void) const
Check if bounds are on.
Defines the linear algebra of vector space on a generic partitioned vector.
Contains definitions of custom data types in ROL.
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.
std::vector< Ptr< BoundConstraint< Real > > > bnd_
Ptr< BoundConstraint< Real > > CreateBoundConstraint_Partitioned(const Ptr< BoundConstraint< Real >> &bnd1, const Ptr< BoundConstraint< Real >> &bnd2)
Ptr< Vector< Real > > lower_
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 pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real xeps=Real(0), Real geps=Real(0))
Set variables to zero if they correspond to the upper -binding set.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
A composite composite BoundConstraint formed from bound constraints on subvectors of a PartitionedVec...
virtual const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real xeps=Real(0), Real geps=Real(0))
Set variables to zero if they correspond to the -binding set.
Provides the interface to apply upper and lower bound constraints.
void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
~BoundConstraint_Partitioned()
std::vector< Real >::size_type uint
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
PartitionedVector< Real > PV
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 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.
void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.