ROL
ROL_RandVarFunctionalInfo.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Rapid Optimization Library (ROL) Package
4//
5// Copyright 2014 NTESS and the ROL contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
10#ifndef ROL_RANDVARFUNCTIONALINFO_HPP
11#define ROL_RANDVARFUNCTIONALINFO_HPP
12
18
19namespace ROL {
20
21template<class Real>
22inline void RandVarFunctionalInfo(ROL::ParameterList &parlist, std::string &name,
23 int &nStatistic, std::vector<Real> &lower,
24 std::vector<Real> &upper, bool &isBoundActivated,
25 const bool printToStream = false,
26 std::ostream &outStream = std::cout) {
27 std::string type = parlist.sublist("SOL").get("Type","Risk Averse");
28 if (type == "Risk Averse") {
29 RiskMeasureInfo<Real>(parlist,name,nStatistic,lower,upper,isBoundActivated,printToStream,outStream);
30 }
31 else if (type == "Deviation") {
32 DeviationMeasureInfo<Real>(parlist,name,nStatistic,lower,upper,isBoundActivated,printToStream,outStream);
33 }
34 else if (type == "Error") {
35 ErrorMeasureInfo<Real>(parlist,name,nStatistic,lower,upper,isBoundActivated,printToStream,outStream);
36 }
37 else if (type == "Regret") {
38 RegretMeasureInfo<Real>(parlist,name,nStatistic,lower,upper,isBoundActivated,printToStream,outStream);
39 }
40 else if (type == "Probability") {
41 ProbabilityInfo<Real>(parlist,name,nStatistic,lower,upper,isBoundActivated,printToStream,outStream);
42 }
43 else {
44 ROL_TEST_FOR_EXCEPTION(true,std::invalid_argument,
45 ">>> (ROL::RandVarFunctionalInfo): Invalid random variable functional type!");
46 }
47
48 // Print Information
49 if ( printToStream ) {
50 ROL::nullstream oldFormatState;
51 oldFormatState.copyfmt(outStream);
52
53 outStream << std::endl;
54 outStream << std::scientific << std::setprecision(6);
55 outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
56 outStream << " RANDVARFUNCTIONAL INFORMATION" << std::endl;
57 outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
58 outStream << " NAME" << std::endl;
59 outStream << " " << name << std::endl;
60 outStream << " NUMBER OF STATISTICS" << std::endl;
61 outStream << " " << nStatistic << std::endl;
62 outStream << " ARE BOUNDS ACTIVATED" << std::endl;
63 outStream << " " << (isBoundActivated ? "TRUE" : "FALSE") << std::endl;
64 if ( isBoundActivated ) {
65 outStream << " STATISTIC LOWER BOUNDS" << std::endl;
66 for (int i = 0; i < nStatistic-1; ++i) {
67 outStream << " " << lower[i] << std::endl;
68 }
69 outStream << " " << lower[nStatistic-1] << std::endl;
70 outStream << " STATISTIC UPPER BOUNDS" << std::endl;
71 for (int i = 0; i < nStatistic-1; ++i) {
72 outStream << " " << upper[i] << std::endl;
73 }
74 outStream << " " << upper[nStatistic-1] << std::endl;
75 }
76 outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
77 outStream << std::endl;
78
79 outStream.copyfmt(oldFormatState);
80 }
81}
82
83}
84#endif
void RandVarFunctionalInfo(ROL::ParameterList &parlist, std::string &name, int &nStatistic, std::vector< Real > &lower, std::vector< Real > &upper, bool &isBoundActivated, const bool printToStream=false, std::ostream &outStream=std::cout)