10 #ifndef ROL_MOREAUYOSIDACVAR_HPP
11 #define ROL_MOREAUYOSIDACVAR_HPP
81 std::string type = parlist.sublist(
"SOL").get(
"Type",
"Risk Averse");
82 ROL::ParameterList list;
83 if (type ==
"Risk Averse") {
84 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Moreau-Yosida CVaR");
86 else if (type ==
"Error") {
87 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Moreau-Yosida-Koenker-Bassett");
89 else if (type ==
"Deviation") {
90 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Moreau-Yosida CVaR");
92 else if (type ==
"Regret") {
93 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Moreau-Yosida Mean Absolute Loss");
95 prob_ = list.get<Real>(
"Confidence Level");
96 eps_ = list.get<Real>(
"Smoothing Parameter");
100 Real
zero(0), one(1);
101 ROL_TEST_FOR_EXCEPTION((
prob_ <=
zero) || (
prob_ >= one), std::invalid_argument,
102 ">>> ERROR (ROL::MoreauYosidaCVaR): Confidence level must be between 0 and 1!");
103 ROL_TEST_FOR_EXCEPTION((
eps_ <=
zero), std::invalid_argument,
104 ">>> ERROR (ROL::MoreauYosidaCVaR): Smoothing parameter must be positive!");
142 Real
zero(0), one(1);
143 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
144 return regret(x,deriv) - X;
148 Real
zero(0), half(0.5), one(1), reg(0);
152 else if ( x >=
ub_ ) {
153 reg = ((deriv == 0) ? (x-half*
ub_)/
omp_
154 : ((deriv == 1) ? one/
omp_ :
zero));
157 reg = ((deriv == 0) ? half/
eps_*x*x
158 : ((deriv == 1) ? x/
eps_ : one/
eps_));
165 Real
zero(0), one(1), two(2), p1(0.1);
173 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(eps) is correct? \n";
174 std::cout << std::right << std::setw(20) <<
"t"
175 << std::setw(20) <<
"v'(x)"
176 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
177 << std::setw(20) <<
"Error"
179 for (
int i = 0; i < 13; i++) {
182 diff = (vy-vx)/(two*t);
183 err = std::abs(diff-dv);
184 std::cout << std::scientific << std::setprecision(11) << std::right
185 << std::setw(20) << t
186 << std::setw(20) << dv
187 << std::setw(20) << diff
188 << std::setw(20) << err
200 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(eps) is correct? \n";
201 std::cout << std::right << std::setw(20) <<
"t"
202 << std::setw(20) <<
"v''(x)"
203 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
204 << std::setw(20) <<
"Error"
206 for (
int i = 0; i < 13; i++) {
209 diff = (vy-vx)/(two*t);
210 err = std::abs(diff-dv);
211 std::cout << std::scientific << std::setprecision(11) << std::right
212 << std::setw(20) << t
213 << std::setw(20) << dv
214 << std::setw(20) << diff
215 << std::setw(20) << err
228 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
229 std::cout << std::right << std::setw(20) <<
"t"
230 << std::setw(20) <<
"v'(x)"
231 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
232 << std::setw(20) <<
"Error"
234 for (
int i = 0; i < 13; i++) {
237 diff = (vy-vx)/(two*t);
238 err = std::abs(diff-dv);
239 std::cout << std::scientific << std::setprecision(11) << std::right
240 << std::setw(20) << t
241 << std::setw(20) << dv
242 << std::setw(20) << diff
243 << std::setw(20) << err
255 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
256 std::cout << std::right << std::setw(20) <<
"t"
257 << std::setw(20) <<
"v''(x)"
258 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
259 << std::setw(20) <<
"Error"
261 for (
int i = 0; i < 13; i++) {
264 diff = (vy-vx)/(two*t);
265 err = std::abs(diff-dv);
266 std::cout << std::scientific << std::setprecision(11) << std::right
267 << std::setw(20) << t
268 << std::setw(20) << dv
269 << std::setw(20) << diff
270 << std::setw(20) << err
283 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
284 std::cout << std::right << std::setw(20) <<
"t"
285 << std::setw(20) <<
"v'(x)"
286 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
287 << std::setw(20) <<
"Error"
289 for (
int i = 0; i < 13; i++) {
292 diff = (vy-vx)/(two*t);
293 err = std::abs(diff-dv);
294 std::cout << std::scientific << std::setprecision(11) << std::right
295 << std::setw(20) << t
296 << std::setw(20) << dv
297 << std::setw(20) << diff
298 << std::setw(20) << err
310 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
311 std::cout << std::right << std::setw(20) <<
"t"
312 << std::setw(20) <<
"v''(x)"
313 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
314 << std::setw(20) <<
"Error"
316 for (
int i = 0; i < 13; i++) {
319 diff = (vy-vx)/(two*t);
320 err = std::abs(diff-dv);
321 std::cout << std::scientific << std::setprecision(11) << std::right
322 << std::setw(20) << t
323 << std::setw(20) << dv
324 << std::setw(20) << diff
325 << 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.