10 #ifndef ROL_SMOOTHEDWORSTCASEQUAD_HPP
11 #define ROL_SMOOTHEDWORSTCASEQUAD_HPP
61 std::string type = parlist.sublist(
"SOL").get(
"Type",
"Risk Averse");
62 ROL::ParameterList list;
63 if (type ==
"Risk Averse") {
64 list = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Smoothed Worst Case");
66 else if (type ==
"Error") {
67 list = parlist.sublist(
"SOL").sublist(
"Error Measure").sublist(
"Smoothed Worst Case");
69 else if (type ==
"Deviation") {
70 list = parlist.sublist(
"SOL").sublist(
"Deviation Measure").sublist(
"Smoothed Upper Range");
72 else if (type ==
"Regret") {
73 list = parlist.sublist(
"SOL").sublist(
"Regret Measure").sublist(
"Smoothed Worst Case");
75 eps_ = list.get<Real>(
"Smoothing Parameter");
80 ROL_TEST_FOR_EXCEPTION((
eps_ <= zero), std::invalid_argument,
81 ">>> ERROR (ROL::SmoothedWorstCaseQuadrangle): Smoothing parameter must be positive!");
108 Real err(0),
zero(0), half(0.5), one(1);
112 else if (deriv == 1) {
122 Real
zero(0), one(1);
123 Real X = ((deriv==0) ? x : ((deriv==1) ? one :
zero));
124 Real reg =
error(x,deriv) + X;
131 Real x = -
eps_,
zero(0), one(1), two(2), p1(0.1);
137 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-eps) is correct? \n";
138 std::cout << std::right << std::setw(20) <<
"t"
139 << std::setw(20) <<
"v'(x)"
140 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
141 << std::setw(20) <<
"Error"
143 for (
int i = 0; i < 13; i++) {
146 diff = (vy-vx)/(two*t);
147 err = std::abs(diff-dv);
148 std::cout << std::scientific << std::setprecision(11) << std::right
149 << std::setw(20) << t
150 << std::setw(20) << dv
151 << std::setw(20) << diff
152 << std::setw(20) << err
164 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-eps) is correct? \n";
165 std::cout << std::right << std::setw(20) <<
"t"
166 << std::setw(20) <<
"v''(x)"
167 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
168 << std::setw(20) <<
"Error"
170 for (
int i = 0; i < 13; i++) {
173 diff = (vy-vx)/(two*t);
174 err = std::abs(diff-dv);
175 std::cout << std::scientific << std::setprecision(11) << std::right
176 << std::setw(20) << t
177 << std::setw(20) << dv
178 << std::setw(20) << diff
179 << std::setw(20) << err
192 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(0) is correct? \n";
193 std::cout << std::right << std::setw(20) <<
"t"
194 << std::setw(20) <<
"v'(x)"
195 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
196 << std::setw(20) <<
"Error"
198 for (
int i = 0; i < 13; i++) {
201 diff = (vy-vx)/(two*t);
202 err = std::abs(diff-dv);
203 std::cout << std::scientific << std::setprecision(11) << std::right
204 << std::setw(20) << t
205 << std::setw(20) << dv
206 << std::setw(20) << diff
207 << std::setw(20) << err
219 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(0) is correct? \n";
220 std::cout << std::right << std::setw(20) <<
"t"
221 << std::setw(20) <<
"v''(x)"
222 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
223 << std::setw(20) <<
"Error"
225 for (
int i = 0; i < 13; i++) {
228 diff = (vy-vx)/(two*t);
229 err = std::abs(diff-dv);
230 std::cout << std::scientific << std::setprecision(11) << std::right
231 << std::setw(20) << t
232 << std::setw(20) << dv
233 << std::setw(20) << diff
234 << std::setw(20) << err
247 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(-1-eps) is correct? \n";
248 std::cout << std::right << std::setw(20) <<
"t"
249 << std::setw(20) <<
"v'(x)"
250 << std::setw(20) <<
"(v(x+t)-v(x-t))/2t"
251 << std::setw(20) <<
"Error"
253 for (
int i = 0; i < 13; i++) {
256 diff = (vy-vx)/(two*t);
257 err = std::abs(diff-dv);
258 std::cout << std::scientific << std::setprecision(11) << std::right
259 << std::setw(20) << t
260 << std::setw(20) << dv
261 << std::setw(20) << diff
262 << std::setw(20) << err
274 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(-1-eps) is correct? \n";
275 std::cout << std::right << std::setw(20) <<
"t"
276 << std::setw(20) <<
"v''(x)"
277 << std::setw(20) <<
"(v'(x+t)-v'(x-t))/2t"
278 << std::setw(20) <<
"Error"
280 for (
int i = 0; i < 13; i++) {
283 diff = (vy-vx)/(two*t);
284 err = std::abs(diff-dv);
285 std::cout << std::scientific << std::setprecision(11) << std::right
286 << std::setw(20) << t
287 << std::setw(20) << dv
288 << std::setw(20) << diff
289 << 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)