ROL
ROL_RegretMeasureInfo.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_REGRETINFO_HPP
11 #define ROL_REGRETINFO_HPP
12 
13 #include "ROL_ParameterList.hpp"
14 #include "ROL_Types.hpp"
15 
16 namespace ROL {
17 
18 template<class Real>
19 inline void RegretMeasureInfo(ROL::ParameterList &parlist, std::string &name,
20  int &nStatistic, std::vector<Real> &lower,
21  std::vector<Real> &upper, bool &isBoundActivated,
22  const bool printToStream = false,
23  std::ostream &outStream = std::cout) {
24  name = parlist.sublist("SOL").sublist("Regret Measure").get<std::string>("Name");
25  lower.clear(); upper.clear();
26  nStatistic = 0; isBoundActivated = false;
27  if ( name == "Mean Absolute Loss" ||
28  name == "Moreau-Yosida Mean Absolute Loss" ||
29  name == "Generalized Moreau-Yosida Mean Absolute Loss" ||
30  name == "Exponential" ||
31  name == "Mean L2" ||
32  name == "Truncated Mean" ||
33  name == "Log Quantile" ||
34  name == "Smoothed Worst Case" ) {
35  nStatistic = 0;
36  }
37  else {
38  ROL_TEST_FOR_EXCEPTION(true,std::invalid_argument,
39  ">>> (ROL::RegretMeasureInfo): Invalid probability " << name << "!");
40  }
41 
42  // Print Information
43  if ( printToStream ) {
44  ROL::nullstream oldFormatState;
45  oldFormatState.copyfmt(outStream);
46 
47  outStream << std::endl;
48  outStream << std::scientific << std::setprecision(6);
49  outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
50  outStream << " REGRET INFORMATION" << std::endl;
51  outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
52  outStream << " NAME" << std::endl;
53  outStream << " " << name << std::endl;
54  outStream << " NUMBER OF STATISTICS" << std::endl;
55  outStream << " " << nStatistic << std::endl;
56  outStream << " ARE BOUNDS ACTIVATED" << std::endl;
57  outStream << " " << (isBoundActivated ? "TRUE" : "FALSE") << std::endl;
58  if ( isBoundActivated ) {
59  outStream << " STATISTIC LOWER BOUNDS" << std::endl;
60  for (int i = 0; i < nStatistic-1; ++i) {
61  outStream << " " << lower[i] << std::endl;
62  }
63  outStream << " " << lower[nStatistic-1] << std::endl;
64  outStream << " STATISTIC UPPER BOUNDS" << std::endl;
65  for (int i = 0; i < nStatistic-1; ++i) {
66  outStream << " " << upper[i] << std::endl;
67  }
68  outStream << " " << upper[nStatistic-1] << std::endl;
69  }
70  outStream << std::setfill('-') << std::setw(80) << "-" << std::endl;
71  outStream << std::endl;
72 
73  outStream.copyfmt(oldFormatState);
74  }
75 }
76 
77 }
78 #endif
Contains definitions of custom data types in ROL.
basic_nullstream< char, std::char_traits< char >> nullstream
Definition: ROL_Stream.hpp:36
void RegretMeasureInfo(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)