ROL
ROL_RiskMeasureFactory.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_RISKMEASUREFACTORY_HPP
45 #define ROL_RISKMEASUREFACTORY_HPP
46 
47 #include "Teuchos_ParameterList.hpp"
48 
49 #include "ROL_Types.hpp"
50 
51 // Standard Risk Measure Implementations
52 #include "ROL_CVaR.hpp"
54 #include "ROL_ExpUtility.hpp"
55 #include "ROL_HMCR.hpp"
57 #include "ROL_MeanDeviation.hpp"
59 #include "ROL_MeanVariance.hpp"
60 #include "ROL_MoreauYosidaCVaR.hpp"
61 
62 // Risk Quadrangle Risk Measure Implementations
68 #include "ROL_ChebyshevKusuoka.hpp"
69 #include "ROL_SpectralRisk.hpp"
74 
75 // F-Divergence Distributionally Robust Risk Measure Implementations
76 #include "ROL_Chi2Divergence.hpp"
77 #include "ROL_KLDivergence.hpp"
78 
79 namespace ROL {
80 
81  enum ERiskMeasure {
105  };
106 
107  inline std::string ERiskMeasureToString(ERiskMeasure ed) {
108  std::string retString;
109  switch(ed) {
110  case RISKMEASURE_CVAR:
111  retString = "CVaR"; break;
113  retString = "Coherent Exponential Utility"; break;
115  retString = "Exponential Utility"; break;
116  case RISKMEASURE_HMCR:
117  retString = "HMCR"; break;
119  retString = "Mean Plus Deviation From Target"; break;
121  retString = "Mean Plus Deviation"; break;
123  retString = "Mean Plus Variance From Target"; break;
125  retString = "Mean Plus Variance"; break;
127  retString = "Moreau-Yosida CVaR"; break;
129  retString = "Log-Exponential Quadrangle"; break;
131  retString = "Log-Quantile Quadrangle"; break;
133  retString = "Mean-Variance Quadrangle"; break;
135  retString = "Mixed-Quantile Quadrangle"; break;
137  retString = "Super Quantile Quadrangle"; break;
139  retString = "Chebyshev-Kusuoka"; break;
141  retString = "Spectral Risk"; break;
143  retString = "Quantile-Based Quadrangle"; break;
145  retString = "Quantile-Radius Quadrangle"; break;
147  retString = "Smoothed Worst-Case Quadrangle"; break;
149  retString = "Truncated Mean Quadrangle"; break;
151  retString = "Chi-Squared Divergence"; break;
153  retString = "KL Divergence"; break;
154  case RISKMEASURE_LAST:
155  retString = "Last Type (Dummy)"; break;
156  default:
157  retString = "INVALID ERiskMeasure"; break;
158  }
159  return retString;
160  }
161 
163  return( (ed == RISKMEASURE_CVAR) ||
165  (ed == RISKMEASURE_EXPUTILITY) ||
166  (ed == RISKMEASURE_HMCR) ||
168  (ed == RISKMEASURE_MEANDEVIATION) ||
170  (ed == RISKMEASURE_MEANVARIANCE) ||
178  (ed == RISKMEASURE_SPECTRALRISK) ||
183  (ed == RISKMEASURE_CHI2DIVERGENCE) ||
184  (ed == RISKMEASURE_KLDIVERGENCE) );
185  }
186 
188  return type = static_cast<ERiskMeasure>(type+1);
189  }
190 
191  inline ERiskMeasure operator++(ERiskMeasure &type, int) {
192  ERiskMeasure oldval = type;
193  ++type;
194  return oldval;
195  }
196 
198  return type = static_cast<ERiskMeasure>(type-1);
199  }
200 
201  inline ERiskMeasure operator--(ERiskMeasure &type, int) {
202  ERiskMeasure oldval = type;
203  --type;
204  return oldval;
205  }
206 
207  inline ERiskMeasure StringToERiskMeasure(std::string s) {
208  s = removeStringFormat(s);
209  for ( ERiskMeasure tr = RISKMEASURE_CVAR; tr < RISKMEASURE_LAST; tr++ ) {
210  if ( !s.compare(removeStringFormat(ERiskMeasureToString(tr))) ) {
211  return tr;
212  }
213  }
214  return RISKMEASURE_LAST;
215  }
216 
217  template<class Real>
218  inline Teuchos::RCP<RiskMeasure<Real> > RiskMeasureFactory(Teuchos::ParameterList &parlist) {
219  std::string risk = parlist.sublist("SOL").sublist("Risk Measure").get("Name","CVaR");
221  switch(ed) {
222  case RISKMEASURE_CVAR:
223  return Teuchos::rcp(new CVaR<Real>(parlist));
225  return Teuchos::rcp(new CoherentExpUtility<Real>());
227  return Teuchos::rcp(new ExpUtility<Real>(parlist));
228  case RISKMEASURE_HMCR:
229  return Teuchos::rcp(new HMCR<Real>(parlist));
231  return Teuchos::rcp(new MeanDeviationFromTarget<Real>(parlist));
233  return Teuchos::rcp(new MeanDeviation<Real>(parlist));
235  return Teuchos::rcp(new MeanVarianceFromTarget<Real>(parlist));
237  return Teuchos::rcp(new MeanVariance<Real>(parlist));
239  return Teuchos::rcp(new MoreauYosidaCVaR<Real>(parlist));
241  return Teuchos::rcp(new LogExponentialQuadrangle<Real>(parlist));
243  return Teuchos::rcp(new LogQuantileQuadrangle<Real>(parlist));
245  return Teuchos::rcp(new MeanVarianceQuadrangle<Real>(parlist));
247  return Teuchos::rcp(new MixedQuantileQuadrangle<Real>(parlist));
249  return Teuchos::rcp(new SuperQuantileQuadrangle<Real>(parlist));
251  return Teuchos::rcp(new ChebyshevKusuoka<Real>(parlist));
253  return Teuchos::rcp(new SpectralRisk<Real>(parlist));
255  return Teuchos::rcp(new QuantileQuadrangle<Real>(parlist));
257  return Teuchos::rcp(new QuantileRadiusQuadrangle<Real>(parlist));
259  return Teuchos::rcp(new SmoothedWorstCaseQuadrangle<Real>(parlist));
261  return Teuchos::rcp(new TruncatedMeanQuadrangle<Real>(parlist));
263  return Teuchos::rcp(new Chi2Divergence<Real>(parlist));
265  return Teuchos::rcp(new KLDivergence<Real>(parlist));
266  default:
267  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
268  "Invalid risk measure type " << risk << "!");
269  }
270  }
271 }
272 #endif
Provides an interface for a smoothed version of the worst-case scenario risk measure using the expect...
Provides an interface for a convex combination of the expected value and the conditional value-at-ris...
Provides an interface for the Kullback-Leibler distributionally robust expectation.
Provides an interface for the entropic risk.
Provides an interface for a convex combination of conditional value-at-risks.
Provides an interface for a convex combination of the expected value and the conditional value-at-ris...
Definition: ROL_CVaR.hpp:79
Contains definitions of custom data types in ROL.
std::string removeStringFormat(std::string s)
Definition: ROL_Types.hpp:174
Provides an interface for a smooth approximation of the conditional value-at-risk.
ERiskMeasure StringToERiskMeasure(std::string s)
Provides an interface for the entropic risk using the expectation risk quadrangle.
Provides an interface for the chi-squared-divergence distributionally robust expectation.
int isValidRiskMeasure(ERiskMeasure ed)
Provides an interface for the mean plus a sum of arbitrary order deviations from targets.
Provides an interface for the mean plus a sum of arbitrary order deviations.
Provides the interface for the coherent entropic risk measure.
std::string ERiskMeasureToString(ERiskMeasure ed)
Provides an interface for the risk measure associated with the super quantile quadrangle.
Provides an interface for the conditioanl entropic risk using the expectation risk quadrangle...
Provides an interface for spectral risk measures.
ETrustRegion & operator--(ETrustRegion &type)
Provides an interface for the mean plus variance risk measure using the expectation risk quadrangle...
Provides an interface for the mean plus a sum of arbitrary order variances from targets.
Teuchos::RCP< RiskMeasure< Real > > RiskMeasureFactory(Teuchos::ParameterList &parlist)
Provides an interface for a convex combination of the expected value and the higher moment coherent r...
Definition: ROL_HMCR.hpp:75
ETrustRegion & operator++(ETrustRegion &type)
Provides an interface for the mean plus a sum of arbitrary order variances.
Provides an interface for the Chebyshev-Kusuoka risk measure.