44 #ifndef ROL_EXPECTATIONQUAD_HPP 45 #define ROL_EXPECTATIONQUAD_HPP 67 virtual Real
regret(Real x,
int deriv = 0) = 0;
73 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(0) = 0? \n";
74 std::cout << std::right << std::setw(20) <<
"v(0)" <<
"\n";
75 std::cout << std::scientific << std::setprecision(11) << std::right
76 << std::setw(20) << std::abs(vx)
81 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: x < v(x) for |x| > 0? \n";
82 std::cout << std::right << std::setw(20) <<
"x" 83 << std::right << std::setw(20) <<
"v(x)" 85 for (
int i = 0; i < 10; i++) {
86 x = scale*(Real)rand()/(Real)RAND_MAX - scale*0.5;
88 std::cout << std::scientific << std::setprecision(11) << std::right
90 << std::setw(20) << vx
102 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v(x) is convex? \n";
103 std::cout << std::right << std::setw(20) <<
"v(l*x+(1-l)*y)" 104 << std::setw(20) <<
"l*v(x)+(1-l)*v(y)" 106 for (
int i = 0; i < 10; i++) {
107 x = scale*(Real)rand()/(Real)RAND_MAX - scale*0.5;
109 y = scale*(Real)rand()/(Real)RAND_MAX - scale*0.5;
111 l = (Real)rand()/(Real)RAND_MAX;
114 std::cout << std::scientific << std::setprecision(11) << std::right
115 << std::setw(20) << vz
116 << std::setw(20) << l*vx + (1.0-l)*vy
122 x = 0.001*(Real)rand()/(Real)RAND_MAX - 0.0005;
128 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v'(x) is correct? \n";
129 std::cout << std::right << std::setw(20) <<
"t" 130 << std::setw(20) <<
"v'(x)" 131 << std::setw(20) <<
"(v(x+t)-v(x))/t" 132 << std::setw(20) <<
"Error" 134 for (
int i = 0; i < 13; i++) {
138 err = std::abs(diff-dv);
139 std::cout << std::scientific << std::setprecision(11) << std::right
140 << std::setw(20) << t
141 << std::setw(20) << dv
142 << std::setw(20) << diff
143 << std::setw(20) << err
149 x = 0.001*(Real)rand()/(Real)RAND_MAX - 0.0005;
155 std::cout << std::right << std::setw(20) <<
"CHECK REGRET: v''(x) is correct? \n";
156 std::cout << std::right << std::setw(20) <<
"t" 157 << std::setw(20) <<
"v''(x)" 158 << std::setw(20) <<
"(v'(x+t)-v'(x))/t" 159 << std::setw(20) <<
"Error" 161 for (
int i = 0; i < 13; i++) {
165 err = std::abs(diff-dv);
166 std::cout << std::scientific << std::setprecision(11) << std::right
167 << std::setw(20) << t
168 << std::setw(20) << dv
169 << std::setw(20) << diff
170 << std::setw(20) << err
182 dualVector_ = (x0->dual()).clone();
197 void update(
const Real val,
const Real weight) {
198 Real r =
regret(val-xstat_,0);
203 Real r =
regret(val-xstat_,1);
210 Real r1 =
regret(val-xstat_,1);
211 Real r2 =
regret(val-xstat_,2);
220 sampler.
sumAll(&val,&gval,1);
229 sampler.
sumAll(&stat,&gstat,1);
241 sampler.
sumAll(&stat,&gstat,1);
void update(const Real val, const Vector< Real > &g, const Real weight)
void getGradient(Vector< Real > &g, SampleGenerator< Real > &sampler)
virtual void checkRegret(void)
Real getValue(SampleGenerator< Real > &sampler)
Contains definitions of custom data types in ROL.
const Real getStatistic(const int i=0) const
Defines the linear algebra or vector space interface.
void sumAll(Real *input, Real *output, int dim) const
void setVector(const Vector< Real > &vec)
Teuchos::RCP< const Vector< Real > > getVector() const
void update(const Real val, const Vector< Real > &g, const Real gv, const Vector< Real > &hv, const Real weight)
void setStatistic(const Real stat)
virtual Real regret(Real x, int deriv=0)=0
virtual void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x, Teuchos::RCP< Vector< Real > > &v0, const Vector< Real > &v)
void getHessVec(Vector< Real > &hv, SampleGenerator< Real > &sampler)
void update(const Real val, const Real weight)
void reset(Teuchos::RCP< Vector< Real > > &x0, const Vector< Real > &x)
Teuchos::RCP< Vector< Real > > dualVector_