44 #ifndef ROL_RISK_BOUND_CONSTRAINT_H 45 #define ROL_RISK_BOUND_CONSTRAINT_H 56 Teuchos::RCP<BoundConstraint<Real> >
bc_;
66 std::string type = parlist.sublist(
"SOL").sublist(
"Risk Measure").get(
"Name",
"CVaR");
67 if ( type ==
"CVaR" || type ==
"HMCR" ||
68 type ==
"Log-Exponential Quadrangle" ||
69 type ==
"Quantile-Based Quadrangle" ||
70 type ==
"Truncated Mean Quadrangle" ) {
73 if ( !(bc_->isActivated()) ) {
79 const bool augmented =
false,
82 : bc_(bc), augmented_(augmented) {
83 lower_ = std::min(lower,upper);
84 upper_ = std::max(lower,upper);
85 if (!augmented_ && !(bc_->isActivated()) ) {
93 if ( name ==
"BPOE" ) { lower_ = 0.; }
97 if ( bc_ != Teuchos::null ) {
98 Teuchos::RCP<const Vector<Real> > xv
100 bc_->update(*xv,flag,iter);
107 xvar = std::min(upper_,std::max(lower_,xvar));
108 (Teuchos::dyn_cast<RiskVector<Real> >(x)).setStatistic(xvar);
110 if ( bc_ != Teuchos::null ) {
111 Teuchos::RCP<Vector<Real> > xvec = Teuchos::rcp_const_cast<
Vector<Real> >(
121 if ( xvar >= upper_ - eps ) {
125 if ( bc_ != Teuchos::null ) {
126 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
128 Teuchos::RCP<const Vector<Real> > xvec =
130 bc_->pruneUpperActive(*vvec,*xvec,eps);
138 if ( (xvar >= upper_ - eps) && gvar < 0.0 ) {
142 if ( bc_ != Teuchos::null ) {
143 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
145 Teuchos::RCP<const Vector<Real> > gvec =
147 Teuchos::RCP<const Vector<Real> > xvec =
149 bc_->pruneUpperActive(*vvec,*gvec,*xvec,eps);
156 if ( xvar <= lower_ + eps ) {
160 if ( bc_ != Teuchos::null ) {
161 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
163 Teuchos::RCP<const Vector<Real> > xvec
165 bc_->pruneLowerActive(*vvec,*xvec,eps);
173 if ( (xvar <= lower_ + eps) && gvar > 0.0 ) {
177 if ( bc_ != Teuchos::null ) {
178 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
180 Teuchos::RCP<const Vector<Real> > gvec
182 Teuchos::RCP<const Vector<Real> > xvec
184 bc_->pruneLowerActive(*vvec,*gvec,*xvec,eps);
192 if ( bc_ != Teuchos::null ) {
193 Teuchos::RCP<Vector<Real> > uvec = Teuchos::rcp_const_cast<
Vector<Real> >(
195 bc_->setVectorToUpperBound(*uvec);
203 if ( bc_ != Teuchos::null ) {
204 Teuchos::RCP<Vector<Real> > lvec = Teuchos::rcp_const_cast<
Vector<Real> >(
206 bc_->setVectorToLowerBound(*lvec);
213 if ( (xvar <= lower_ + eps) || (xvar >= upper_ - eps) ) {
217 if ( bc_ != Teuchos::null ) {
218 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
220 Teuchos::RCP<const Vector<Real> > xvec =
222 bc_->pruneActive(*vvec,*xvec,eps);
230 if ( ((xvar <= lower_ + eps) && gvar > 0.0) ||
231 ((xvar >= upper_ - eps) && gvar < 0.0) ) {
235 if ( bc_ != Teuchos::null ) {
236 Teuchos::RCP<Vector<Real> > vvec = Teuchos::rcp_const_cast<
Vector<Real> >(
238 Teuchos::RCP<const Vector<Real> > gvec =
240 Teuchos::RCP<const Vector<Real> > xvec =
242 bc_->pruneActive(*vvec,*gvec,*xvec,eps);
247 bool flagstat =
true, flagvec =
true;
250 flagstat = ((vvar >= lower_ && vvar <=
upper_) ?
true :
false);
252 if ( bc_ != Teuchos::null ) {
253 Teuchos::RCP<const Vector<Real> > vvec
255 if ( bc_->isActivated() ) {
256 flagvec = bc_->isFeasible(*vvec);
259 return (flagstat && flagvec);
RiskBoundConstraint(const Teuchos::RCP< BoundConstraint< Real > > &bc=Teuchos::null, const bool augmented=false, const Real lower=ROL_NINF, const Real upper=ROL_INF)
void setVectorToUpperBound(Vector< Real > &u)
Set the input vector to the upper bound.
Contains definitions of custom data types in ROL.
void setVectorToLowerBound(Vector< Real > &l)
Set the input vector to the lower bound.
const Real getStatistic(const int i=0) const
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 > &x, Real eps=0.0)
Set variables to zero if they correspond to the -active set.
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.
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
Provides the interface to apply upper and lower bound constraints.
static const double ROL_INF
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 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 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.
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.
RiskBoundConstraint(const std::string name, const Teuchos::RCP< BoundConstraint< Real > > &bc=Teuchos::null)
static const double ROL_NINF
void deactivate(void)
Turn off bounds.
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Teuchos::RCP< BoundConstraint< Real > > bc_
RiskBoundConstraint(Teuchos::ParameterList &parlist, const Teuchos::RCP< BoundConstraint< Real > > &bc=Teuchos::null)