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"
75 
76 // F-Divergence Distributionally Robust Risk Measure Implementations
77 #include "ROL_Chi2Divergence.hpp"
78 #include "ROL_KLDivergence.hpp"
79 
80 namespace ROL {
81 
82  enum ERiskMeasure {
107  };
108 
109  inline std::string ERiskMeasureToString(ERiskMeasure ed) {
110  std::string retString;
111  switch(ed) {
112  case RISKMEASURE_CVAR:
113  retString = "CVaR"; break;
115  retString = "Coherent Exponential Utility"; break;
117  retString = "Exponential Utility"; break;
118  case RISKMEASURE_HMCR:
119  retString = "HMCR"; break;
121  retString = "Mean Plus Deviation From Target"; break;
123  retString = "Mean Plus Deviation"; break;
125  retString = "Mean Plus Variance From Target"; break;
127  retString = "Mean Plus Variance"; break;
129  retString = "Moreau-Yosida CVaR"; break;
131  retString = "Generalized Moreau-Yosida CVaR"; break;
133  retString = "Log-Exponential Quadrangle"; break;
135  retString = "Log-Quantile Quadrangle"; break;
137  retString = "Mean-Variance Quadrangle"; break;
139  retString = "Mixed-Quantile Quadrangle"; break;
141  retString = "Super Quantile Quadrangle"; break;
143  retString = "Chebyshev-Kusuoka"; break;
145  retString = "Spectral Risk"; break;
147  retString = "Quantile-Based Quadrangle"; break;
149  retString = "Quantile-Radius Quadrangle"; break;
151  retString = "Smoothed Worst-Case Quadrangle"; break;
153  retString = "Truncated Mean Quadrangle"; break;
155  retString = "Chi-Squared Divergence"; break;
157  retString = "KL Divergence"; break;
158  case RISKMEASURE_LAST:
159  retString = "Last Type (Dummy)"; break;
160  default:
161  retString = "INVALID ERiskMeasure"; break;
162  }
163  return retString;
164  }
165 
167  return( (ed == RISKMEASURE_CVAR) ||
169  (ed == RISKMEASURE_EXPUTILITY) ||
170  (ed == RISKMEASURE_HMCR) ||
172  (ed == RISKMEASURE_MEANDEVIATION) ||
174  (ed == RISKMEASURE_MEANVARIANCE) ||
183  (ed == RISKMEASURE_SPECTRALRISK) ||
188  (ed == RISKMEASURE_CHI2DIVERGENCE) ||
189  (ed == RISKMEASURE_KLDIVERGENCE) );
190  }
191 
193  return type = static_cast<ERiskMeasure>(type+1);
194  }
195 
196  inline ERiskMeasure operator++(ERiskMeasure &type, int) {
197  ERiskMeasure oldval = type;
198  ++type;
199  return oldval;
200  }
201 
203  return type = static_cast<ERiskMeasure>(type-1);
204  }
205 
206  inline ERiskMeasure operator--(ERiskMeasure &type, int) {
207  ERiskMeasure oldval = type;
208  --type;
209  return oldval;
210  }
211 
212  inline ERiskMeasure StringToERiskMeasure(std::string s) {
213  s = removeStringFormat(s);
214  for ( ERiskMeasure tr = RISKMEASURE_CVAR; tr < RISKMEASURE_LAST; tr++ ) {
215  if ( !s.compare(removeStringFormat(ERiskMeasureToString(tr))) ) {
216  return tr;
217  }
218  }
219  return RISKMEASURE_LAST;
220  }
221 
222  template<class Real>
223  inline Teuchos::RCP<RiskMeasure<Real> > RiskMeasureFactory(Teuchos::ParameterList &parlist) {
224  std::string risk = parlist.sublist("SOL").sublist("Risk Measure").get("Name","CVaR");
226  switch(ed) {
227  case RISKMEASURE_CVAR:
228  return Teuchos::rcp(new CVaR<Real>(parlist));
230  return Teuchos::rcp(new CoherentExpUtility<Real>());
232  return Teuchos::rcp(new ExpUtility<Real>(parlist));
233  case RISKMEASURE_HMCR:
234  return Teuchos::rcp(new HMCR<Real>(parlist));
236  return Teuchos::rcp(new MeanDeviationFromTarget<Real>(parlist));
238  return Teuchos::rcp(new MeanDeviation<Real>(parlist));
240  return Teuchos::rcp(new MeanVarianceFromTarget<Real>(parlist));
242  return Teuchos::rcp(new MeanVariance<Real>(parlist));
244  return Teuchos::rcp(new MoreauYosidaCVaR<Real>(parlist));
246  return Teuchos::rcp(new GenMoreauYosidaCVaR<Real>(parlist));
248  return Teuchos::rcp(new LogExponentialQuadrangle<Real>(parlist));
250  return Teuchos::rcp(new LogQuantileQuadrangle<Real>(parlist));
252  return Teuchos::rcp(new MeanVarianceQuadrangle<Real>(parlist));
254  return Teuchos::rcp(new MixedQuantileQuadrangle<Real>(parlist));
256  return Teuchos::rcp(new SuperQuantileQuadrangle<Real>(parlist));
258  return Teuchos::rcp(new ChebyshevKusuoka<Real>(parlist));
260  return Teuchos::rcp(new SpectralRisk<Real>(parlist));
262  return Teuchos::rcp(new QuantileQuadrangle<Real>(parlist));
264  return Teuchos::rcp(new QuantileRadiusQuadrangle<Real>(parlist));
266  return Teuchos::rcp(new SmoothedWorstCaseQuadrangle<Real>(parlist));
268  return Teuchos::rcp(new TruncatedMeanQuadrangle<Real>(parlist));
270  return Teuchos::rcp(new Chi2Divergence<Real>(parlist));
272  return Teuchos::rcp(new KLDivergence<Real>(parlist));
273  default:
274  TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
275  "Invalid risk measure type " << risk << "!");
276  }
277  }
278 }
279 #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.