44 #ifndef ROL_LOGQUANTILEQUAD_HPP
45 #define ROL_LOGQUANTILEQUAD_HPP
79 ROL::Ptr<PlusFunction<Real> >
pf_;
86 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
87 ROL::ParameterList list;
88 if (type ==
"Risk Averse") {
89 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Log Quantile");
91 else if (type ==
"Error") {
92 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Log Quantile");
94 else if (type ==
"Deviation") {
95 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Log Quantile");
97 else if (type ==
"Regret") {
98 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Log Quantile");
101 alpha_ = list.get<Real>(
"Slope for Linear Growth");
102 rate_ = list.get<Real>(
"Rate for Exponential Growth");
103 eps_ = list.get<Real>(
"Smoothing Parameter");
105 pf_ = ROL::makePtr<PlusFunction<Real>>(list);
109 Real
zero(0), one(1);
110 ROL_TEST_FOR_EXCEPTION((
alpha_ <
zero) || (
alpha_ >= one), std::invalid_argument,
111 ">>> ERROR (ROL::LogQuantileQuadrangle): Linear growth rate must be between 0 and 1!");
112 ROL_TEST_FOR_EXCEPTION((
rate_ <=
zero), std::invalid_argument,
113 ">>> ERROR (ROL::LogQuantileQuadrangle): Exponential growth rate must be positive!");
114 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
115 ">>> ERROR (ROL::LogQuantileQuadrangle): Smoothing parameter must be positive!");
116 ROL_TEST_FOR_EXCEPTION(
pf_ == ROL::nullPtr, std::invalid_argument,
117 ">>> ERROR (ROL::LogQuantileQuadrangle): PlusFunction pointer is null!");
152 Real
zero(0), one(1);
153 ROL_TEST_FOR_EXCEPTION( (deriv > 2), std::invalid_argument,
154 ">>> ERROR (ROL::LogQuantileQuadrangle::error): deriv greater than 2!");
155 ROL_TEST_FOR_EXCEPTION( (deriv < 0), std::invalid_argument,
156 ">>> ERROR (ROL::LogQuantileQuadrangle::error): deriv less than 0!");
158 Real X = ((deriv == 0) ? x : ((deriv == 1) ? one :
zero));
159 return regret(x,deriv) - X;
163 Real
zero(0), one(1);
164 ROL_TEST_FOR_EXCEPTION( (deriv > 2), std::invalid_argument,
165 ">>> ERROR (ROL::LogQuantileQuadrangle::regret): deriv greater than 2!");
166 ROL_TEST_FOR_EXCEPTION( (deriv < 0), std::invalid_argument,
167 ">>> ERROR (ROL::LogQuantileQuadrangle::regret): deriv less than 0!");
169 Real arg = std::exp(
rate_*x);
170 Real sarg =
rate_*arg;
171 Real reg = (
pf_->evaluate(arg-one,deriv) *
172 ((deriv == 0) ? one/
rate_ : ((deriv == 1) ? arg : sarg*arg))
173 + ((deriv == 2) ?
pf_->evaluate(arg-one,deriv-1)*sarg :
zero))
174 + ((deriv%2 == 0) ? -one : one) *
alpha_ *
pf_->evaluate(-x,deriv);
181 Real x =
eps_, two(2), p1(0.1),
zero(0), one(1);
184 Real t(1), diff(0), err(0);
185 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(eps) is correct? \n";
186 std::cout << std::right << std::setw(20) <<
"t"
187 << std::setw(20) <<
"v'(x)"
188 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
189 << std::setw(20) <<
"Error"
191 for (
int i = 0; i < 13; i++) {
194 diff = (vy-vx)/(two*t);
195 err = std::abs(diff-dv);
196 std::cout << std::scientific << std::setprecision(11) << std::right
197 << std::setw(20) << t
198 << std::setw(20) << dv
199 << std::setw(20) << diff
200 << std::setw(20) << err
212 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(eps) is correct? \n";
213 std::cout << std::right << std::setw(20) <<
"t"
214 << std::setw(20) <<
"v''(x)"
215 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
216 << std::setw(20) <<
"Error"
218 for (
int i = 0; i < 13; i++) {
221 diff = (vy-vx)/(two*t);
222 err = std::abs(diff-dv);
223 std::cout << std::scientific << std::setprecision(11) << std::right
224 << std::setw(20) << t
225 << std::setw(20) << dv
226 << std::setw(20) << diff
227 << std::setw(20) << err
240 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
241 std::cout << std::right << std::setw(20) <<
"t"
242 << std::setw(20) <<
"v'(x)"
243 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
244 << std::setw(20) <<
"Error"
246 for (
int i = 0; i < 13; i++) {
249 diff = (vy-vx)/(two*t);
250 err = std::abs(diff-dv);
251 std::cout << std::scientific << std::setprecision(11) << std::right
252 << std::setw(20) << t
253 << std::setw(20) << dv
254 << std::setw(20) << diff
255 << std::setw(20) << err
267 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
268 std::cout << std::right << std::setw(20) <<
"t"
269 << std::setw(20) <<
"v''(x)"
270 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
271 << std::setw(20) <<
"Error"
273 for (
int i = 0; i < 13; i++) {
276 diff = (vy-vx)/(two*t);
277 err = std::abs(diff-dv);
278 std::cout << std::scientific << std::setprecision(11) << std::right
279 << std::setw(20) << t
280 << std::setw(20) << dv
281 << std::setw(20) << diff
282 << std::setw(20) << err
295 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
296 std::cout << std::right << std::setw(20) <<
"t"
297 << std::setw(20) <<
"v'(x)"
298 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
299 << std::setw(20) <<
"Error"
301 for (
int i = 0; i < 13; i++) {
304 diff = (vy-vx)/(two*t);
305 err = std::abs(diff-dv);
306 std::cout << std::scientific << std::setprecision(11) << std::right
307 << std::setw(20) << t
308 << std::setw(20) << dv
309 << std::setw(20) << diff
310 << std::setw(20) << err
322 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
323 std::cout << std::right << std::setw(20) <<
"t"
324 << std::setw(20) <<
"v''(x)"
325 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
326 << std::setw(20) <<
"Error"
328 for (
int i = 0; i < 13; i++) {
331 diff = (vy-vx)/(two*t);
332 err = std::abs(diff-dv);
333 std::cout << std::scientific << std::setprecision(11) << std::right
334 << std::setw(20) << t
335 << std::setw(20) << dv
336 << std::setw(20) << diff
337 << std::setw(20) << err
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
Provides a general interface for risk and error measures generated through the expectation risk quadr...
virtual void check(void)
Run default derivative tests for the scalar regret function.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Provides an interface for the conditioanl entropic risk using the expectation risk quadrangle...
LogQuantileQuadrangle(ROL::ParameterList &parlist)
Constructor.
void parseParameterList(ROL::ParameterList &parlist)
ROL::Ptr< PlusFunction< Real > > pf_
void check(void)
Run default derivative tests for the scalar regret function.
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.
LogQuantileQuadrangle(Real alpha, Real rate, Real eps, ROL::Ptr< PlusFunction< Real > > &pf)
Constructor.
void checkInputs(void) const