10 #ifndef ROL_GENMOREAUYOSIDACVAR_HPP
11 #define ROL_GENMOREAUYOSIDACVAR_HPP
88 std::string type = parlist.sublist(
"SOL").get(
"Type",
"Risk Averse");
89 ROL::ParameterList list;
90 if (type ==
"Risk Averse") {
91 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Generalized Moreau-Yosida CVaR");
93 else if (type ==
"Error") {
94 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Generalized Moreau-Yosida-Koenker-Bassett");
96 else if (type ==
"Deviation") {
97 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Generalized Moreau-Yosida CVaR");
99 else if (type ==
"Regret") {
100 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Generalized Moreau-Yosida Mean Absolute Loss");
102 prob_ = list.get<Real>(
"Confidence Level");
103 lam_ = list.get<Real>(
"Convex Combination Parameter");
104 eps_ = list.get<Real>(
"Smoothing Parameter");
108 Real
zero(0), one(1);
109 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
110 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Confidence level must be between 0 and 1!");
111 ROL_TEST_FOR_EXCEPTION((
lam_ <
zero) || (
lam_ > one), std::invalid_argument,
112 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Convex combination parameter must be positive!");
113 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
114 ">>> ERROR (ROL::GenMoreauYosidaCVaR): Smoothing parameter must be positive!");
170 Real
zero(0), one(1);
171 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
172 return regret(x,deriv) - X;
176 Real
zero(0), half(0.5), one(1), reg(0);
181 else if ( x >=
ub_ ) {
186 reg = ((deriv == 0) ? half/
eps_*x*x + x
187 : ((deriv == 1) ? x/
eps_ + one : one/
eps_));
194 Real
zero(0), one(1), two(2), p1(0.1);
202 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(ub) is correct? \n";
203 std::cout << std::right << std::setw(20) <<
"t"
204 << std::setw(20) <<
"v'(x)"
205 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
206 << std::setw(20) <<
"Error"
208 for (
int i = 0; i < 13; i++) {
211 diff = (vy-vx)/(two*t);
212 err = std::abs(diff-dv);
213 std::cout << std::scientific << std::setprecision(11) << std::right
214 << std::setw(20) << t
215 << std::setw(20) << dv
216 << std::setw(20) << diff
217 << std::setw(20) << err
229 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(ub) is correct? \n";
230 std::cout << std::right << std::setw(20) <<
"t"
231 << std::setw(20) <<
"v''(x)"
232 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
233 << std::setw(20) <<
"Error"
235 for (
int i = 0; i < 13; i++) {
238 diff = (vy-vx)/(two*t);
239 err = std::abs(diff-dv);
240 std::cout << std::scientific << std::setprecision(11) << std::right
241 << std::setw(20) << t
242 << std::setw(20) << dv
243 << std::setw(20) << diff
244 << std::setw(20) << err
257 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
258 std::cout << std::right << std::setw(20) <<
"t"
259 << std::setw(20) <<
"v'(x)"
260 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
261 << std::setw(20) <<
"Error"
263 for (
int i = 0; i < 13; i++) {
266 diff = (vy-vx)/(two*t);
267 err = std::abs(diff-dv);
268 std::cout << std::scientific << std::setprecision(11) << std::right
269 << std::setw(20) << t
270 << std::setw(20) << dv
271 << std::setw(20) << diff
272 << std::setw(20) << err
284 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
285 std::cout << std::right << std::setw(20) <<
"t"
286 << std::setw(20) <<
"v''(x)"
287 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
288 << std::setw(20) <<
"Error"
290 for (
int i = 0; i < 13; i++) {
293 diff = (vy-vx)/(two*t);
294 err = std::abs(diff-dv);
295 std::cout << std::scientific << std::setprecision(11) << std::right
296 << std::setw(20) << t
297 << std::setw(20) << dv
298 << std::setw(20) << diff
299 << std::setw(20) << err
312 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(lb) is correct? \n";
313 std::cout << std::right << std::setw(20) <<
"t"
314 << std::setw(20) <<
"v'(x)"
315 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
316 << std::setw(20) <<
"Error"
318 for (
int i = 0; i < 13; i++) {
321 diff = (vy-vx)/(two*t);
322 err = std::abs(diff-dv);
323 std::cout << std::scientific << std::setprecision(11) << std::right
324 << std::setw(20) << t
325 << std::setw(20) << dv
326 << std::setw(20) << diff
327 << std::setw(20) << err
339 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(lb) is correct? \n";
340 std::cout << std::right << std::setw(20) <<
"t"
341 << std::setw(20) <<
"v''(x)"
342 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
343 << std::setw(20) <<
"Error"
345 for (
int i = 0; i < 13; i++) {
348 diff = (vy-vx)/(two*t);
349 err = std::abs(diff-dv);
350 std::cout << std::scientific << std::setprecision(11) << std::right
351 << std::setw(20) << t
352 << std::setw(20) << dv
353 << std::setw(20) << diff
354 << 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)