This file is indexed.

/usr/include/trilinos/ROL_RiskMeasureFactory.hpp is in libtrilinos-rol-dev 12.12.1-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
// @HEADER
// ************************************************************************
//
//               Rapid Optimization Library (ROL) Package
//                 Copyright (2014) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on behalf of the U.S. Government.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the Corporation nor the names of the
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Questions? Contact lead developers:
//              Drew Kouri   (dpkouri@sandia.gov) and
//              Denis Ridzal (dridzal@sandia.gov)
//
// ************************************************************************
// @HEADER

#ifndef ROL_RISKMEASUREFACTORY_HPP
#define ROL_RISKMEASUREFACTORY_HPP

#include "Teuchos_ParameterList.hpp"

#include "ROL_Types.hpp"

// Standard Risk Measure Implementations
#include "ROL_CVaR.hpp"
#include "ROL_CoherentExpUtility.hpp"
#include "ROL_ExpUtility.hpp"
#include "ROL_HMCR.hpp"
#include "ROL_MeanDeviationFromTarget.hpp"
#include "ROL_MeanDeviation.hpp"
#include "ROL_MeanVarianceFromTarget.hpp"
#include "ROL_MeanVariance.hpp"
#include "ROL_MoreauYosidaCVaR.hpp"

// Risk Quadrangle Risk Measure Implementations
#include "ROL_LogExponentialQuadrangle.hpp"
#include "ROL_LogQuantileQuadrangle.hpp"
#include "ROL_MeanVarianceQuadrangle.hpp"
#include "ROL_MixedQuantileQuadrangle.hpp"
#include "ROL_SuperQuantileQuadrangle.hpp"
#include "ROL_ChebyshevKusuoka.hpp"
#include "ROL_SpectralRisk.hpp"
#include "ROL_QuantileQuadrangle.hpp"
#include "ROL_QuantileRadiusQuadrangle.hpp"
#include "ROL_SmoothedWorstCaseQuadrangle.hpp"
#include "ROL_TruncatedMeanQuadrangle.hpp"
#include "ROL_GenMoreauYosidaCVaR.hpp"

// F-Divergence Distributionally Robust Risk Measure Implementations
#include "ROL_Chi2Divergence.hpp"
#include "ROL_KLDivergence.hpp"

namespace ROL {

  enum ERiskMeasure {
    RISKMEASURE_CVAR = 0,
    RISKMEASURE_COHERENTEXPUTILITY,
    RISKMEASURE_EXPUTILITY,
    RISKMEASURE_HMCR,
    RISKMEASURE_MEANDEVIATIONFROMTARGET, 
    RISKMEASURE_MEANDEVIATION,
    RISKMEASURE_MEANVARIANCEFROMTARGET,
    RISKMEASURE_MEANVARIANCE,
    RISKMEASURE_MOREAUYOSIDACVAR,
    RISKMEASURE_GENMOREAUYOSIDACVAR,
    RISKMEASURE_LOGEXPONENTIALQUADRANGLE,
    RISKMEASURE_LOGQUANTILEQUADRANGLE,
    RISKMEASURE_MEANVARIANCEQUADRANGLE,
    RISKMEASURE_MIXEDQUANTILEQUADRANGLE,
    RISKMEASURE_QUANTILEQUADRANGLE,
    RISKMEASURE_QUANTILERADIUSQUADRANGLE,
    RISKMEASURE_SMOOTHEDWORSTCASEQUADRANGLE,
    RISKMEASURE_SUPERQUANTILEQUADRANGLE,
    RISKMEASURE_CHEBYSHEVKUSUOKA,
    RISKMEASURE_SPECTRALRISK,
    RISKMEASURE_TRUNCATEDMEANQUADRANGLE,
    RISKMEASURE_CHI2DIVERGENCE,
    RISKMEASURE_KLDIVERGENCE,
    RISKMEASURE_LAST
  };

