ROL
ROL_LogExponentialQuadrangle.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_LOGEXPONENTIALQUAD_HPP
11 #define ROL_LOGEXPONENTIALQUAD_HPP
12 
13 #include "ROL_ExpectationQuad.hpp"
14 
44 namespace ROL {
45 
46 template<class Real>
48 private:
49  Real coeff_;
50 
51  void parseParameterList(ROL::ParameterList &parlist) {
52  std::string type = parlist.sublist("SOL").get("Type","Risk Averse");
53  ROL::ParameterList list;
54  if (type == "Risk Averse") {
55  list = parlist.sublist("SOL").sublist("Risk Measure").sublist("Entropic Risk");
56  }
57  else if (type == "Error") {
58  list = parlist.sublist("SOL").sublist("Error Measure").sublist("Exponential");
59  }
60  else if (type == "Deviation") {
61  list = parlist.sublist("SOL").sublist("Deviation Measure").sublist("Entropic");
62  }
63  else if (type == "Regret") {
64  list = parlist.sublist("SOL").sublist("Regret Measure").sublist("Exponential");
65  }
66  coeff_ = list.get<Real>("Rate");
67  }
68 
69  void checkInputs(void) const {
70  Real zero(0);
71  ROL_TEST_FOR_EXCEPTION((coeff_ <= zero), std::invalid_argument,
72  ">>> ERROR (ROL::LogExponentialQuadrangle): Rate must be positive!");
73  }
74 
75 public:
80  LogExponentialQuadrangle(const Real coeff = 1)
81  : ExpectationQuad<Real>(), coeff_(coeff) {
82  checkInputs();
83  }
84 
93  LogExponentialQuadrangle(ROL::ParameterList &parlist)
94  : ExpectationQuad<Real>() {
95  parseParameterList(parlist);
96  checkInputs();
97  }
98 
99  Real error(Real x, int deriv = 0) {
100  Real err(0), one(1), cx = coeff_*x;
101  if (deriv==0) {
102  err = (std::exp(cx) - cx - one)/coeff_;
103  }
104  else if (deriv==1) {
105  err = std::exp(cx) - one;
106  }
107  else {
108  err = coeff_*std::exp(cx);
109  }
110  return err;
111  }
112 
113  Real regret(Real x, int deriv = 0) {
114  Real zero(0), one(1);
115  Real X = ((deriv==0) ? x : ((deriv==1) ? one : zero));
116  Real reg = error(x,deriv) + X;
117  return reg;
118  }
119 
120 };
121 
122 }
123 #endif
LogExponentialQuadrangle(const Real coeff=1)
Constructor.
LogExponentialQuadrangle(ROL::ParameterList &parlist)
Constructor.
Provides a general interface for risk and error measures generated through the expectation risk quadr...
Provides an interface for the entropic risk using the expectation risk quadrangle.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
void parseParameterList(ROL::ParameterList &parlist)
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.