ROL
ROL_RiskVector.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_RISKVECTOR_HPP
45 #define ROL_RISKVECTOR_HPP
46 
47 #include "ROL_StdVector.hpp"
49 #include "ROL_ParameterList.hpp"
50 
51 namespace ROL {
52 
53 template<class Real>
54 class RiskVector : public Vector<Real> {
55 private:
56  ROL::Ptr<std::vector<Real> > statObj_;
57  ROL::Ptr<StdVector<Real> > statObj_vec_;
59  int nStatObj_;
60 
61  std::vector<ROL::Ptr<std::vector<Real> > > statCon_;
62  std::vector<ROL::Ptr<StdVector<Real> > > statCon_vec_;
64  std::vector<int> nStatCon_;
65 
66  ROL::Ptr<Vector<Real> > vec_;
67 
68  mutable bool isDualInitialized_;
69  mutable ROL::Ptr<std::vector<Real> > dualObj_;
70  mutable std::vector<ROL::Ptr<std::vector<Real> > > dualCon_;
71  mutable ROL::Ptr<Vector<Real> > dual_vec1_;
72  mutable ROL::Ptr<RiskVector<Real> > dual_vec_;
73 
74  void initializeObj(ROL::Ptr<ROL::ParameterList> &parlist,
75  const Real stat = 1) {
76  // Get risk measure information
77  if (parlist != ROL::nullPtr) {
78  std::string name;
79  std::vector<Real> lower, upper;
80  bool activated(false);
81  RandVarFunctionalInfo<Real>(*parlist,name,nStatObj_,lower,upper,activated);
82  augmentedObj_ = (nStatObj_ > 0) ? true : false;
83  // Initialize statistic vector
84  if (augmentedObj_) {
85  statObj_ = ROL::makePtr<std::vector<Real>>(nStatObj_,stat);
86  statObj_vec_ = ROL::makePtr<StdVector<Real>>(statObj_);
87  }
88  }
89  else {
90  augmentedObj_ = false;
91  nStatObj_ = 0;
92  }
93  }
94 
95  void initializeCon(std::vector<ROL::Ptr<ROL::ParameterList> > &parlist,
96  const Real stat = 1) {
97  int size = parlist.size();
98  statCon_.resize(size); statCon_vec_.resize(size); nStatCon_.resize(size);
99  for (int i = 0; i < size; ++i) {
100  if (parlist[i] != ROL::nullPtr) {
101  // Get risk measure information
102  std::string name;
103  std::vector<Real> lower, upper;
104  bool activated(false);
105  RandVarFunctionalInfo<Real>(*parlist[i],name,nStatCon_[i],lower,upper,activated);
106  augmentedCon_ = (nStatCon_[i] > 0) ? true : augmentedCon_;
107  // Initialize statistic vector
108  if (nStatCon_[i] > 0) {
109  statCon_[i] = ROL::makePtr<std::vector<Real>>(nStatCon_[i],stat);
110  statCon_vec_[i] = ROL::makePtr<StdVector<Real>>(statCon_[i]);
111  }
112  else {
113  statCon_[i] = ROL::nullPtr;
114  statCon_vec_[i] = ROL::nullPtr;
115  }
116  }
117  else {
118  statCon_[i] = ROL::nullPtr;
119  statCon_vec_[i] = ROL::nullPtr;
120  }
121  }
122  }
123 
124 public:
125 
126  // Objective risk only
127  RiskVector( ROL::Ptr<ROL::ParameterList> &parlist,
128  const ROL::Ptr<Vector<Real> > &vec,
129  const Real stat = 0 )
130  : statObj_(ROL::nullPtr), statObj_vec_(ROL::nullPtr),
131  augmentedObj_(false), nStatObj_(0),
132  augmentedCon_(false),
133  vec_(vec), isDualInitialized_(false) {
134  initializeObj(parlist,stat);
135  }
136 
137  // Inequality constraint risk only
138  RiskVector( std::vector<ROL::Ptr<ROL::ParameterList> > &parlist,
139  const ROL::Ptr<Vector<Real> > &vec,
140  const Real stat = 0 )
141  : statObj_(ROL::nullPtr), statObj_vec_(ROL::nullPtr),
142  augmentedObj_(false), nStatObj_(0),
143  augmentedCon_(false),
144  vec_(vec), isDualInitialized_(false) {
145  initializeCon(parlist,stat);
146  }
147 
148  // Objective and inequality constraint risk
149  RiskVector( ROL::Ptr<ROL::ParameterList> & parlistObj,
150  std::vector<ROL::Ptr<ROL::ParameterList> > &parlistCon,
151  const ROL::Ptr<Vector<Real> > &vec,
152  const Real stat = 0 )
153  : statObj_(ROL::nullPtr), statObj_vec_(ROL::nullPtr),
154  augmentedObj_(false), nStatObj_(0),
155  augmentedCon_(false),
156  vec_(vec), isDualInitialized_(false) {
157  initializeObj(parlistObj,stat);
158  initializeCon(parlistCon,stat);
159  }
160 
161  // Build from components
162  RiskVector( const ROL::Ptr<Vector<Real> > &vec,
163  const ROL::Ptr<std::vector<Real> > &statObj,
164  const std::vector<ROL::Ptr<std::vector<Real> > > &statCon )
165  : statObj_(ROL::nullPtr), statObj_vec_(ROL::nullPtr),
166  augmentedObj_(false), nStatObj_(0), augmentedCon_(false),
167  vec_(vec), isDualInitialized_(false) {
168  if (statObj != ROL::nullPtr) {
169  statObj_ = statObj;
170  statObj_vec_ = ROL::makePtr<StdVector<Real>>(statObj_);
171  augmentedObj_ = true;
172  nStatObj_ = statObj->size();
173  }
174  int size = statCon.size();
175  statCon_.clear(); statCon_vec_.clear(); nStatCon_.clear();
176  statCon_.resize(size,ROL::nullPtr);
177  statCon_vec_.resize(size,ROL::nullPtr);
178  nStatCon_.resize(size,0);
179  for (int i = 0; i < size; ++i) {
180  if (statCon[i] != ROL::nullPtr) {
181  statCon_[i] = statCon[i];
182  statCon_vec_[i] = ROL::makePtr<StdVector<Real>>(statCon_[i]);
183  augmentedCon_ = true;
184  nStatCon_[i] = statCon[i]->size();
185  }
186  }
187  }
188 
189  // Build from components -- Objective only...no statistic
190  RiskVector( const ROL::Ptr<Vector<Real> > &vec )
191  : statObj_(ROL::nullPtr), statObj_vec_(ROL::nullPtr),
192  augmentedObj_(false), nStatObj_(0), augmentedCon_(false),
193  vec_(vec), isDualInitialized_(false) {}
194 
195  void set( const Vector<Real> &x ) {
196  const RiskVector<Real> &xs = dynamic_cast<const RiskVector<Real>&>(x);
197  vec_->set(*(xs.getVector()));
198  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
199  statObj_vec_->set(*(xs.getStatisticVector(0)));
200  }
201  if (augmentedCon_) {
202  int size = statCon_vec_.size();
203  for (int i = 0; i < size; ++i) {
204  if (statCon_vec_[i] != ROL::nullPtr) {
205  statCon_vec_[i]->set(*(xs.getStatisticVector(1,i)));
206  }
207  }
208  }
209  }
210 
211  void plus( const Vector<Real> &x ) {
212  const RiskVector<Real> &xs = dynamic_cast<const RiskVector<Real>&>(x);
213  vec_->plus(*(xs.getVector()));
214  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
215  statObj_vec_->plus(*(xs.getStatisticVector(0)));
216  }
217  if (augmentedCon_) {
218  int size = statCon_vec_.size();
219  for (int i = 0; i < size; ++i) {
220  if (statCon_vec_[i] != ROL::nullPtr) {
221  statCon_vec_[i]->plus(*(xs.getStatisticVector(1,i)));
222  }
223  }
224  }
225  }
226 
227  void scale( const Real alpha ) {
228  vec_->scale(alpha);
229  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
230  statObj_vec_->scale(alpha);
231  }
232  if (augmentedCon_) {
233  int size = statCon_vec_.size();
234  for (int i = 0; i < size; ++i) {
235  if (statCon_vec_[i] != ROL::nullPtr) {
236  statCon_vec_[i]->scale(alpha);
237  }
238  }
239  }
240  }
241 
242  void axpy( const Real alpha, const Vector<Real> &x ) {
243  const RiskVector<Real> &xs = dynamic_cast<const RiskVector<Real>&>(x);
244  vec_->axpy(alpha,*(xs.getVector()));
245  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
246  statObj_vec_->axpy(alpha,*(xs.getStatisticVector(0)));
247  }
248  if (augmentedCon_) {
249  int size = statCon_vec_.size();
250  for (int i = 0; i < size; ++i) {
251  if (statCon_vec_[i] != ROL::nullPtr) {
252  statCon_vec_[i]->axpy(alpha,*(xs.getStatisticVector(1,i)));
253  }
254  }
255  }
256  }
257 
258  Real dot( const Vector<Real> &x ) const {
259  const RiskVector<Real> &xs = dynamic_cast<const RiskVector<Real>&>(x);
260  Real val = vec_->dot(*(xs.getVector()));
261  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
262  val += statObj_vec_->dot(*(xs.getStatisticVector(0)));
263  }
264  if (augmentedCon_) {
265  int size = statCon_vec_.size();
266  for (int i = 0; i < size; ++i) {
267  if (statCon_vec_[i] != ROL::nullPtr) {
268  val += statCon_vec_[i]->dot(*(xs.getStatisticVector(1,i)));
269  }
270  }
271  }
272  return val;
273  }
274 
275  Real norm(void) const {
276  return sqrt( dot(*this) );
277  }
278 
279  ROL::Ptr<Vector<Real> > clone(void) const {
280  ROL::Ptr<std::vector<Real> > e2 = ROL::nullPtr;
281  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
282  e2 = ROL::makePtr<std::vector<Real>>(nStatObj_,static_cast<Real>(0));
283  }
284  int size = statCon_vec_.size();
285  std::vector<ROL::Ptr<std::vector<Real> > > e3(size, ROL::nullPtr);
286  for (int j = 0; j < size; ++j) {
287  if (statCon_vec_[j] != ROL::nullPtr) {
288  e3[j] = ROL::makePtr<std::vector<Real>>(nStatCon_[j],static_cast<Real>(0));
289  }
290  }
291  return ROL::makePtr<RiskVector>(vec_->clone(),e2,e3);
292  }
293 
294  const Vector<Real> &dual(void) const {
295  // Initialize dual vectors if not already initialized
296  if ( !isDualInitialized_ ) {
297  dual_vec1_ = vec_->dual().clone();
298  dualObj_ = ROL::nullPtr;
299  if (statObj_ != ROL::nullPtr) {
300  dualObj_ = ROL::makePtr<std::vector<Real>>(statObj_->size());
301  }
302  int size = statCon_.size();
303  dualCon_.clear(); dualCon_.resize(size,ROL::nullPtr);
304  for (int i = 0; i < size; ++i) {
305  if (statCon_[i] != ROL::nullPtr) {
306  dualCon_[i] = ROL::makePtr<std::vector<Real>>(statCon_[i]->size());
307  }
308  }
309  dual_vec_ = ROL::makePtr<RiskVector<Real>>(dual_vec1_,dualObj_,dualCon_);
310  isDualInitialized_ = true;
311  }
312  // Set vector component
313  dual_vec1_->set(vec_->dual());
314  // Set statistic component
315  if ( augmentedObj_ && statObj_vec_ != ROL::nullPtr ) {
316  ROL::dynamicPtrCast<RiskVector<Real> >(dual_vec_)->setStatistic(*statObj_,0);
317  }
318  if ( augmentedCon_ ) {
319  int size = statCon_.size();
320  for (int i = 0; i < size; ++i) {
321  if (statCon_[i] != ROL::nullPtr) {
322  ROL::dynamicPtrCast<RiskVector<Real> >(dual_vec_)->setStatistic(*statCon_[i],1,i);
323  }
324  }
325  }
326  // Return dual vector
327  return *dual_vec_;
328  }
329 
330  ROL::Ptr<Vector<Real> > basis( const int i ) const {
331  ROL::Ptr<Vector<Real> > e1;
332  ROL::Ptr<std::vector<Real> > e2 = ROL::nullPtr;
333  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
334  e2 = ROL::makePtr<std::vector<Real>>(nStatObj_,static_cast<Real>(0));
335  }
336  int size = statCon_vec_.size();
337  std::vector<ROL::Ptr<std::vector<Real> > > e3(size);
338  for (int j = 0; j < size; ++j) {
339  if (statCon_vec_[j] != ROL::nullPtr) {
340  e3[j] = ROL::makePtr<std::vector<Real>>(nStatCon_[j],static_cast<Real>(0));
341  }
342  }
343  int n1 = vec_->dimension(), n2 = 0;
344  if (statObj_vec_ != ROL::nullPtr) {
345  n2 = statObj_vec_->dimension();
346  }
347  if ( i < n1 ) {
348  e1 = vec_->basis(i);
349  }
350  else if (i >= n1 && i < n1+n2) {
351  e1 = vec_->clone(); e1->zero();
352  (*e2)[i-n1] = static_cast<Real>(1);
353  }
354  else if (i >= n1+n2) {
355  e1 = vec_->clone(); e1->zero();
356  int sum = n1+n2, sum0 = sum;
357  for (int j = 0; j < size; ++j) {
358  if (statCon_vec_[j] != ROL::nullPtr) {
359  sum += nStatCon_[j];
360  if (i < sum) {
361  (*e3[j])[i-sum0] = static_cast<Real>(1);
362  break;
363  }
364  sum0 = sum;
365  }
366  }
367  if (i >= sum) {
368  throw Exception::NotImplemented(">>> ROL::RiskVector::Basis: index out of bounds!");
369  }
370  }
371  return ROL::makePtr<RiskVector<Real>>(e1,e2,e3);
372  }
373 
374  void applyUnary( const Elementwise::UnaryFunction<Real> &f ) {
375  vec_->applyUnary(f);
376  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
377  statObj_vec_->applyUnary(f);
378  }
379  if (augmentedCon_) {
380  int size = statCon_vec_.size();
381  for (int i = 0; i < size; ++i) {
382  if (statCon_vec_[i] != ROL::nullPtr) {
383  statCon_vec_[i]->applyUnary(f);
384  }
385  }
386  }
387  }
388 
389  void applyBinary( const Elementwise::BinaryFunction<Real> &f, const Vector<Real> &x ) {
390  const RiskVector<Real> &xs = dynamic_cast<const RiskVector<Real>&>(x);
391  vec_->applyBinary(f,*xs.getVector());
392  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
393  statObj_vec_->applyBinary(f,*xs.getStatisticVector(0));
394  }
395  if (augmentedCon_) {
396  int size = statCon_vec_.size();
397  for (int i = 0; i < size; ++i) {
398  if (statCon_vec_[i] != ROL::nullPtr) {
399  statCon_vec_[i]->applyBinary(f,*xs.getStatisticVector(1,i));
400  }
401  }
402  }
403  }
404 
405  Real reduce( const Elementwise::ReductionOp<Real> &r ) const {
406  Real result = r.initialValue();
407  r.reduce(vec_->reduce(r),result);
408  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
409  r.reduce(statObj_vec_->reduce(r),result);
410  }
411  if (augmentedCon_) {
412  int size = statCon_vec_.size();
413  for (int i = 0; i < size; ++i) {
414  if (statCon_vec_[i] != ROL::nullPtr) {
415  r.reduce(statCon_vec_[i]->reduce(r),result);
416  }
417  }
418  }
419  return result;
420  }
421 
422  void setScalar( const Real C ) {
423  vec_->setScalar(C);
424  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
425  statObj_vec_->setScalar(C);
426  }
427  if (augmentedCon_) {
428  int size = statCon_vec_.size();
429  for (int i = 0; i < size; ++i) {
430  if (statCon_vec_[i] != ROL::nullPtr) {
431  statCon_vec_[i]->setScalar(C);
432  }
433  }
434  }
435  }
436 
437  void randomize( const Real l=0.0, const Real u=1.0 ) {
438  vec_->randomize(l,u);
439  if (augmentedObj_ && statObj_vec_ != ROL::nullPtr) {
440  statObj_vec_->randomize(l,u);
441  }
442  if (augmentedCon_) {
443  int size = statCon_vec_.size();
444  for (int i = 0; i < size; ++i) {
445  if (statCon_vec_[i] != ROL::nullPtr) {
446  statCon_vec_[i]->randomize(l,u);
447  }
448  }
449  }
450  }
451 
452  int dimension(void) const {
453  int dim = vec_->dimension();
454  if (augmentedObj_) {
455  dim += statObj_vec_->dimension();
456  }
457  if (augmentedCon_) {
458  int size = statCon_vec_.size();
459  for (int i = 0; i < size; ++i) {
460  if (statCon_vec_[i] != ROL::nullPtr) {
461  dim += statCon_vec_[i]->dimension();
462  }
463  }
464  }
465  return dim;
466  }
467 
468  /***************************************************************************/
469  /************ ROL VECTOR ACCESSOR FUNCTIONS ********************************/
470  /***************************************************************************/
471  ROL::Ptr<const StdVector<Real>>
472  getStatisticVector(const int comp, const int index = 0) const {
473  if (comp == 0) {
474  return statObj_vec_;
475  }
476  else if (comp == 1) {
477  return statCon_vec_[index];
478  }
479  else {
480  throw Exception::NotImplemented(">>> ROL::RiskVector::getStatisticVector: Component must be 0 or 1!");
481  }
482  }
483 
484  ROL::Ptr<StdVector<Real>>
485  getStatisticVector(const int comp, const int index = 0) {
486  if (comp == 0) {
487  return statObj_vec_;
488  }
489  else if (comp == 1) {
490  return statCon_vec_[index];
491  }
492  else {
493  throw Exception::NotImplemented(">>> ROL::RiskVector::getStatistic: Component must be 0 or 1!");
494  }
495  }
496 
497  ROL::Ptr<const Vector<Real> > getVector(void) const {
498  return vec_;
499  }
500 
501  ROL::Ptr<Vector<Real> > getVector(void) {
502  return vec_;
503  }
504 
505  /***************************************************************************/
506  /************ COMPONENT ACCESSOR FUNCTIONS *********************************/
507  /***************************************************************************/
508  ROL::Ptr<std::vector<Real>>
509  getStatistic(const int comp = 0, const int index = 0) {
510  if (comp == 0) {
511  if (augmentedObj_) {
512  return statObj_;
513  }
514  }
515  else if (comp == 1) {
516  if (augmentedCon_) {
517  return statCon_[index];
518  }
519  }
520  else {
521  throw Exception::NotImplemented(">>> ROL::RiskVector::getStatistic: Component must be 0 or 1!");
522  }
523  return ROL::nullPtr;
524  }
525 
526  ROL::Ptr<const std::vector<Real>>
527  getStatistic(const int comp = 0, const int index = 0) const {
528  if (comp == 0) {
529  if (augmentedObj_) {
530  return statObj_;
531  }
532  }
533  else if (comp == 1) {
534  if (augmentedCon_) {
535  return statCon_[index];
536  }
537  }
538  else {
539  throw Exception::NotImplemented(">>> ROL::RiskVector::getStatistic: Component must be 0 or 1!");
540  }
541  return ROL::nullPtr;
542  }
543 
544  void setStatistic(const Real stat, const int comp = 0, const int index = 0) {
545  if ( comp == 0 ) {
546  if ( augmentedObj_ ) {
547  statObj_->assign(nStatObj_,stat);
548  }
549  }
550  else if ( comp == 1 ) {
551  if ( augmentedCon_ ) {
552  statCon_[index]->assign(nStatCon_[index],stat);
553  }
554  }
555  else {
556  throw Exception::NotImplemented(">>> ROL::RiskVector::setStatistic: Component must be 0 or 1!");
557  }
558  }
559 
560  void setStatistic(const std::vector<Real> &stat, const int comp = 0, const int index = 0) {
561  if ( comp == 0 ) {
562  if ( augmentedObj_ ) {
563  if ( nStatObj_ != static_cast<int>(stat.size()) ) {
564  throw Exception::NotImplemented(">>> ROL::RiskVector::setStatistic: Dimension mismatch!");
565  }
566  statObj_->assign(stat.begin(),stat.end());
567  }
568  }
569  else if ( comp == 1) {
570  if ( augmentedCon_ ) {
571  if ( nStatCon_[index] != static_cast<int>(stat.size()) ) {
572  throw Exception::NotImplemented(">>> ROL::RiskVector::setStatistic: Dimension mismatch!");
573  }
574  statCon_[index]->assign(stat.begin(),stat.end());
575  }
576  }
577  else {
578  throw Exception::NotImplemented(">>> ROL::RiskVector::setStatistic: Component must be 0 or 1!");
579  }
580  }
581 
582  void setVector(const Vector<Real>& vec) {
583  vec_->set(vec);
584  }
585 };
586 
587 }
588 
589 #endif
ROL::Ptr< std::vector< Real > > dualObj_
ROL::Ptr< std::vector< Real > > getStatistic(const int comp=0, const int index=0)
RiskVector(ROL::Ptr< ROL::ParameterList > &parlist, const ROL::Ptr< Vector< Real > > &vec, const Real stat=0)
void set(const Vector< Real > &x)
Set where .
std::vector< int > nStatCon_
std::vector< ROL::Ptr< std::vector< Real > > > dualCon_
void scale(const Real alpha)
Compute where .
ROL::Ptr< const Vector< Real > > getVector(void) const
RiskVector(std::vector< ROL::Ptr< ROL::ParameterList > > &parlist, const ROL::Ptr< Vector< Real > > &vec, const Real stat=0)
void setStatistic(const std::vector< Real > &stat, const int comp=0, const int index=0)
ROL::Ptr< Vector< Real > > dual_vec1_
void setScalar(const Real C)
Set where .
const Vector< Real > & dual(void) const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
ROL::Ptr< StdVector< Real > > getStatisticVector(const int comp, const int index=0)
RiskVector(ROL::Ptr< ROL::ParameterList > &parlistObj, std::vector< ROL::Ptr< ROL::ParameterList > > &parlistCon, const ROL::Ptr< Vector< Real > > &vec, const Real stat=0)
void axpy(const Real alpha, const Vector< Real > &x)
Compute where .
ROL::Ptr< Vector< Real > > clone(void) const
Clone to make a new (uninitialized) vector.
void setStatistic(const Real stat, const int comp=0, const int index=0)
Defines the linear algebra or vector space interface.
Definition: ROL_Vector.hpp:80
void setVector(const Vector< Real > &vec)
void plus(const Vector< Real > &x)
Compute , where .
ROL::Ptr< std::vector< Real > > statObj_
RiskVector(const ROL::Ptr< Vector< Real > > &vec, const ROL::Ptr< std::vector< Real > > &statObj, const std::vector< ROL::Ptr< std::vector< Real > > > &statCon)
void initializeCon(std::vector< ROL::Ptr< ROL::ParameterList > > &parlist, const Real stat=1)
std::vector< ROL::Ptr< StdVector< Real > > > statCon_vec_
int dimension(void) const
Return dimension of the vector space.
void randomize(const Real l=0.0, const Real u=1.0)
Set vector to be uniform random between [l,u].
void applyBinary(const Elementwise::BinaryFunction< Real > &f, const Vector< Real > &x)
ROL::Ptr< Vector< Real > > getVector(void)
ROL::Ptr< RiskVector< Real > > dual_vec_
void applyUnary(const Elementwise::UnaryFunction< Real > &f)
ROL::Ptr< const std::vector< Real > > getStatistic(const int comp=0, const int index=0) const
ROL::Ptr< const StdVector< Real > > getStatisticVector(const int comp, const int index=0) const
ROL::Ptr< Vector< Real > > basis(const int i) const
Return i-th basis vector.
Real norm(void) const
Returns where .
RiskVector(const ROL::Ptr< Vector< Real > > &vec)
ROL::Ptr< StdVector< Real > > statObj_vec_
Real reduce(const Elementwise::ReductionOp< Real > &r) const
Real dot(const Vector< Real > &x) const
Compute where .
void initializeObj(ROL::Ptr< ROL::ParameterList > &parlist, const Real stat=1)
ROL::Ptr< Vector< Real > > vec_
std::vector< ROL::Ptr< std::vector< Real > > > statCon_
constexpr auto dim