  inline std::string ERiskMeasureToString(ERiskMeasure ed) {
    std::string retString;
    switch(ed) {
      case RISKMEASURE_CVAR:
             retString = "CVaR";                                    break;
      case RISKMEASURE_COHERENTEXPUTILITY:
             retString = "Coherent Exponential Utility";            break;
      case RISKMEASURE_EXPUTILITY:
             retString = "Exponential Utility";                     break;
      case RISKMEASURE_HMCR:
             retString = "HMCR";                                    break;
      case RISKMEASURE_MEANDEVIATIONFROMTARGET:
             retString = "Mean Plus Deviation From Target";         break;
      case RISKMEASURE_MEANDEVIATION:
             retString = "Mean Plus Deviation";                     break;
      case RISKMEASURE_MEANVARIANCEFROMTARGET:
             retString = "Mean Plus Variance From Target";          break;
      case RISKMEASURE_MEANVARIANCE:
             retString = "Mean Plus Variance";                      break;
      case RISKMEASURE_MOREAUYOSIDACVAR:
             retString = "Moreau-Yosida CVaR";                      break;
      case RISKMEASURE_GENMOREAUYOSIDACVAR:
             retString = "Generalized Moreau-Yosida CVaR";          break;
      case RISKMEASURE_LOGEXPONENTIALQUADRANGLE:
             retString = "Log-Exponential Quadrangle";              break;
      case RISKMEASURE_LOGQUANTILEQUADRANGLE:
             retString = "Log-Quantile Quadrangle";                 break;
      case RISKMEASURE_MEANVARIANCEQUADRANGLE:
             retString = "Mean-Variance Quadrangle";                break;
      case RISKMEASURE_MIXEDQUANTILEQUADRANGLE:
             retString = "Mixed-Quantile Quadrangle";               break;
      case RISKMEASURE_SUPERQUANTILEQUADRANGLE:
             retString = "Super Quantile Quadrangle";               break;
      case RISKMEASURE_CHEBYSHEVKUSUOKA:
             retString = "Chebyshev-Kusuoka";                       break;
      case RISKMEASURE_SPECTRALRISK:
             retString = "Spectral Risk";                           break;
      case RISKMEASURE_QUANTILEQUADRANGLE:
             retString = "Quantile-Based Quadrangle";               break;
      case RISKMEASURE_QUANTILERADIUSQUADRANGLE:
             retString = "Quantile-Radius Quadrangle";              break;
      case RISKMEASURE_SMOOTHEDWORSTCASEQUADRANGLE:
             retString = "Smoothed Worst-Case Quadrangle";          break;
      case RISKMEASURE_TRUNCATEDMEANQUADRANGLE:
             retString = "Truncated Mean Quadrangle";               break;
      case RISKMEASURE_CHI2DIVERGENCE:
             retString = "Chi-Squared Divergence";                  break;
      case RISKMEASURE_KLDIVERGENCE:
             retString = "KL Divergence";                           break;
      case RISKMEASURE_LAST:
             retString = "Last Type (Dummy)";                       break;
      default:
             retString = "INVALID ERiskMeasure";                    break;
    }
    return retString;
  }

  inline int isValidRiskMeasure(ERiskMeasure ed) {
    return( (ed == RISKMEASURE_CVAR) ||
            (ed == RISKMEASURE_COHERENTEXPUTILITY) ||
            (ed == RISKMEASURE_EXPUTILITY) ||
            (ed == RISKMEASURE_HMCR) ||
            (ed == RISKMEASURE_MEANDEVIATIONFROMTARGET) ||
            (ed == RISKMEASURE_MEANDEVIATION) ||
            (ed == RISKMEASURE_MEANVARIANCEFROMTARGET) ||
            (ed == RISKMEASURE_MEANVARIANCE) ||
            (ed == RISKMEASURE_MOREAUYOSIDACVAR) ||
            (ed == RISKMEASURE_GENMOREAUYOSIDACVAR) ||
            (ed == RISKMEASURE_LOGEXPONENTIALQUADRANGLE) ||
            (ed == RISKMEASURE_LOGQUANTILEQUADRANGLE) ||
            (ed == RISKMEASURE_MEANVARIANCEQUADRANGLE) ||
            (ed == RISKMEASURE_MIXEDQUANTILEQUADRANGLE) ||
            (ed == RISKMEASURE_SUPERQUANTILEQUADRANGLE) ||
            (ed == RISKMEASURE_CHEBYSHEVKUSUOKA) ||
            (ed == RISKMEASURE_SPECTRALRISK) ||
            (ed == RISKMEASURE_QUANTILEQUADRANGLE) ||
            (ed == RISKMEASURE_QUANTILERADIUSQUADRANGLE) ||
            (ed == RISKMEASURE_SMOOTHEDWORSTCASEQUADRANGLE) ||
            (ed == RISKMEASURE_TRUNCATEDMEANQUADRANGLE) ||
            (ed == RISKMEASURE_CHI2DIVERGENCE) ||
            (ed == RISKMEASURE_KLDIVERGENCE) );
  }

  inline ERiskMeasure & operator++(ERiskMeasure &type) {
    return type = static_cast<ERiskMeasure>(type+1);
  }

  inline ERiskMeasure operator++(ERiskMeasure &type, int) {
    ERiskMeasure oldval = type;
    ++type;
    return oldval;
  }

