44 #ifndef ROL_BOUND_CONSTRAINT_PARTITIONED_H 45 #define ROL_BOUND_CONSTRAINT_PARTITIONED_H 65 typedef typename std::vector<Real>::size_type
uint;
68 std::vector<Teuchos::RCP<BoundConstraint<Real> > >
bnd_;
83 : bnd_(bnd), dim_(bnd.size()) {
85 for( uint k=0; k<
dim_; ++k ) {
91 std::vector<Teuchos::RCP<Vector<Real> > > lp;
92 std::vector<Teuchos::RCP<Vector<Real> > > up;
94 for( uint k=0; k<
dim_; ++k ) {
99 l_ = Teuchos::rcp(
new PV(lp) );
100 u_ = Teuchos::rcp(
new PV(up) );
113 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
115 for( uint k=0; k<
dim_; ++k ) {
117 bnd_[k]->update(*(xpv.
get(k)),flag,iter);
132 PV &xpv = Teuchos::dyn_cast<PV>(x);
133 for( uint k=0; k<
dim_; ++k ) {
135 bnd_[k]->project(*xpv.
get(k));
153 PV &vpv = Teuchos::dyn_cast<PV>(v);
154 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
156 for( uint k=0; k<
dim_; ++k ) {
158 bnd_[k]->pruneUpperActive(*(vpv.
get(k)),*(xpv.get(k)),eps);
181 PV &vpv = Teuchos::dyn_cast<PV>(v);
182 const PV &gpv = Teuchos::dyn_cast<
const PV>(g);
183 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
185 for( uint k=0; k<
dim_; ++k ) {
187 bnd_[k]->pruneUpperActive(*(vpv.
get(k)),*(gpv.get(k)),*(xpv.get(k)),eps);
208 PV &vpv = Teuchos::dyn_cast<PV>(v);
209 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
211 for( uint k=0; k<
dim_; ++k ) {
213 bnd_[k]->pruneLowerActive(*(vpv.
get(k)),*(xpv.get(k)),eps);
235 PV &vpv = Teuchos::dyn_cast<PV>(v);
236 const PV &gpv = Teuchos::dyn_cast<
const PV>(g);
237 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
239 for( uint k=0; k<
dim_; ++k ) {
241 bnd_[k]->pruneLowerActive(*(vpv.
get(k)),*(gpv.get(k)),*(xpv.get(k)),eps);
314 PV &vpv = Teuchos::dyn_cast<PV>(v);
315 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
317 for( uint k=0; k<
dim_; ++k ) {
322 bnd_[k]->pruneActive(*(vpv.
get(k)),*(xpv.get(k)),eps);
341 PV &vpv = Teuchos::dyn_cast<PV>(v);
342 const PV &gpv = Teuchos::dyn_cast<
const PV>(g);
343 const PV &xpv = Teuchos::dyn_cast<
const PV>(x);
345 for( uint k=0; k<
dim_; ++k ) {
352 bnd_[k]->pruneActive(*(vpv.
get(k)),*(gpv.get(k)),*(xpv.get(k)),eps);
364 bool feasible =
true;
365 const PV &vs = Teuchos::dyn_cast<
const PV>(v);
367 for( uint k=0; k<
dim_; ++k ) {
369 feasible = feasible && bnd_[k]->isFeasible(*(vs.
get(k)));
400 Teuchos::RCP<BoundConstraint<Real> >
404 using Teuchos::RCP;
using Teuchos::rcp;
407 RCP<BND> temp[] = {bnd1, bnd2};
408 return rcp(
new BNDP( std::vector<RCP<BND> >(temp,temp+2) ) );
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -active set.
void activate(void)
Turn on bounds.
Teuchos::RCP< BoundConstraint< Real > > CreateBoundConstraint_Partitioned(const Teuchos::RCP< BoundConstraint< Real > > &bnd1, const Teuchos::RCP< BoundConstraint< Real > > &bnd2)
Defines the linear algebra of vector space on a generic partitioned vector.
Teuchos::RCP< const Vector< Real > > get(size_type i) const
Contains definitions of custom data types in ROL.
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the lower -active set.
void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
BoundConstraint_Partitioned(const std::vector< Teuchos::RCP< BoundConstraint< Real > > > &bnd)
Default constructor.
Defines the linear algebra or vector space interface.
void pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the -binding set.
const Teuchos::RCP< Vector< Real > > getUpperVectorRCP(void)
Return the ref count pointer to the upper bound vector.
void setVectorToUpperBound(Vector< Real > &u)
Set the input vector to the upper bound.
bool isActivated(void)
Check if bounds are on.
const Teuchos::RCP< const Vector< Real > > getUpperVectorRCP(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 eps=0.0)
Set variables to zero if they correspond to the lower -binding set.
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the upper -active set.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update bounds.
A composite composite BoundConstraint formed from bound constraints on subvectors of a PartitionedVec...
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0.0)
Set variables to zero if they correspond to the upper -binding set.
Provides the interface to apply upper and lower bound constraints.
std::vector< Teuchos::RCP< BoundConstraint< Real > > > bnd_
~BoundConstraint_Partitioned()
std::vector< Real >::size_type uint
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
const Teuchos::RCP< const Vector< Real > > getLowerVectorRCP(void) const
Return the ref count pointer to the lower bound vector.
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
virtual void set(const Vector &x)
Set where .
PartitionedVector< Real > PV
void deactivate(void)
Turn off bounds.
const Teuchos::RCP< Vector< Real > > getLowerVectorRCP(void)
Return the ref count pointer to the lower bound vector.