44 #ifndef ROL_SMOOTHCVARQUAD_HPP
45 #define ROL_SMOOTHCVARQUAD_HPP
100 ROL::Ptr<PlusFunction<Real> >
pf_;
110 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
111 ROL::ParameterList list;
112 if (type ==
"Risk Averse") {
113 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"CVaR");
115 else if (type ==
"Error") {
116 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Koenker-Bassett");
118 else if (type ==
"Deviation") {
119 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"CVaR");
121 else if (type ==
"Regret") {
122 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Mean Absolute Loss");
125 prob_ = list.get<Real>(
"Confidence Level");
126 lam_ = list.get<Real>(
"Convex Combination Parameter");
127 eps_ = list.get<Real>(
"Smoothing Parameter");
129 pf_ = ROL::makePtr<PlusFunction<Real>>(list);
133 Real
zero(0), one(1);
134 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
135 ">>> ERROR (ROL::QuantileQuadrangle): Confidence level must be between 0 and 1!");
136 ROL_TEST_FOR_EXCEPTION((
lam_ <
zero) || (
lam_ > one), std::invalid_argument,
137 ">>> ERROR (ROL::QuantileQuadrangle): Convex combination parameter must be positive!");
138 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
139 ">>> ERROR (ROL::QuantileQuadrangle): Smoothing parameter must be positive!");
140 ROL_TEST_FOR_EXCEPTION(
pf_ == ROL::nullPtr, std::invalid_argument,
141 ">>> ERROR (ROL::QuantileQuadrangle): PlusFunction pointer is null!");
199 Real err = (
beta_-one)*
pf_->evaluate(x,deriv)
200 + ((deriv%2) ? -one : one)*(one-
alpha_)*
pf_->evaluate(-x,deriv);
205 Real
zero(0), one(1);
206 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
207 Real reg =
error(x,deriv) + X;
214 Real x =
eps_, two(2), p1(0.1), one(1),
zero(0);
217 Real t(1), diff(0), err(0);
218 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(eps) is correct? \n";
219 std::cout << std::right << std::setw(20) <<
"t"
220 << std::setw(20) <<
"v'(x)"
221 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
222 << std::setw(20) <<
"Error"
224 for (
int i = 0; i < 13; i++) {
227 diff = (vy-vx)/(two*t);
228 err = std::abs(diff-dv);
229 std::cout << std::scientific << std::setprecision(11) << std::right
230 << std::setw(20) << t
231 << std::setw(20) << dv
232 << std::setw(20) << diff
233 << std::setw(20) << err
245 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(eps) is correct? \n";
246 std::cout << std::right << std::setw(20) <<
"t"
247 << std::setw(20) <<
"v''(x)"
248 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
249 << std::setw(20) <<
"Error"
251 for (
int i = 0; i < 13; i++) {
254 diff = (vy-vx)/(two*t);
255 err = std::abs(diff-dv);
256 std::cout << std::scientific << std::setprecision(11) << std::right
257 << std::setw(20) << t
258 << std::setw(20) << dv
259 << std::setw(20) << diff
260 << std::setw(20) << err
273 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
274 std::cout << std::right << std::setw(20) <<
"t"
275 << std::setw(20) <<
"v'(x)"
276 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
277 << std::setw(20) <<
"Error"
279 for (
int i = 0; i < 13; i++) {
282 diff = (vy-vx)/(two*t);
283 err = std::abs(diff-dv);
284 std::cout << std::scientific << std::setprecision(11) << std::right
285 << std::setw(20) << t
286 << std::setw(20) << dv
287 << std::setw(20) << diff
288 << std::setw(20) << err
300 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
301 std::cout << std::right << std::setw(20) <<
"t"
302 << std::setw(20) <<
"v''(x)"
303 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
304 << std::setw(20) <<
"Error"
306 for (
int i = 0; i < 13; i++) {
309 diff = (vy-vx)/(two*t);
310 err = std::abs(diff-dv);
311 std::cout << std::scientific << std::setprecision(11) << std::right
312 << std::setw(20) << t
313 << std::setw(20) << dv
314 << std::setw(20) << diff
315 << std::setw(20) << err
328 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
329 std::cout << std::right << std::setw(20) <<
"t"
330 << std::setw(20) <<
"v'(x)"
331 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
332 << std::setw(20) <<
"Error"
334 for (
int i = 0; i < 13; i++) {
337 diff = (vy-vx)/(two*t);
338 err = std::abs(diff-dv);
339 std::cout << std::scientific << std::setprecision(11) << std::right
340 << std::setw(20) << t
341 << std::setw(20) << dv
342 << std::setw(20) << diff
343 << std::setw(20) << err
355 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
356 std::cout << std::right << std::setw(20) <<
"t"
357 << std::setw(20) <<
"v''(x)"
358 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
359 << std::setw(20) <<
"Error"
361 for (
int i = 0; i < 13; i++) {
364 diff = (vy-vx)/(two*t);
365 err = std::abs(diff-dv);
366 std::cout << std::scientific << std::setprecision(11) << std::right
367 << std::setw(20) << t
368 << std::setw(20) << dv
369 << std::setw(20) << diff
370 << std::setw(20) << err
QuantileQuadrangle(Real prob, Real eps, ROL::Ptr< PlusFunction< Real > > &pf)
Constructor.
Provides a general interface for risk and error measures generated through the expectation risk quadr...
void check(void)
Run default derivative tests for the scalar regret function.
Provides an interface for a convex combination of the expected value and the conditional value-at-ris...
virtual void check(void)
Run default derivative tests for the scalar regret function.
void checkInputs(void) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
QuantileQuadrangle(ROL::ParameterList &parlist)
Constructor.
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.
QuantileQuadrangle(Real prob, Real lam, Real eps, ROL::Ptr< PlusFunction< Real > > &pf)
Constructor.
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
void parseParameterList(ROL::ParameterList &parlist)
ROL::Ptr< PlusFunction< Real > > pf_