  inline ERiskMeasure & operator--(ERiskMeasure &type) {
    return type = static_cast<ERiskMeasure>(type-1);
  }

  inline ERiskMeasure operator--(ERiskMeasure &type, int) {
    ERiskMeasure oldval = type;
    --type;
    return oldval;
  }

  inline ERiskMeasure StringToERiskMeasure(std::string s) {
    s = removeStringFormat(s);
    for ( ERiskMeasure tr = RISKMEASURE_CVAR; tr < RISKMEASURE_LAST; tr++ ) {
      if ( !s.compare(removeStringFormat(ERiskMeasureToString(tr))) ) {
        return tr;
      }
    }
    return RISKMEASURE_LAST;
  }

  template<class Real>
  inline Teuchos::RCP<RiskMeasure<Real> > RiskMeasureFactory(Teuchos::ParameterList &parlist) {
    std::string risk = parlist.sublist("SOL").sublist("Risk Measure").get("Name","CVaR");
    ERiskMeasure ed = StringToERiskMeasure(risk);
    switch(ed) {
      case RISKMEASURE_CVAR:
             return Teuchos::rcp(new CVaR<Real>(parlist));
      case RISKMEASURE_COHERENTEXPUTILITY:
             return Teuchos::rcp(new CoherentExpUtility<Real>());
      case RISKMEASURE_EXPUTILITY:
             return Teuchos::rcp(new ExpUtility<Real>(parlist));
      case RISKMEASURE_HMCR:
             return Teuchos::rcp(new HMCR<Real>(parlist));
      case RISKMEASURE_MEANDEVIATIONFROMTARGET:
             return Teuchos::rcp(new MeanDeviationFromTarget<Real>(parlist));
      case RISKMEASURE_MEANDEVIATION:
             return Teuchos::rcp(new MeanDeviation<Real>(parlist));
      case RISKMEASURE_MEANVARIANCEFROMTARGET:
             return Teuchos::rcp(new MeanVarianceFromTarget<Real>(parlist));
      case RISKMEASURE_MEANVARIANCE:
             return Teuchos::rcp(new MeanVariance<Real>(parlist));
      case RISKMEASURE_MOREAUYOSIDACVAR:
             return Teuchos::rcp(new MoreauYosidaCVaR<Real>(parlist));
      case RISKMEASURE_GENMOREAUYOSIDACVAR:
             return Teuchos::rcp(new GenMoreauYosidaCVaR<Real>(parlist));
      case RISKMEASURE_LOGEXPONENTIALQUADRANGLE:
             return Teuchos::rcp(new LogExponentialQuadrangle<Real>(parlist));
      case RISKMEASURE_LOGQUANTILEQUADRANGLE:
             return Teuchos::rcp(new LogQuantileQuadrangle<Real>(parlist));
      case RISKMEASURE_MEANVARIANCEQUADRANGLE:
             return Teuchos::rcp(new MeanVarianceQuadrangle<Real>(parlist));
      case RISKMEASURE_MIXEDQUANTILEQUADRANGLE:
             return Teuchos::rcp(new MixedQuantileQuadrangle<Real>(parlist));
      case RISKMEASURE_SUPERQUANTILEQUADRANGLE:
             return Teuchos::rcp(new SuperQuantileQuadrangle<Real>(parlist));
      case RISKMEASURE_CHEBYSHEVKUSUOKA:
             return Teuchos::rcp(new ChebyshevKusuoka<Real>(parlist));
      case RISKMEASURE_SPECTRALRISK:
             return Teuchos::rcp(new SpectralRisk<Real>(parlist));
      case RISKMEASURE_QUANTILEQUADRANGLE:
             return Teuchos::rcp(new QuantileQuadrangle<Real>(parlist));
      case RISKMEASURE_QUANTILERADIUSQUADRANGLE:
             return Teuchos::rcp(new QuantileRadiusQuadrangle<Real>(parlist));
      case RISKMEASURE_SMOOTHEDWORSTCASEQUADRANGLE:
             return Teuchos::rcp(new SmoothedWorstCaseQuadrangle<Real>(parlist));
      case RISKMEASURE_TRUNCATEDMEANQUADRANGLE:
             return Teuchos::rcp(new TruncatedMeanQuadrangle<Real>(parlist));
      case RISKMEASURE_CHI2DIVERGENCE:
             return Teuchos::rcp(new Chi2Divergence<Real>(parlist));
      case RISKMEASURE_KLDIVERGENCE:
             return Teuchos::rcp(new KLDivergence<Real>(parlist));
      default:
        TEUCHOS_TEST_FOR_EXCEPTION(true,std::invalid_argument,
                                   "Invalid risk measure type " << risk << "!");
    }
  }
}
#endif