44 #ifndef ROL_EXPECTATIONQUAD_HPP
45 #define ROL_EXPECTATIONQUAD_HPP
99 virtual Real
regret(Real x,
int deriv = 0) = 0;
108 virtual Real
error(Real x,
int deriv = 0) {
109 const Real one(1),
zero(0);
110 Real X = (deriv==0 ? x : (deriv==1 ? one :
zero));
111 return regret(x,deriv) - X;
117 Real
zero(0), half(0.5), two(2), one(1), oem3(1.e-3), fem4(5.e-4), p1(0.1);
121 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(0) = 0? \n";
122 std::cout << std::right << std::setw(20) <<
"v(0)" <<
"\n";
123 std::cout << std::scientific << std::setprecision(11) << std::right
124 << std::setw(20) << std::abs(vx)
129 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: x < v(x) for |x| > 0? \n";
130 std::cout << std::right << std::setw(20) <<
"x"
131 << std::right << std::setw(20) <<
"v(x)"
133 for (
int i = 0; i < 10; i++) {
134 x = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
136 std::cout << std::scientific << std::setprecision(11) << std::right
137 << std::setw(20) << x
138 << std::setw(20) << vx
150 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(x) is convex? \n";
151 std::cout << std::right << std::setw(20) <<
"v(l*x+(1-l)*y)"
152 << std::setw(20) <<
"l*v(x)+(1-l)*v(y)"
154 for (
int i = 0; i < 10; i++) {
155 x = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
157 y = scale*(Real)rand()/(Real)RAND_MAX - scale*half;
159 l = (Real)rand()/(Real)RAND_MAX;
162 std::cout << std::scientific << std::setprecision(11) << std::right
163 << std::setw(20) << vz
164 << std::setw(20) << l*vx + (one-l)*vy
170 x = oem3*(Real)rand()/(Real)RAND_MAX - fem4;
176 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(x) is correct? \n";
177 std::cout << std::right << std::setw(20) <<
"t"
178 << std::setw(20) <<
"v'(x)"
179 << std::setw(20) <<
"(v(x+t)-v(x))/t"
180 << std::setw(20) <<
"Error"
182 for (
int i = 0; i < 13; i++) {
186 err = std::abs(diff-dv);
187 std::cout << std::scientific << std::setprecision(11) << std::right
188 << std::setw(20) << t
189 << std::setw(20) << dv
190 << std::setw(20) << diff
191 << std::setw(20) << err
197 x = oem3*(Real)rand()/(Real)RAND_MAX - fem4;
203 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(x) is correct? \n";
204 std::cout << std::right << std::setw(20) <<
"t"
205 << std::setw(20) <<
"v''(x)"
206 << std::setw(20) <<
"(v'(x+t)-v'(x))/t"
207 << std::setw(20) <<
"Error"
209 for (
int i = 0; i < 13; i++) {
213 err = std::abs(diff-dv);
214 std::cout << std::scientific << std::setprecision(11) << std::right
215 << std::setw(20) << t
216 << std::setw(20) << dv
217 << std::setw(20) << diff
218 << 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.