ROL
ROL_DeviationMeasureFactory.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_DEVIATIONMEASUREFACTORY_HPP
11 #define ROL_DEVIATIONMEASUREFACTORY_HPP
12 
13 #include "ROL_ParameterList.hpp"
14 
15 #include "ROL_Types.hpp"
16 
17 // Risk Quadrangle Implementations
20 #include "ROL_MoreauYosidaCVaR.hpp"
27 
28 namespace ROL {
29 
40  };
41 
43  std::string retString;
44  switch(ed) {
46  retString = "Variance"; break;
48  retString = "Truncated Mean"; break;
50  retString = "CVaR"; break;
52  retString = "Moreau-Yosida CVaR"; break;
54  retString = "Generalized Moreau-Yosida CVaR"; break;
56  retString = "Entropic"; break;
58  retString = "Log Quantile"; break;
60  retString = "Smoothed Upper Range"; break;
62  retString = "Last Type (Dummy)"; break;
63  default:
64  retString = "INVALID EDeviationMeasure"; break;
65  }
66  return retString;
67  }
68 
78  }
79 
81  return type = static_cast<EDeviationMeasure>(type+1);
82  }
83 
85  EDeviationMeasure oldval = type;
86  ++type;
87  return oldval;
88  }
89 
91  return type = static_cast<EDeviationMeasure>(type-1);
92  }
93 
95  EDeviationMeasure oldval = type;
96  --type;
97  return oldval;
98  }
99 
101  s = removeStringFormat(s);
103  if ( !s.compare(removeStringFormat(EDeviationMeasureToString(tr))) ) {
104  return tr;
105  }
106  }
107  return DEVIATIONMEASURE_LAST;
108  }
109 
110  template<class Real>
111  inline Ptr<RandVarFunctional<Real>> DeviationMeasureFactory(ParameterList &parlist) {
112  std::string deviation = parlist.sublist("SOL").sublist("Deviation Measure").get("Name","Variance");
114  switch(ed) {
116  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<MeanVarianceQuadrangle<Real>>(parlist));
118  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<TruncatedMeanQuadrangle<Real>>(parlist));
120  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<QuantileQuadrangle<Real>>(parlist));
122  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<MoreauYosidaCVaR<Real>>(parlist));
124  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<GenMoreauYosidaCVaR<Real>>(parlist));
126  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<LogExponentialQuadrangle<Real>>(parlist));
128  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<LogQuantileQuadrangle<Real>>(parlist));
130  return makePtr<ExpectationQuadDeviation<Real>>(makePtr<SmoothedWorstCaseQuadrangle<Real>>(parlist));
131  default:
132  ROL_TEST_FOR_EXCEPTION(true,std::invalid_argument,
133  "Invalid deviation measure type " << deviation << "!");
134  }
135  }
136 }
137 #endif
EPolyProjAlgo & operator++(EPolyProjAlgo &type)
Contains definitions of custom data types in ROL.
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:215
EPolyProjAlgo & operator--(EPolyProjAlgo &type)
std::string EDeviationMeasureToString(EDeviationMeasure ed)
int isValidDeviationMeasure(EDeviationMeasure ed)
Ptr< RandVarFunctional< Real > > DeviationMeasureFactory(ParameterList &parlist)
EDeviationMeasure StringToEDeviationMeasure(std::string s)