10 #ifndef ROL_EXPECTATIONQUAD_HPP
11 #define ROL_EXPECTATIONQUAD_HPP
65 virtual Real
regret(Real x,
int deriv = 0) = 0;
74 virtual Real
error(Real x,
int deriv = 0) {
75 const Real one(1),
zero(0);
76 Real X = (deriv==0 ? x : (deriv==1 ? one :
zero));
77 return regret(x,deriv) - X;
83 Real
zero(0), half(0.5), two(2), one(1), oem3(1.e-3), fem4(5.e-4), p1(0.1);
87 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(0) = 0? \n";
88 std::cout << std::right << std::setw(20) <<
"v(0)" <<
"\n";
89 std::cout << std::scientific << std::setprecision(11) << std::right
90 << std::setw(20) << std::abs(vx)
95 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: x < v(x) for |x| > 0? \n";
96 std::cout << std::right << std::setw(20) <<
"x"
97 << std::right << std::setw(20) <<
"v(x)"
99 for (
int i = 0; i < 10; i++) {
100 x = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
102 std::cout << std::scientific << std::setprecision(11) << std::right
103 << std::setw(20) << x
104 << std::setw(20) << vx
116 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(x) is convex? \n";
117 std::cout << std::right << std::setw(20) <<
"v(l*x+(1-l)*y)"
118 << std::setw(20) <<
"l*v(x)+(1-l)*v(y)"
120 for (
int i = 0; i < 10; i++) {
121 x = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
123 y = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
125 l = (Real)rand()/(Real)RAND_MAX;
128 std::cout << std::scientific << std::setprecision(11) << std::right
129 << std::setw(20) << vz
130 << std::setw(20) << l*vx + (one-l)*vy
136 x = oem3*(Real)rand()/(Real)RAND_MAX - fem4;
142 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(x) is correct? \n";
143 std::cout << std::right << std::setw(20) <<
"t"
144 << std::setw(20) <<
"v'(x)"
145 << std::setw(20) <<
"(v(x+t)-v(x))/t"
146 << std::setw(20) <<
"Error"
148 for (
int i = 0; i < 13; i++) {
152 err = std::abs(diff-dv);
153 std::cout << std::scientific << std::setprecision(11) << std::right
154 << std::setw(20) << t
155 << std::setw(20) << dv
156 << std::setw(20) << diff
157 << std::setw(20) << err
163 x = oem3*(Real)rand()/(Real)RAND_MAX - fem4;
169 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(x) is correct? \n";
170 std::cout << std::right << std::setw(20) <<
"t"
171 << std::setw(20) <<
"v''(x)"
172 << std::setw(20) <<
"(v'(x+t)-v'(x))/t"
173 << std::setw(20) <<
"Error"
175 for (
int i = 0; i < 13; i++) {
179 err = std::abs(diff-dv);
180 std::cout << std::scientific << std::setprecision(11) << std::right
181 << std::setw(20) << t
182 << std::setw(20) << dv
183 << std::setw(20) << diff
184 << std::setw(20) << err
Provides a general interface for risk and error measures generated through the expectation risk quadr...
Contains definitions of custom data types in ROL.
virtual ~ExpectationQuad(void)
virtual void check(void)
Run default derivative tests for the scalar regret function.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
virtual Real error(Real x, int deriv=0)
Evaluate the scalar error function at x.
virtual Real regret(Real x, int deriv=0)=0
Evaluate the scalar regret function at x.