44 #ifndef ROL_GENMOREAUYOSIDACVAR_HPP
45 #define ROL_GENMOREAUYOSIDACVAR_HPP
122 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
123 ROL::ParameterList list;
124 if (type ==
"Risk Averse") {
125 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Generalized Moreau-Yosida CVaR");
127 else if (type ==
"Error") {
128 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Generalized Moreau-Yosida-Koenker-Bassett");
130 else if (type ==
"Deviation") {
131 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Generalized Moreau-Yosida CVaR");
133 else if (type ==
"Regret") {
134 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Generalized Moreau-Yosida Mean Absolute Loss");
136 prob_ = list.get<Real>(
"Confidence Level");
137 lam_ = list.get<Real>(
"Convex Combination Parameter");
138 eps_ = list.get<Real>(
"Smoothing Parameter");
142 Real
zero(0), one(1);
143 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
144 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Confidence level must be between 0 and 1!");
145 ROL_TEST_FOR_EXCEPTION((
lam_ <
zero) || (
lam_ > one), std::invalid_argument,
146 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Convex combination parameter must be positive!");
147 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
148 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Smoothing parameter must be positive!");
204 Real
zero(0), one(1);
205 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
206 return regret(x,deriv) - X;
210 Real
zero(0), half(0.5), one(1), reg(0);
215 else if ( x >=
ub_ ) {
220 reg = ((deriv == 0) ? half/
eps_*x*x + x
221 : ((deriv == 1) ? x/
eps_ + one : one/
eps_));
228 Real
zero(0), one(1), two(2), p1(0.1);
236 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(ub) is correct? \n";
237 std::cout << std::right << std::setw(20) <<
"t"
238 << std::setw(20) <<
"v'(x)"
239 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
240 << std::setw(20) <<
"Error"
242 for (
int i = 0; i < 13; i++) {
245 diff = (vy-vx)/(two*t);
246 err = std::abs(diff-dv);
247 std::cout << std::scientific << std::setprecision(11) << std::right
248 << std::setw(20) << t
249 << std::setw(20) << dv
250 << std::setw(20) << diff
251 << std::setw(20) << err
263 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(ub) is correct? \n";
264 std::cout << std::right << std::setw(20) <<
"t"
265 << std::setw(20) <<
"v''(x)"
266 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
267 << std::setw(20) <<
"Error"
269 for (
int i = 0; i < 13; i++) {
272 diff = (vy-vx)/(two*t);
273 err = std::abs(diff-dv);
274 std::cout << std::scientific << std::setprecision(11) << std::right
275 << std::setw(20) << t
276 << std::setw(20) << dv
277 << std::setw(20) << diff
278 << std::setw(20) << err
291 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
292 std::cout << std::right << std::setw(20) <<
"t"
293 << std::setw(20) <<
"v'(x)"
294 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
295 << std::setw(20) <<
"Error"
297 for (
int i = 0; i < 13; i++) {
300 diff = (vy-vx)/(two*t);
301 err = std::abs(diff-dv);
302 std::cout << std::scientific << std::setprecision(11) << std::right
303 << std::setw(20) << t
304 << std::setw(20) << dv
305 << std::setw(20) << diff
306 << std::setw(20) << err
318 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
319 std::cout << std::right << std::setw(20) <<
"t"
320 << std::setw(20) <<
"v''(x)"
321 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
322 << std::setw(20) <<
"Error"
324 for (
int i = 0; i < 13; i++) {
327 diff = (vy-vx)/(two*t);
328 err = std::abs(diff-dv);
329 std::cout << std::scientific << std::setprecision(11) << std::right
330 << std::setw(20) << t
331 << std::setw(20) << dv
332 << std::setw(20) << diff
333 << std::setw(20) << err
346 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(lb) is correct? \n";
347 std::cout << std::right << std::setw(20) <<
"t"
348 << std::setw(20) <<
"v'(x)"
349 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
350 << std::setw(20) <<
"Error"
352 for (
int i = 0; i < 13; i++) {
355 diff = (vy-vx)/(two*t);
356 err = std::abs(diff-dv);
357 std::cout << std::scientific << std::setprecision(11) << std::right
358 << std::setw(20) << t
359 << std::setw(20) << dv
360 << std::setw(20) << diff
361 << std::setw(20) << err
373 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(lb) is correct? \n";
374 std::cout << std::right << std::setw(20) <<
"t"
375 << std::setw(20) <<
"v''(x)"
376 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
377 << std::setw(20) <<
"Error"
379 for (
int i = 0; i < 13; i++) {
382 diff = (vy-vx)/(two*t);
383 err = std::abs(diff-dv);
384 std::cout << std::scientific << std::setprecision(11) << std::right
385 << std::setw(20) << t
386 << std::setw(20) << dv
387 << std::setw(20) << diff
388 << std::setw(20) << err
Provides a general interface for risk and error measures generated through the expectation risk quadr...
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
virtual void check(void)
Run default derivative tests for the scalar regret function.
GenMoreauYosidaCVaR(Real prob, Real eps)
Constructor.
GenMoreauYosidaCVaR(Real prob, Real lam, Real eps)
Constructor.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
void check(void)
Run default derivative tests for the scalar regret function.
void checkInputs(void) const
GenMoreauYosidaCVaR(ROL::ParameterList &parlist)
Constructor.
void parseParameterList(ROL::ParameterList &parlist)