44 #ifndef ROL_SMOOTHEDWORSTCASEQUAD_HPP
45 #define ROL_SMOOTHEDWORSTCASEQUAD_HPP
95 std::string type = parlist.sublist(
"SOL").get(
"Stochastic Component Type",
"Risk Averse");
96 ROL::ParameterList list;
97 if (type ==
"Risk Averse") {
98 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Smoothed Worst Case");
100 else if (type ==
"Error") {
101 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Smoothed Worst Case");
103 else if (type ==
"Deviation") {
104 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Smoothed Upper Range");
106 else if (type ==
"Regret") {
107 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Smoothed Worst Case");
109 eps_ = list.get<Real>(
"Smoothing Parameter");
114 ROL_TEST_FOR_EXCEPTION((
eps_ <= zero), std::invalid_argument,
115 ">>> ERROR (ROL::SmoothedWorstCaseQuadrangle): Smoothing parameter must be positive!");
142 Real err(0),
zero(0), half(0.5), one(1);
146 else if (deriv == 1) {
156 Real
zero(0), one(1);
157 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
158 Real reg =
error(x,deriv) + X;
165 Real x = -
eps_,
zero(0), one(1), two(2), p1(0.1);
171 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
172 std::cout << std::right << std::setw(20) <<
"t"
173 << std::setw(20) <<
"v'(x)"
174 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
175 << std::setw(20) <<
"Error"
177 for (
int i = 0; i < 13; i++) {
180 diff = (vy-vx)/(two*t);
181 err = std::abs(diff-dv);
182 std::cout << std::scientific << std::setprecision(11) << std::right
183 << std::setw(20) << t
184 << std::setw(20) << dv
185 << std::setw(20) << diff
186 << std::setw(20) << err
198 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
199 std::cout << std::right << std::setw(20) <<
"t"
200 << std::setw(20) <<
"v''(x)"
201 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
202 << std::setw(20) <<
"Error"
204 for (
int i = 0; i < 13; i++) {
207 diff = (vy-vx)/(two*t);
208 err = std::abs(diff-dv);
209 std::cout << std::scientific << std::setprecision(11) << std::right
210 << std::setw(20) << t
211 << std::setw(20) << dv
212 << std::setw(20) << diff
213 << std::setw(20) << err
226 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
227 std::cout << std::right << std::setw(20) <<
"t"
228 << std::setw(20) <<
"v'(x)"
229 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
230 << std::setw(20) <<
"Error"
232 for (
int i = 0; i < 13; i++) {
235 diff = (vy-vx)/(two*t);
236 err = std::abs(diff-dv);
237 std::cout << std::scientific << std::setprecision(11) << std::right
238 << std::setw(20) << t
239 << std::setw(20) << dv
240 << std::setw(20) << diff
241 << std::setw(20) << err
253 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
254 std::cout << std::right << std::setw(20) <<
"t"
255 << std::setw(20) <<
"v''(x)"
256 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
257 << std::setw(20) <<
"Error"
259 for (
int i = 0; i < 13; i++) {
262 diff = (vy-vx)/(two*t);
263 err = std::abs(diff-dv);
264 std::cout << std::scientific << std::setprecision(11) << std::right
265 << std::setw(20) << t
266 << std::setw(20) << dv
267 << std::setw(20) << diff
268 << std::setw(20) << err
281 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-1-eps) is correct? \n";
282 std::cout << std::right << std::setw(20) <<
"t"
283 << std::setw(20) <<
"v'(x)"
284 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
285 << std::setw(20) <<
"Error"
287 for (
int i = 0; i < 13; i++) {
290 diff = (vy-vx)/(two*t);
291 err = std::abs(diff-dv);
292 std::cout << std::scientific << std::setprecision(11) << std::right
293 << std::setw(20) << t
294 << std::setw(20) << dv
295 << std::setw(20) << diff
296 << std::setw(20) << err
308 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-1-eps) is correct? \n";
309 std::cout << std::right << std::setw(20) <<
"t"
310 << std::setw(20) <<
"v''(x)"
311 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
312 << std::setw(20) <<
"Error"
314 for (
int i = 0; i < 13; i++) {
317 diff = (vy-vx)/(two*t);
318 err = std::abs(diff-dv);
319 std::cout << std::scientific << std::setprecision(11) << std::right
320 << std::setw(20) << t
321 << std::setw(20) << dv
322 << std::setw(20) << diff
323 << std::setw(20) << err
Provides an interface for a smoothed version of the worst-case scenario risk measure using the expect...
Provides a general interface for risk and error measures generated through the expectation risk quadr...
void checkInputs(void) const
virtual void check(void)
Run default derivative tests for the scalar regret function.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
SmoothedWorstCaseQuadrangle(ROL::ParameterList &parlist)
Constructor.
Real regret(Real x, int deriv=0)
Evaluate the scalar regret function at x.
SmoothedWorstCaseQuadrangle(const Real eps)
Constructor.
Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
void check(void)
Run default derivative tests for the scalar regret function.
void parseParameterList(ROL::ParameterList &parlist)