44 #ifndef ROL_RISK_BOUND_CONSTRAINT_H
45 #define ROL_RISK_BOUND_CONSTRAINT_H
56 ROL::Ptr<BoundConstraint<Real> >
bc_;
61 std::vector<ROL::Ptr<StdBoundConstraint<Real> > >
statCon_bc_;
72 mutable ROL::Ptr<RiskVector<Real> >
lo_,
hi_;
76 std::vector<Real> &lower,
77 std::vector<Real> &upper,
80 lower.clear(); upper.clear();
82 std::string optType = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
83 if ( optType ==
"Risk Averse" ||
84 optType ==
"Deviation" ||
85 optType ==
"Regret" ||
87 optType ==
"Probability" ) {
89 RandVarFunctionalInfo<Real>(parlist,name,nStat,lower,upper,activated);
90 augmented = (nStat > 0) ?
true :
false;
92 else if ( optType ==
"Risk Neutral" || optType ==
"Mean Value" ) {
98 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
99 ">>> (ROL::RiskBoundConstraint): Invalid stochastic optimization type!" << optType);
105 if (parlist != ROL::nullPtr) {
129 int size = parlist.size();
135 bool activated =
false;
136 for (
int i = 0; i < size; ++i) {
137 if ( parlist[i] != ROL::nullPtr ) {
138 bool augmented =
false;
140 std::vector<Real> lo, up;
180 if ( !activatedObj ) {
181 if ( bc == ROL::nullPtr || (bc != ROL::nullPtr && !bc->isActivated()) ) {
197 if ( !activatedCon ) {
198 if ( bc == ROL::nullPtr || (bc != ROL::nullPtr && !bc->isActivated()) ) {
206 std::vector<ROL::Ptr<ROL::ParameterList> > &parlistCon,
216 if ( !activatedObj && !activatedCon ) {
217 if ( bc == ROL::nullPtr || (bc != ROL::nullPtr && !bc->isActivated()) ) {
238 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(0);
243 for (
int i = 0; i < size; ++i) {
245 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(1,i);
250 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
251 ROL::Ptr<const Vector<Real> > xv =
dynamic_cast<const RiskVector<Real>&
>(x).getVector();
252 bc_->update(*xv,flag,iter);
258 ROL::Ptr<StdVector<Real> > xs =
dynamic_cast<RiskVector<Real>&
>(x).getStatisticVector(0);
263 for (
int i = 0; i < size; ++i) {
265 ROL::Ptr<StdVector<Real> > xs =
dynamic_cast<RiskVector<Real>&
>(x).getStatisticVector(1,i);
270 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
271 ROL::Ptr<Vector<Real> > xvec =
dynamic_cast<RiskVector<Real>&
>(x).getVector();
278 ROL::Ptr<StdVector<Real> > xs =
dynamic_cast<RiskVector<Real>&
>(x).getStatisticVector(0);
283 for (
int i = 0; i < size; ++i) {
285 ROL::Ptr<StdVector<Real> > xs =
dynamic_cast<RiskVector<Real>&
>(x).getStatisticVector(1,i);
290 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
291 ROL::Ptr<Vector<Real> > xvec =
dynamic_cast<RiskVector<Real>&
>(x).getVector();
292 bc_->projectInterior(*xvec);
298 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(0);
299 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(0);
304 for (
int i = 0; i < size; ++i) {
306 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(1,i);
307 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(1,i);
312 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
313 ROL::Ptr<Vector<Real> > vv =
dynamic_cast<RiskVector<Real>&
>(v).getVector();
314 ROL::Ptr<const Vector<Real> > xv =
dynamic_cast<const RiskVector<Real>&
>(x).getVector();
315 bc_->pruneUpperActive(*vv,*xv,eps);
321 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(0);
322 ROL::Ptr<const StdVector<Real> > gs =
dynamic_cast<const RiskVector<Real>&
>(g).getStatisticVector(0);
323 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(0);
328 for (
int i = 0; i < size; ++i) {
330 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(1,i);
331 ROL::Ptr<const StdVector<Real> > gs =
dynamic_cast<const RiskVector<Real>&
>(g).getStatisticVector(1,i);
332 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(1,i);
337 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
338 ROL::Ptr<Vector<Real> > vv =
dynamic_cast<RiskVector<Real>&
>(v).getVector();
339 ROL::Ptr<const Vector<Real> > gv =
dynamic_cast<const RiskVector<Real>&
>(g).getVector();
340 ROL::Ptr<const Vector<Real> > xv =
dynamic_cast<const RiskVector<Real>&
>(x).getVector();
341 bc_->pruneUpperActive(*vv,*gv,*xv,eps);
347 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(0);
348 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(0);
353 for (
int i = 0; i < size; ++i) {
355 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(1,i);
356 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(1,i);
361 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
362 ROL::Ptr<Vector<Real> > vv =
dynamic_cast<RiskVector<Real>&
>(v).getVector();
363 ROL::Ptr<const Vector<Real> > xv =
dynamic_cast<const RiskVector<Real>&
>(x).getVector();
364 bc_->pruneLowerActive(*vv,*xv,eps);
370 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(0);
371 ROL::Ptr<const StdVector<Real> > gs =
dynamic_cast<const RiskVector<Real>&
>(g).getStatisticVector(0);
372 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(0);
377 for (
int i = 0; i < size; ++i) {
379 ROL::Ptr<StdVector<Real> > vs =
dynamic_cast<RiskVector<Real>&
>(v).getStatisticVector(1,i);
380 ROL::Ptr<const StdVector<Real> > gs =
dynamic_cast<const RiskVector<Real>&
>(g).getStatisticVector(1,i);
381 ROL::Ptr<const StdVector<Real> > xs =
dynamic_cast<const RiskVector<Real>&
>(x).getStatisticVector(1,i);
386 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
387 ROL::Ptr<Vector<Real> > vv =
dynamic_cast<RiskVector<Real>&
>(v).getVector();
388 ROL::Ptr<const Vector<Real> > gv =
dynamic_cast<const RiskVector<Real>&
>(g).getVector();
389 ROL::Ptr<const Vector<Real> > xv =
dynamic_cast<const RiskVector<Real>&
>(x).getVector();
390 bc_->pruneLowerActive(*vv,*gv,*xv,eps);
396 const ROL::Ptr<const Vector<Real> > vlo =
bc_->getLowerBound();
397 ROL::Ptr<std::vector<Real> > lowerObj = ROL::makePtr<std::vector<Real>>(
lowerObj_);
399 std::vector<ROL::Ptr<std::vector<Real> > > lowerCon(size);
400 for (
int i = 0; i < size; ++i) {
401 lowerCon[i] = ROL::makePtr<std::vector<Real>>(
lowerCon_[i]);
403 lo_ = ROL::makePtr<RiskVector<Real>>(ROL::constPtrCast<Vector<Real>>(vlo),
412 const ROL::Ptr<const Vector<Real> > vhi =
bc_->getUpperBound();
413 ROL::Ptr<std::vector<Real> > upperObj = ROL::makePtr<std::vector<Real>>(
upperObj_);
415 std::vector<ROL::Ptr<std::vector<Real> > > upperCon(size);
416 for (
int i = 0; i < size; ++i) {
417 upperCon[i] = ROL::makePtr<std::vector<Real>>(
upperCon_[i]);
419 hi_ = ROL::makePtr<RiskVector<Real>>(ROL::constPtrCast<Vector<Real>>(vhi),
427 bool flagstat =
true, flagcon =
true, flagvec =
true;
429 ROL::Ptr<const StdVector<Real> > vs =
dynamic_cast<const RiskVector<Real>&
>(v).getStatisticVector(0);
434 for (
int i = 0; i < size; ++i) {
436 ROL::Ptr<const StdVector<Real> > vs =
dynamic_cast<const RiskVector<Real>&
>(v).getStatisticVector(1,i);
437 flagcon = (!
statCon_bc_[i]->isFeasible(*vs) ?
false : flagcon);
441 if (
bc_ != ROL::nullPtr &&
bc_->isActivated() ) {
442 ROL::Ptr<const Vector<Real> > vv =
dynamic_cast<const RiskVector<Real>&
>(v).getVector();
443 flagvec =
bc_->isFeasible(*vv);
445 return (flagstat && flagcon && flagvec);
Contains definitions for std::vector bound constraints.
std::vector< bool > activatedCon_
RiskBoundConstraint(const Ptr< BoundConstraint< Real > > &bc)
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.
bool buildConStatBnd(std::vector< ROL::Ptr< ROL::ParameterList > > &parlist)
Contains definitions of custom data types in ROL.
ROL::Ptr< RiskVector< Real > > lo_
std::vector< Real > lowerObj_
ROL::Ptr< StdBoundConstraint< Real > > statObj_bc_
Defines the linear algebra or vector space interface.
ROL::Ptr< RiskVector< Real > > hi_
const ROL::Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
std::vector< std::vector< Real > > lowerCon_
void update(const Vector< Real > &x, bool flag=true, int iter=-1)
Update bounds.
void pruneUpperActive(Vector< Real > &v, const Vector< Real > &x, Real eps=0)
Set variables to zero if they correspond to the upper -active set.
const ROL::Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
bool buildObjStatBnd(ROL::Ptr< ROL::ParameterList > &parlist)
std::vector< int > nStatCon_
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.
RiskBoundConstraint(ROL::Ptr< ROL::ParameterList > &parlist, const ROL::Ptr< BoundConstraint< Real > > &bc=ROL::nullPtr)
std::vector< std::vector< Real > > upperCon_
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
std::vector< ROL::Ptr< StdBoundConstraint< Real > > > statCon_bc_
Provides the interface to apply upper and lower bound constraints.
std::vector< Real > upperObj_
void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
ROL::Ptr< BoundConstraint< Real > > bc_
void setBoundInfo(ROL::ParameterList &parlist, int &nStat, std::vector< Real > &lower, std::vector< Real > &upper, bool &augmented, bool &activated)
void deactivate(void)
Turn off bounds.
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
RiskBoundConstraint(ROL::Ptr< ROL::ParameterList > &parlistObj, std::vector< ROL::Ptr< ROL::ParameterList > > &parlistCon, const ROL::Ptr< BoundConstraint< Real > > &bc=ROL::nullPtr)
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 -binding set.
RiskBoundConstraint(std::vector< ROL::Ptr< ROL::ParameterList > > &parlist, const ROL::Ptr< BoundConstraint< Real > > &bc=ROL::nullPtr)