10 #ifndef ROL_SMOOTHCVARQUAD_HPP
11 #define ROL_SMOOTHCVARQUAD_HPP
66 ROL::Ptr<PlusFunction<Real> >
pf_;
76 std::string type = parlist.sublist(
"SOL").get(
"Type",
"Risk Averse");
77 ROL::ParameterList list;
78 if (type ==
"Risk Averse") {
79 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"CVaR");
81 else if (type ==
"Error") {
82 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Koenker-Bassett");
84 else if (type ==
"Deviation") {
85 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"CVaR");
87 else if (type ==
"Regret") {
88 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Mean Absolute Loss");
91 prob_ = list.get<Real>(
"Confidence Level");
92 lam_ = list.get<Real>(
"Convex Combination Parameter");
93 eps_ = list.get<Real>(
"Smoothing Parameter");
95 pf_ = ROL::makePtr<PlusFunction<Real>>(list);
100 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
101 ">>> ERROR (ROL::QuantileQuadrangle): Confidence level must be between 0 and 1!");
102 ROL_TEST_FOR_EXCEPTION((
lam_ <
zero) || (
lam_ > one), std::invalid_argument,
103 ">>> ERROR (ROL::QuantileQuadrangle): Convex combination parameter must be positive!");
104 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
105 ">>> ERROR (ROL::QuantileQuadrangle): Smoothing parameter must be positive!");
106 ROL_TEST_FOR_EXCEPTION(
pf_ == ROL::nullPtr, std::invalid_argument,
107 ">>> ERROR (ROL::QuantileQuadrangle): PlusFunction pointer is null!");
165 Real err = (
beta_-one)*
pf_->evaluate(x,deriv)
166 + ((deriv%2) ? -one : one)*(one-
alpha_)*
pf_->evaluate(-x,deriv);
171 Real
zero(0), one(1);
172 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
173 Real reg =
error(x,deriv) + X;
180 Real x =
eps_, two(2), p1(0.1), one(1),
zero(0);
183 Real t(1), diff(0), err(0);
184 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(eps) is correct? \n";
185 std::cout << std::right << std::setw(20) <<
"t"
186 << std::setw(20) <<
"v'(x)"
187 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
188 << std::setw(20) <<
"Error"
190 for (
int i = 0; i < 13; i++) {
193 diff = (vy-vx)/(two*t);
194 err = std::abs(diff-dv);
195 std::cout << std::scientific << std::setprecision(11) << std::right
196 << std::setw(20) << t
197 << std::setw(20) << dv
198 << std::setw(20) << diff
199 << std::setw(20) << err
211 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(eps) is correct? \n";
212 std::cout << std::right << std::setw(20) <<
"t"
213 << std::setw(20) <<
"v''(x)"
214 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
215 << std::setw(20) <<
"Error"
217 for (
int i = 0; i < 13; i++) {
220 diff = (vy-vx)/(two*t);
221 err = std::abs(diff-dv);
222 std::cout << std::scientific << std::setprecision(11) << std::right
223 << std::setw(20) << t
224 << std::setw(20) << dv
225 << std::setw(20) << diff
226 << std::setw(20) << err
239 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
240 std::cout << std::right << std::setw(20) <<
"t"
241 << std::setw(20) <<
"v'(x)"
242 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
243 << std::setw(20) <<
"Error"
245 for (
int i = 0; i < 13; i++) {
248 diff = (vy-vx)/(two*t);
249 err = std::abs(diff-dv);
250 std::cout << std::scientific << std::setprecision(11) << std::right
251 << std::setw(20) << t
252 << std::setw(20) << dv
253 << std::setw(20) << diff
254 << std::setw(20) << err
266 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
267 std::cout << std::right << std::setw(20) <<
"t"
268 << std::setw(20) <<
"v''(x)"
269 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
270 << std::setw(20) <<
"Error"
272 for (
int i = 0; i < 13; i++) {
275 diff = (vy-vx)/(two*t);
276 err = std::abs(diff-dv);
277 std::cout << std::scientific << std::setprecision(11) << std::right
278 << std::setw(20) << t
279 << std::setw(20) << dv
280 << std::setw(20) << diff
281 << std::setw(20) << err
294 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
295 std::cout << std::right << std::setw(20) <<
"t"
296 << std::setw(20) <<
"v'(x)"
297 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
298 << std::setw(20) <<
"Error"
300 for (
int i = 0; i < 13; i++) {
303 diff = (vy-vx)/(two*t);
304 err = std::abs(diff-dv);
305 std::cout << std::scientific << std::setprecision(11) << std::right
306 << std::setw(20) << t
307 << std::setw(20) << dv
308 << std::setw(20) << diff
309 << std::setw(20) << err
321 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
322 std::cout << std::right << std::setw(20) <<
"t"
323 << std::setw(20) <<
"v''(x)"
324 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
325 << std::setw(20) <<
"Error"
327 for (
int i = 0; i < 13; i++) {
330 diff = (vy-vx)/(two*t);
331 err = std::abs(diff-dv);
332 std::cout << std::scientific << std::setprecision(11) << std::right
333 << std::setw(20) << t
334 << std::setw(20) << dv
335 << std::setw(20) << diff
336 << 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_