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
51namespace ROL {
52
53template <class Real>
55private:
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
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
168public:
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
235
236 void update( const Vector<Real> &x, bool flag = true, int iter = -1 ) {
237 if ( augmentedObj_ && activatedObj_ ) {
238 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
239 statObj_bc_->update(*xs,flag,iter);
240 }
241 if (augmentedCon_) {
242 int size = statCon_bc_.size();
243 for (int i = 0; i < size; ++i) {
244 if (activatedCon_[i]) {
245 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
246 statCon_bc_[i]->update(*xs,flag,iter);
247 }
248 }
249 }
250 if ( bc_ != nullPtr && bc_->isActivated() ) {
251 Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
252 bc_->update(*xv,flag,iter);
253 }
254 }
255
257 if ( augmentedObj_ && activatedObj_ ) {
258 Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(0);
259 statObj_bc_->project(*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]->project(*xs);
267 }
268 }
269 }
270 if ( bc_ != nullPtr && bc_->isActivated() ) {
271 Ptr<Vector<Real>> xvec = dynamic_cast<RiskVector<Real>&>(x).getVector();
272 bc_->project(*xvec);
273 }
274 }
275
277 if ( augmentedObj_ && activatedObj_ ) {
278 Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(0);
279 statObj_bc_->projectInterior(*xs);
280 }
281 if (augmentedCon_) {
282 int size = statCon_bc_.size();
283 for (int i = 0; i < size; ++i) {
284 if (activatedCon_[i]) {
285 Ptr<StdVector<Real>> xs = dynamic_cast<RiskVector<Real>&>(x).getStatisticVector(1,i);
286 statCon_bc_[i]->projectInterior(*xs);
287 }
288 }
289 }
290 if ( bc_ != nullPtr && bc_->isActivated() ) {
291 Ptr<Vector<Real>> xvec = dynamic_cast<RiskVector<Real>&>(x).getVector();
292 bc_->projectInterior(*xvec);
293 }
294 }
295
296 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) {
297 if ( augmentedObj_ && activatedObj_ ) {
298 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
299 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
300 statObj_bc_->pruneUpperActive(*vs,*xs,eps);
301 }
302 if (augmentedCon_) {
303 int size = statCon_bc_.size();
304 for (int i = 0; i < size; ++i) {
305 if (activatedCon_[i]) {
306 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
307 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
308 statCon_bc_[i]->pruneUpperActive(*vs,*xs,eps);
309 }
310 }
311 }
312 if ( bc_ != nullPtr && bc_->isActivated() ) {
313 Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
314 Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
315 bc_->pruneUpperActive(*vv,*xv,eps);
316 }
317 }
318
319 void pruneUpperActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) {
320 if ( augmentedObj_ && activatedObj_ ) {
321 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
322 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
323 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
324 statObj_bc_->pruneUpperActive(*vs,*gs,*xs,xeps,geps);
325 }
326 if (augmentedCon_) {
327 int size = statCon_bc_.size();
328 for (int i = 0; i < size; ++i) {
329 if (activatedCon_[i]) {
330 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
331 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
332 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
333 statCon_bc_[i]->pruneUpperActive(*vs,*gs,*xs,xeps,geps);
334 }
335 }
336 }
337 if ( bc_ != nullPtr && bc_->isActivated() ) {
338 Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
339 Ptr<const Vector<Real>> gv = dynamic_cast<const RiskVector<Real>&>(g).getVector();
340 Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
341 bc_->pruneUpperActive(*vv,*gv,*xv,xeps,geps);
342 }
343 }
344
345 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &x, Real eps = Real(0) ) {
346 if ( augmentedObj_ && activatedObj_ ) {
347 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
348 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
349 statObj_bc_->pruneLowerActive(*vs,*xs,eps);
350 }
351 if (augmentedCon_) {
352 int size = statCon_bc_.size();
353 for (int i = 0; i < size; ++i) {
354 if (activatedCon_[i]) {
355 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
356 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
357 statCon_bc_[i]->pruneLowerActive(*vs,*xs,eps);
358 }
359 }
360 }
361 if ( bc_ != nullPtr && bc_->isActivated() ) {
362 Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
363 Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
364 bc_->pruneLowerActive(*vv,*xv,eps);
365 }
366 }
367
368 void pruneLowerActive( Vector<Real> &v, const Vector<Real> &g, const Vector<Real> &x, Real xeps = Real(0), Real geps = Real(0) ) {
369 if ( augmentedObj_ && activatedObj_ ) {
370 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(0);
371 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
372 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
373 statObj_bc_->pruneLowerActive(*vs,*gs,*xs,xeps,geps);
374 }
375 if (augmentedCon_) {
376 int size = statCon_bc_.size();
377 for (int i = 0; i < size; ++i) {
378 if (activatedCon_[i]) {
379 Ptr<StdVector<Real>> vs = dynamic_cast<RiskVector<Real>&>(v).getStatisticVector(1,i);
380 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
381 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
382 statCon_bc_[i]->pruneLowerActive(*vs,*gs,*xs,xeps,geps);
383 }
384 }
385 }
386 if ( bc_ != nullPtr && bc_->isActivated() ) {
387 Ptr<Vector<Real>> vv = dynamic_cast<RiskVector<Real>&>(v).getVector();
388 Ptr<const Vector<Real>> gv = dynamic_cast<const RiskVector<Real>&>(g).getVector();
389 Ptr<const Vector<Real>> xv = dynamic_cast<const RiskVector<Real>&>(x).getVector();
390 bc_->pruneLowerActive(*vv,*gv,*xv,xeps,geps);
391 }
392 }
393
394 const Ptr<const Vector<Real>> getLowerBound(void) const {
395 if (!isLOinitialized_) {
396 const Ptr<const Vector<Real>> vlo = bc_->getLowerBound();
397 Ptr<std::vector<Real>> lowerObj = makePtr<std::vector<Real>>(lowerObj_);
398 int size = statCon_bc_.size();
399 std::vector<Ptr<std::vector<Real>>> lowerCon(size);
400 for (int i = 0; i < size; ++i) {
401 lowerCon[i] = makePtr<std::vector<Real>>(lowerCon_[i]);
402 }
403 lo_ = makePtr<RiskVector<Real>>(constPtrCast<Vector<Real>>(vlo),
404 lowerObj,lowerCon);
405 isLOinitialized_ = true;
406 }
407 return lo_;
408 }
409
410 const Ptr<const Vector<Real>> getUpperBound(void) const {
411 if (!isHIinitialized_) {
412 const Ptr<const Vector<Real>> vhi = bc_->getUpperBound();
413 Ptr<std::vector<Real>> upperObj = makePtr<std::vector<Real>>(upperObj_);
414 int size = statCon_bc_.size();
415 std::vector<Ptr<std::vector<Real>>> upperCon(size);
416 for (int i = 0; i < size; ++i) {
417 upperCon[i] = makePtr<std::vector<Real>>(upperCon_[i]);
418 }
419 hi_ = makePtr<RiskVector<Real>>(constPtrCast<Vector<Real>>(vhi),
420 upperObj,upperCon);
421 isHIinitialized_ = true;
422 }
423 return hi_;
424 }
425
426 bool isFeasible( const Vector<Real> &v ) {
427 bool flagstat = true, flagcon = true, flagvec = true;
428 if ( augmentedObj_ && activatedObj_ ) {
429 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
430 flagstat = statObj_bc_->isFeasible(*vs);
431 }
432 if (augmentedCon_) {
433 int size = statCon_bc_.size();
434 for (int i = 0; i < size; ++i) {
435 if (activatedCon_[i]) {
436 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
437 flagcon = (!statCon_bc_[i]->isFeasible(*vs) ? false : flagcon);
438 }
439 }
440 }
441 if ( bc_ != nullPtr && bc_->isActivated() ) {
442 Ptr<const Vector<Real>> vv = dynamic_cast<const RiskVector<Real>&>(v).getVector();
443 flagvec = bc_->isFeasible(*vv);
444 }
445 return (flagstat && flagcon && flagvec);
446 }
447
448 void applyInverseScalingFunction(Vector<Real> &dv, const Vector<Real> &v, const Vector<Real> &x, const Vector<Real> &g) const {
449 if ( augmentedObj_ && activatedObj_ ) {
450 Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(0);
451 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
452 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
453 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
454 statObj_bc_->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
455 }
456 if (augmentedCon_) {
457 int size = statCon_bc_.size();
458 for (int i = 0; i < size; ++i) {
459 if (activatedCon_[i]) {
460 Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(1,i);
461 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
462 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
463 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
464 statCon_bc_[i]->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
465 }
466 }
467 }
468 if ( bc_ != nullPtr && bc_->isActivated() ) {
469 Ptr<Vector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getVector();
470 Ptr<const Vector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getVector();
471 Ptr<const Vector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getVector();
472 Ptr<const Vector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getVector();
473 bc_->applyInverseScalingFunction(*dvs,*vs,*xs,*gs);
474 }
475 }
476
478 if ( augmentedObj_ && activatedObj_ ) {
479 Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(0);
480 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(0);
481 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(0);
482 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(0);
483 statObj_bc_->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
484 }
485 if (augmentedCon_) {
486 int size = statCon_bc_.size();
487 for (int i = 0; i < size; ++i) {
488 if (activatedCon_[i]) {
489 Ptr<StdVector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getStatisticVector(1,i);
490 Ptr<const StdVector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getStatisticVector(1,i);
491 Ptr<const StdVector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getStatisticVector(1,i);
492 Ptr<const StdVector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getStatisticVector(1,i);
493 statCon_bc_[i]->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
494 }
495 }
496 }
497 if ( bc_ != nullPtr && bc_->isActivated() ) {
498 Ptr<Vector<Real>> dvs = dynamic_cast<RiskVector<Real>&>(dv).getVector();
499 Ptr<const Vector<Real>> vs = dynamic_cast<const RiskVector<Real>&>(v).getVector();
500 Ptr<const Vector<Real>> xs = dynamic_cast<const RiskVector<Real>&>(x).getVector();
501 Ptr<const Vector<Real>> gs = dynamic_cast<const RiskVector<Real>&>(g).getVector();
502 bc_->applyScalingFunctionJacobian(*dvs,*vs,*xs,*gs);
503 }
504 }
505
506}; // class RiskBoundConstraint
507
508} // namespace ROL
509
510#endif
Contains definitions for std::vector bound constraints.
Contains definitions of custom data types in ROL.
Provides the interface to apply upper and lower bound constraints.
bool isActivated(void) const
Check if bounds are on.
void deactivate(void)
Turn off bounds.
void activate(void)
Turn on bounds.
RiskBoundConstraint(const Ptr< BoundConstraint< Real > > &bc)
bool isFeasible(const Vector< Real > &v)
Check if the vector, v, is feasible.
const Ptr< const Vector< Real > > getLowerBound(void) const
Return the ref count pointer to the lower bound vector.
void setBoundInfo(ParameterList &parlist, int &nStat, std::vector< Real > &lower, std::vector< Real > &upper, bool &augmented, bool &activated)
Ptr< RiskVector< Real > > hi_
std::vector< std::vector< Real > > upperCon_
RiskBoundConstraint(std::vector< Ptr< ParameterList > > &parlist, const Ptr< BoundConstraint< Real > > &bc=nullPtr)
std::vector< std::vector< Real > > lowerCon_
RiskBoundConstraint(Ptr< ParameterList > &parlist, const Ptr< BoundConstraint< Real > > &bc=nullPtr)
void project(Vector< Real > &x)
Project optimization variables onto the bounds.
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.
std::vector< Ptr< StdBoundConstraint< Real > > > statCon_bc_
const Ptr< const Vector< Real > > getUpperBound(void) const
Return the ref count pointer to the upper bound vector.
bool buildObjStatBnd(Ptr< ParameterList > &parlist)
Ptr< StdBoundConstraint< Real > > statObj_bc_
bool buildConStatBnd(std::vector< 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.
Ptr< BoundConstraint< Real > > bc_
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 > &parlistObj, std::vector< Ptr< ParameterList > > &parlistCon, const Ptr< BoundConstraint< Real > > &bc=nullPtr)
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.
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 update(const Vector< Real > &x, bool flag=true, int iter=-1)
void applyScalingFunctionJacobian(Vector< Real > &dv, const Vector< Real > &v, const Vector< Real > &x, const Vector< Real > &g) const
Apply scaling function Jacobian.
Ptr< RiskVector< Real > > lo_
Defines the linear algebra or vector space interface.