44 #ifndef ROL_MOREAUYOSIDACVAR_HPP
45 #define ROL_MOREAUYOSIDACVAR_HPP
115 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
116 ROL::ParameterList list;
117 if (type ==
"Risk Averse") {
118 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Moreau-Yosida CVaR");
120 else if (type ==
"Error") {
121 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Moreau-Yosida-Koenker-Bassett");
123 else if (type ==
"Deviation") {
124 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Moreau-Yosida CVaR");
126 else if (type ==
"Regret") {
127 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Moreau-Yosida Mean Absolute Loss");
129 prob_ = list.get<Real>(
"Confidence Level");
130 eps_ = list.get<Real>(
"Smoothing Parameter");
134 Real
zero(0), one(1);
135 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
136 ">>> ERROR (ROL::MoreauYosidaCVaR): Confidence level must be between 0 and 1!");
137 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
138 ">>> ERROR (ROL::MoreauYosidaCVaR): Smoothing parameter must be positive!");
176 Real
zero(0), one(1);
177 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
178 return regret(x,deriv) - X;
182 Real
zero(0), half(0.5), one(1), reg(0);
186 else if ( x >=
ub_ ) {
187 reg = ((deriv == 0) ? (x-half*
ub_)/
omp_
188 : ((deriv == 1) ? one/
omp_ :
zero));
191 reg = ((deriv == 0) ? half/
eps_*x*x
192 : ((deriv == 1) ? x/
eps_ : one/
eps_));
199 Real
zero(0), one(1), two(2), p1(0.1);
207 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(eps) is correct? \n";
208 std::cout << std::right << std::setw(20) <<
"t"
209 << std::setw(20) <<
"v'(x)"
210 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
211 << std::setw(20) <<
"Error"
213 for (
int i = 0; i < 13; i++) {
216 diff = (vy-vx)/(two*t);
217 err = std::abs(diff-dv);
218 std::cout << std::scientific << std::setprecision(11) << std::right
219 << std::setw(20) << t
220 << std::setw(20) << dv
221 << std::setw(20) << diff
222 << std::setw(20) << err
234 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(eps) is correct? \n";
235 std::cout << std::right << std::setw(20) <<
"t"
236 << std::setw(20) <<
"v''(x)"
237 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
238 << std::setw(20) <<
"Error"
240 for (
int i = 0; i < 13; i++) {
243 diff = (vy-vx)/(two*t);
244 err = std::abs(diff-dv);
245 std::cout << std::scientific << std::setprecision(11) << std::right
246 << std::setw(20) << t
247 << std::setw(20) << dv
248 << std::setw(20) << diff
249 << std::setw(20) << err
262 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
263 std::cout << std::right << std::setw(20) <<
"t"
264 << std::setw(20) <<
"v'(x)"
265 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
266 << std::setw(20) <<
"Error"
268 for (
int i = 0; i < 13; i++) {
271 diff = (vy-vx)/(two*t);
272 err = std::abs(diff-dv);
273 std::cout << std::scientific << std::setprecision(11) << std::right
274 << std::setw(20) << t
275 << std::setw(20) << dv
276 << std::setw(20) << diff
277 << std::setw(20) << err
289 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
290 std::cout << std::right << std::setw(20) <<
"t"
291 << std::setw(20) <<
"v''(x)"
292 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
293 << std::setw(20) <<
"Error"
295 for (
int i = 0; i < 13; i++) {
298 diff = (vy-vx)/(two*t);
299 err = std::abs(diff-dv);
300 std::cout << std::scientific << std::setprecision(11) << std::right
301 << std::setw(20) << t
302 << std::setw(20) << dv
303 << std::setw(20) << diff
304 << std::setw(20) << err
317 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
318 std::cout << std::right << std::setw(20) <<
"t"
319 << std::setw(20) <<
"v'(x)"
320 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
321 << std::setw(20) <<
"Error"
323 for (
int i = 0; i < 13; i++) {
326 diff = (vy-vx)/(two*t);
327 err = std::abs(diff-dv);
328 std::cout << std::scientific << std::setprecision(11) << std::right
329 << std::setw(20) << t
330 << std::setw(20) << dv
331 << std::setw(20) << diff
332 << std::setw(20) << err
344 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
345 std::cout << std::right << std::setw(20) <<
"t"
346 << std::setw(20) <<
"v''(x)"
347 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
348 << std::setw(20) <<
"Error"
350 for (
int i = 0; i < 13; i++) {
353 diff = (vy-vx)/(two*t);
354 err = std::abs(diff-dv);
355 std::cout << std::scientific << std::setprecision(11) << std::right
356 << std::setw(20) << t
357 << std::setw(20) << dv
358 << std::setw(20) << diff
359 << std::setw(20) << err
void check(void)
Run default derivative tests for the scalar regret function.
Provides a general interface for risk and error measures generated through the expectation risk quadr...
Provides an interface for a smooth approximation of the conditional value-at-risk.
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()
void parseParameterList(ROL::ParameterList &parlist)
MoreauYosidaCVaR(ROL::ParameterList &parlist)
Constructor.
MoreauYosidaCVaR(Real prob, Real eps)
Constructor.
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.