ROL
ROL_RiskBoundConstraint.hpp
Go to the documentation of this file.
1 // @HEADER
2 // ************************************************************************
3 //
4 // Rapid Optimization Library (ROL) Package
5 // Copyright (2014) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8 // license for use of this work by or on behalf of the U.S. Government.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact lead developers:
38 // Drew Kouri (dpkouri@sandia.gov) and
39 // Denis Ridzal (dridzal@sandia.gov)
40 //
41 // ************************************************************************
42 // @HEADER
43 
44 #ifndef ROL_RISK_BOUND_CONSTRAINT_H
45 #define ROL_RISK_BOUND_CONSTRAINT_H
46 
48 #include "ROL_RiskVector.hpp"
49 #include "ROL_Types.hpp"
50 
51 namespace ROL {
52 
53 template <class Real>
54 class RiskBoundConstraint : public BoundConstraint<Real> {
55 private:
56  Ptr<BoundConstraint<Real>> bc_;
57 
58  Ptr<StdBoundConstraint<Real>> statObj_bc_;
59  std::vector<Real> lowerObj_, upperObj_;
60 
61  std::vector<Ptr<StdBoundConstraint<Real>>> statCon_bc_;
62  std::vector<std::vector<Real>> lowerCon_, upperCon_;
63 
65  int nStatObj_;
66 
68  std::vector<bool> activatedCon_;
69  std::vector<int> nStatCon_;
70 
72  mutable Ptr<RiskVector<Real>> lo_, hi_;
73 
74  void setBoundInfo(ParameterList &parlist,
75  int &nStat,
76  std::vector<Real> &lower,
77  std::vector<Real> &upper,
78  bool &augmented,
79  bool &activated) {
80  lower.clear(); upper.clear();
81  // Get stochastic optimization information
82  std::string optType = parlist.sublist("SOL").get("Type","Risk Averse");
83  if ( optType == "Risk Averse" ||
84  optType == "Deviation" ||
85  optType == "Regret" ||
86  optType == "Error" ||
87  optType == "Probability" ) {
88  std::string name;
89  RandVarFunctionalInfo<Real>(parlist,name,nStat,lower,upper,activated);
90  augmented = (nStat > 0) ? true : false;
91  }
92  else if ( optType == "Risk Neutral" || optType == "Mean Value" ) {
93  augmented = false;
94  activated = false;
95  nStat = 0;
96  }
97  else {
98  ROL_TEST_FOR_EXCEPTION(true,std::invalid_argument,
99  ">>> (ROL::RiskBoundConstraint): Invalid stochastic optimization type!" << optType);
100  }
101  }
102 
103  bool buildObjStatBnd(Ptr<ParameterList> &parlist) {
104  // Objective statistic bound
105  if (parlist != nullPtr) {
107  // Build statistic bound constraint
108  if ( augmentedObj_ ) {
109  statObj_bc_ = makePtr<StdBoundConstraint<Real>>(lowerObj_,upperObj_);
110  }
111  }
112  else {
113  augmentedObj_ = false;
114  activatedObj_ = false;
115  nStatObj_ = 0;
116  statObj_bc_ = nullPtr;
117  }
118  // Determine whether or not bound constraint is activated
119  if ( !activatedObj_ ) {
120  if ( statObj_bc_ != nullPtr ) {
121  statObj_bc_->deactivate();
122  }
123  }
124  return activatedObj_;
125  }
126 
127  bool buildConStatBnd(std::vector<Ptr<ParameterList>> &parlist) {
128  // Constraint statistic bound
129  int size = parlist.size();
130  nStatCon_.clear(); nStatCon_.resize(size,0);
131  lowerCon_.clear(); lowerCon_.resize(size);
132  upperCon_.clear(); upperCon_.resize(size);
133  activatedCon_.clear(); activatedCon_.resize(size,false);
134  statCon_bc_.clear(); statCon_bc_.resize(size,nullPtr);
135  bool activated = false;
136  for (int i = 0; i < size; ++i) {
137  if ( parlist[i] != nullPtr ) {
138  bool augmented = false;
139  int nStat = 0;
140  std::vector<Real> lo, up;
141  bool act = false;
142  setBoundInfo(*parlist[i],nStat,lo,up,augmented,act);
143  nStatCon_[i] = nStat;
144  lowerCon_[i] = lo;
145  upperCon_[i] = up;
146  activatedCon_[i] = act;
147  augmentedCon_ = (augmented ? true : augmentedCon_);
148  // Build statistic bound constraint
149  if ( augmented ) {
150  statCon_bc_[i] = makePtr<StdBoundConstraint<Real>>(lowerCon_[i],upperCon_[i]);
151  }
152  }
153  else {
154  activatedCon_[i] = false;
155  nStatCon_[i] = 0;
156  statCon_bc_[i] = nullPtr;
157  }
158  if ( !activatedCon_[i] ) {
159  if ( statCon_bc_[i] != nullPtr ) {
160  statCon_bc_[i]->deactivate();
161  }
162  }
163  activated = (activatedCon_[i] ? true : activated);
164  }
165  return activated;
166  }
167 
168 public:
169 
170  // Objective risk only
171  RiskBoundConstraint(Ptr<ParameterList> &parlist,
172  const Ptr<BoundConstraint<Real>> &bc = nullPtr)
173  : BoundConstraint<Real>(), bc_(bc), statObj_bc_(nullPtr),
174  augmentedObj_(false), activatedObj_(false),
175  augmentedCon_(false),
176  isLOinitialized_(false), isHIinitialized_(false) {
177  bool activatedObj = buildObjStatBnd(parlist);
178  // Determine whether or not bound constraint is activated
180  if ( !activatedObj ) {
181  if ( bc == nullPtr || (bc != nullPtr && !bc->isActivated()) ) {
183  }
184  }
185  }
186 
187  // Constraint risk only
188  RiskBoundConstraint(std::vector<Ptr<ParameterList>> &parlist,
189  const Ptr<BoundConstraint<Real>> &bc = nullPtr)
190  : BoundConstraint<Real>(), bc_(bc), statObj_bc_(nullPtr),
191  augmentedObj_(false), activatedObj_(false),
192  augmentedCon_(false),
193  isLOinitialized_(false), isHIinitialized_(false) {
194  bool activatedCon = buildConStatBnd(parlist);
195  // Determine whether or not bound constraint is activated
197  if ( !activatedCon ) {
198  if ( bc == nullPtr || (bc != nullPtr && !bc->isActivated()) ) {
200  }
201  }
202  }
203 
204  // Objective and constraint risk
205  RiskBoundConstraint(Ptr<ParameterList> &parlistObj,
206  std::vector<Ptr<ParameterList>> &parlistCon,
207  const Ptr<BoundConstraint<Real>> &bc = nullPtr)
208  : BoundConstraint<Real>(), bc_(bc), statObj_bc_(nullPtr),
209  augmentedObj_(false), activatedObj_(false),
210  augmentedCon_(false),
211  isLOinitialized_(false), isHIinitialized_(false) {
212  bool activatedObj = buildObjStatBnd(parlistObj);
213  bool activatedCon = buildConStatBnd(parlistCon);
214  // Determine whether or not bound constraint is activated
216  if ( !activatedObj && !activatedCon ) {
217  if ( bc == nullPtr || (bc != nullPtr && !bc->isActivated()) ) {
219  }
220  }
221  }
222 
223  // Objective only -- no statistic
225  : BoundConstraint<Real>(), bc_(bc), statObj_bc_(nullPtr),
226  augmentedObj_(false), activatedObj_(false),
227  augmentedCon_(false),
228  isLOinitialized_(false), isHIinitialized_(false) {
229  activatedObj_ = bc_->isActivated();
231  if (!activatedObj_) {
233  }
234  }
235 
236  void project( Vector<Real> &x ) {
237  if ( augmentedObj_ && activatedObj_ ) {
238  Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(0);
239  statObj_bc_->project(*xs);
240  }
241  if (augmentedCon_) {
242  int size = statCon_bc_.size();
243  for (int i = 0; i < size; ++i) {
244  if (activatedCon_[i]) {
245  Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(1,i);
246  statCon_bc_[i]->project(*xs);
247  }
248  }
249  }
250  if ( bc_ != nullPtr && bc_->isActivated() ) {
251  Ptr<Vector<Real>> xvec = dynamic_cast<RiskVector<Real>&>(x).getVector();
252  bc_->project(*xvec);
253  }
254  }
255 
257  if ( augmentedObj_ && activatedObj_ ) {
258  Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(0);
259  statObj_bc_->projectInterior(*xs);
260  }
261  if (augmentedCon_) {
262  int size = statCon_bc_.size();
263  for (int i = 0; i < size; ++i) {
264  if (activatedCon_[i]) {
265  Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(1,i);
266  statCon_bc_[i]->projectInterior(*xs);
267  }
268  }
269  }
270  if ( bc_ != nullPtr && bc_->isActivated() ) {
271  Ptr<Vector<Real>> xvec = dynamic_cast<RiskVector<Real>&>(x).getVector();
272  bc_->projectInterior(*xvec);
273  }
274  }
275 
276  void pruneUpperActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) {
277  if ( augmentedObj_ && activatedObj_ ) {
278  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
279  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
280  statObj_bc_->pruneUpperActive(*vs,*xs,eps);
281  }
282  if (augmentedCon_) {
283  int size = statCon_bc_.size();
284  for (int i = 0; i < size; ++i) {
285  if (activatedCon_[i]) {
286  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
287  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
288  statCon_bc_[i]->pruneUpperActive(*vs,*xs,eps);
289  }
290  }
291  }
292  if ( bc_ != nullPtr && bc_->isActivated() ) {
293  Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
294  Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
295  bc_->pruneUpperActive(*vv,*xv,eps);
296  }
297  }
298 
299  void pruneUpperActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) {
300  if ( augmentedObj_ && activatedObj_ ) {
301  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
302  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
303  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
304  statObj_bc_->pruneUpperActive(*vs,*gs,*xs,xeps,geps);
305  }
306  if (augmentedCon_) {
307  int size = statCon_bc_.size();
308  for (int i = 0; i < size; ++i) {
309  if (activatedCon_[i]) {
310  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
311  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
312  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
313  statCon_bc_[i]->pruneUpperActive(*vs,*gs,*xs,xeps,geps);
314  }
315  }
316  }
317  if ( bc_ != nullPtr && bc_->isActivated() ) {
318  Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
319  Ptr<const Vector<Real>> gv = dynamic_cast<const RiskVector<Real>&>(g).getVector();
320  Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
321  bc_->pruneUpperActive(*vv,*gv,*xv,xeps,geps);
322  }
323  }
324 
325  void pruneLowerActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) {
326  if ( augmentedObj_ && activatedObj_ ) {
327  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
328  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
329  statObj_bc_->pruneLowerActive(*vs,*xs,eps);
330  }
331  if (augmentedCon_) {
332  int size = statCon_bc_.size();
333  for (int i = 0; i < size; ++i) {
334  if (activatedCon_[i]) {
335  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
336  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
337  statCon_bc_[i]->pruneLowerActive(*vs,*xs,eps);
338  }
339  }
340  }
341  if ( bc_ != nullPtr && bc_->isActivated() ) {
342  Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
343  Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
344  bc_->pruneLowerActive(*vv,*xv,eps);
345  }
346  }
347 
348  void pruneLowerActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) {
349  if ( augmentedObj_ && activatedObj_ ) {
350  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
351  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
352  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
353  statObj_bc_->pruneLowerActive(*vs,*gs,*xs,xeps,geps);
354  }
355  if (augmentedCon_) {
356  int size = statCon_bc_.size();
357  for (int i = 0; i < size; ++i) {
358  if (activatedCon_[i]) {
359  Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
360  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
361  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
362  statCon_bc_[i]->pruneLowerActive(*vs,*gs,*xs,xeps,geps);
363  }
364  }
365  }
366  if ( bc_ != nullPtr && bc_->isActivated() ) {
367  Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
368  Ptr<const Vector<Real>> gv = dynamic_cast<const RiskVector<Real>&>(g).getVector();
369  Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
370  bc_->pruneLowerActive(*vv,*gv,*xv,xeps,geps);
371  }
372  }
373 
374  const Ptr<const Vector<Real>> getLowerBound(void) const {
375  if (!isLOinitialized_) {
376  const Ptr<const Vector<Real>> vlo = bc_->getLowerBound();
377  Ptr<std::vector<Real>> lowerObj = makePtr<std::vector<Real>>(lowerObj_);
378  int size = statCon_bc_.size();
379  std::vector<Ptr<std::vector<Real>>> lowerCon(size);
380  for (int i = 0; i < size; ++i) {
381  lowerCon[i] = makePtr<std::vector<Real>>(lowerCon_[i]);
382  }
383  lo_ = makePtr<RiskVector<Real>>(constPtrCast<Vector<Real>>(vlo),
384  lowerObj,lowerCon);
385  isLOinitialized_ = true;
386  }
387  return lo_;
388  }
389 
390  const Ptr<const Vector<Real>> getUpperBound(void) const {
391  if (!isHIinitialized_) {
392  const Ptr<const Vector<Real>> vhi = bc_->getUpperBound();
393  Ptr<std::vector<Real>> upperObj = makePtr<std::vector<Real>>(upperObj_);
394  int size = statCon_bc_.size();
395  std::vector<Ptr<std::vector<Real>>> upperCon(size);
396  for (int i = 0; i < size; ++i) {
397  upperCon[i] = makePtr<std::vector<Real>>(upperCon_[i]);
398  }
399  hi_ = makePtr<RiskVector<Real>>(constPtrCast<Vector<Real>>(vhi),
400  upperObj,upperCon);
401  isHIinitialized_ = true;
402  }
403  return hi_;
404  }
405 
406  bool isFeasible( const Vector<Real> &v ) {
407  bool flagstat = true, flagcon = true, flagvec = true;
408  if ( augmentedObj_ && activatedObj_ ) {
409  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
410  flagstat = statObj_bc_->isFeasible(*vs);
411  }
412  if (augmentedCon_) {
413  int size = statCon_bc_.size();
414  for (int i = 0; i < size; ++i) {
415  if (activatedCon_[i]) {
416  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
417  flagcon = (!statCon_bc_[i]->isFeasible(*vs) ? false : flagcon);
418  }
419  }
420  }
421  if ( bc_ != nullPtr && bc_->isActivated() ) {
422  Ptr<const Vector<Real>> vv = dynamic_cast<const RiskVector<Real>&>(v).getVector();
423  flagvec = bc_->isFeasible(*vv);
424  }
425  return (flagstat && flagcon && flagvec);
426  }
427 
428  void applyInverseScalingFunction(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const {
429  if ( augmentedObj_ && activatedObj_ ) {
430  Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(0);
431  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
432  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
433  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
434  statObj_bc_->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
435  }
436  if (augmentedCon_) {
437  int size = statCon_bc_.size();
438  for (int i = 0; i < size; ++i) {
439  if (activatedCon_[i]) {
440  Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(1,i);
441  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
442  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
443  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
444  statCon_bc_[i]->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
445  }
446  }
447  }
448  if ( bc_ != nullPtr && bc_->isActivated() ) {
449  Ptr<Vector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getVector();
450  Ptr<const Vector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getVector();
451  Ptr<const Vector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getVector();
452  Ptr<const Vector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getVector();
453  bc_->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
454  }
455  }
456 
457  void applyScalingFunctionJacobian(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const {
458  if ( augmentedObj_ && activatedObj_ ) {
459  Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(0);
460  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
461  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
462  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
463  statObj_bc_->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
464  }
465  if (augmentedCon_) {
466  int size = statCon_bc_.size();
467  for (int i = 0; i < size; ++i) {
468  if (activatedCon_[i]) {
469  Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(1,i);
470  Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
471  Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
472  Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
473  statCon_bc_[i]->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
474  }
475  }
476  }
477  if ( bc_ != nullPtr && bc_->isActivated() ) {
478  Ptr<Vector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getVector();
479  Ptr<const Vector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getVector();
480  Ptr<const Vector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getVector();
481  Ptr<const Vector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getVector();
482  bc_->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
483  }
484  }
485 
486 }; // class RiskBoundConstraint
487 
488 } // namespace ROL
489 
490 #endif
Contains definitions for std::vector bound constraints.
RiskBoundConstraint(const Ptr< BoundConstraint< Real >> &bc)
RiskBoundConstraint(Ptr< ParameterList > &parlistObj, std::vector< Ptr< ParameterList >> &parlistCon, const Ptr< BoundConstraint< Real >> &bc=nullPtr)
void activate(void)
Turn on bounds.
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.
Contains definitions of custom data types in ROL.
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
bool buildObjStatBnd(Ptr< ParameterList > &parlist)
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.
std::vector< std::vector< Real > > lowerCon_
Ptr< RiskVector< Real > > lo_
RiskBoundConstraint(std::vector< Ptr< ParameterList >> &parlist, const Ptr< BoundConstraint< Real >> &bc=nullPtr)
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 applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
void setBoundInfo(ParameterList &parlist, int &nStat, std::vector< Real > &lower, std::vector< Real > &upper, bool &augmented, bool &activated)
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.
RiskBoundConstraint(Ptr< ParameterList > &parlist, const Ptr< BoundConstraint< Real >> &bc=nullPtr)
const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
std::vector< std::vector< Real > > upperCon_
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
Ptr< StdBoundConstraint< Real > > statObj_bc_
Provides the interface to apply upper and lower bound constraints.
bool buildConStatBnd(std::vector< Ptr< ParameterList >> &parlist)
void projectInterior(Vector< Real > &x)
Project optimization variables into the interior of the feasible set.
void applyInverseScalingFunction(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply inverse scaling function.
void deactivate(void)
Turn off bounds.
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
Ptr< BoundConstraint< Real > > bc_
Ptr< RiskVector< Real > > hi_
std::vector< Ptr< StdBoundConstraint< Real > > > statCon_bc_