44 #ifndef ROL_RISK_BOUND_CONSTRAINT_H 45 #define ROL_RISK_BOUND_CONSTRAINT_H 56 Teuchos::RCP<BoundConstraint<Real> >
bc_;
57 Teuchos::RCP<StdBoundConstraint<Real> >
stat_bc_;
64 mutable Teuchos::RCP<RiskVector<Real> >
lo_,
hi_;
75 std::string optType = parlist.sublist(
"SOL").get(
"Stochastic Optimization Type",
"Risk Averse");
76 if ( optType ==
"BPOE" ) {
82 lower_[0] =
static_cast<Real
>(0);
84 else if ( optType ==
"Risk Averse" ) {
89 else if ( optType ==
"Risk Neutral" || optType ==
"Mean Value" ) {
95 TEUCHOS_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
96 ">>> (ROL::RiskBoundConstraint): Invalid stochastic optimization type!" << optType);
108 if ( bc == Teuchos::null || (bc != Teuchos::null && !bc->isActivated()) ) {
116 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
119 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
120 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
121 bc_->update(*xv,flag,iter);
127 Teuchos::RCP<StdVector<Real> > xs = Teuchos::dyn_cast<
RiskVector<Real> >(x).getStatistic();
130 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
131 Teuchos::RCP<Vector<Real> > xvec = Teuchos::dyn_cast<
RiskVector<Real> >(x).getVector();
138 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
139 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
140 stat_bc_->pruneUpperActive(*vs,*xs,eps);
142 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
143 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
144 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
145 bc_->pruneUpperActive(*vv,*xv,eps);
151 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
152 Teuchos::RCP<const StdVector<Real> > gs = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getStatistic();
153 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
154 stat_bc_->pruneUpperActive(*vs,*gs,*xs,eps);
156 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
157 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
158 Teuchos::RCP<const Vector<Real> > gv = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getVector();
159 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
160 bc_->pruneUpperActive(*vv,*gv,*xv,eps);
166 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
167 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
168 stat_bc_->pruneLowerActive(*vs,*xs,eps);
170 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
171 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
172 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
173 bc_->pruneLowerActive(*vv,*xv,eps);
179 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
180 Teuchos::RCP<const StdVector<Real> > gs = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getStatistic();
181 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
182 stat_bc_->pruneLowerActive(*vs,*gs,*xs,eps);
184 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
185 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
186 Teuchos::RCP<const Vector<Real> > gv = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getVector();
187 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
188 bc_->pruneLowerActive(*vv,*gv,*xv,eps);
194 Teuchos::RCP<StdVector<Real> > us = Teuchos::dyn_cast<
RiskVector<Real> >(u).getStatistic();
195 stat_bc_->setVectorToUpperBound(*us);
197 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
198 Teuchos::RCP<Vector<Real> > uv = Teuchos::dyn_cast<
RiskVector<Real> >(u).getVector();
199 bc_->setVectorToUpperBound(*uv);
205 const Teuchos::RCP<const Vector<Real> > vlo =
bc_->getLowerVectorRCP();
215 const Teuchos::RCP<const Vector<Real> > vhi =
bc_->getUpperVectorRCP();
225 Teuchos::RCP<StdVector<Real> > ls = Teuchos::dyn_cast<
RiskVector<Real> >(l).getStatistic();
226 stat_bc_->setVectorToLowerBound(*ls);
228 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
229 Teuchos::RCP<Vector<Real> > lvec = Teuchos::dyn_cast<
RiskVector<Real> >(l).getVector();
230 bc_->setVectorToLowerBound(*lvec);
236 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
237 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
240 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
241 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
242 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
243 bc_->pruneActive(*vv,*xv,eps);
249 Teuchos::RCP<StdVector<Real> > vs = Teuchos::dyn_cast<
RiskVector<Real> >(v).getStatistic();
250 Teuchos::RCP<const StdVector<Real> > gs = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getStatistic();
251 Teuchos::RCP<const StdVector<Real> > xs = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getStatistic();
252 stat_bc_->pruneActive(*vs,*gs,*xs,eps);
254 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
255 Teuchos::RCP<Vector<Real> > vv = Teuchos::dyn_cast<
RiskVector<Real> >(v).getVector();
256 Teuchos::RCP<const Vector<Real> > gv = Teuchos::dyn_cast<
const RiskVector<Real> >(g).getVector();
257 Teuchos::RCP<const Vector<Real> > xv = Teuchos::dyn_cast<
const RiskVector<Real> >(x).getVector();
258 bc_->pruneActive(*vv,*gv,*xv,eps);
263 bool flagstat =
true, flagvec =
true;
265 Teuchos::RCP<const StdVector<Real> > vs = Teuchos::dyn_cast<
const RiskVector<Real> >(v).getStatistic();
266 flagstat =
stat_bc_->isFeasible(*vs);
268 if (
bc_ != Teuchos::null &&
bc_->isActivated() ) {
269 Teuchos::RCP<const Vector<Real> > vv = Teuchos::dyn_cast<
const RiskVector<Real> >(v).getVector();
270 flagvec =
bc_->isFeasible(*vv);
272 return (flagstat && flagvec);
Contains definitions for std::vector bound constraints.
std::vector< Real > lower_
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the lower -active set.
void activate(void)
Turn on bounds.
void setVectorToUpperBound(Vector< Real > &u)
Set the input vector to the upper bound.
std::vector< Real > upper_
Teuchos::RCP< RiskVector< Real > > hi_
Contains definitions of custom data types in ROL.
Teuchos::RCP< RiskVector< Real > > lo_
void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
Teuchos::RCP< StdBoundConstraint< Real > > stat_bc_
Defines the linear algebra or vector space interface.
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update bounds.
void pruneActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -binding set.
const Teuchos::RCP< const Vector< Real > > getLowerVectorRCP(void) const
Return the ref count pointer to the lower bound vector.
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -active set.
void pruneActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the -active set.
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -binding set.
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
Provides the interface to apply upper and lower bound constraints.
void deactivate(void)
Turn off bounds.
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
const Teuchos::RCP< const Vector< Real > > getUpperVectorRCP(void) const
Return the ref count pointer to the upper bound vector.
Teuchos::RCP< BoundConstraint< Real > > bc_
void pruneLowerActive(Vector< Real > &v, const Vector< Real > &g, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the lower -binding set.
RiskBoundConstraint(Teuchos::ParameterList &parlist, const Teuchos::RCP< BoundConstraint< Real > > &bc=Teuchos::null)