44 #ifndef ROL_PD_HMCR2_HPP
45 #define ROL_PD_HMCR2_HPP
83 values_ = makePtr<SampledScalar<Real>>();
84 gradvecs_ = makePtr<SampledScalar<Real>>();
86 hessvecs_ = makePtr<SampledVector<Real>>();
99 ROL_TEST_FOR_EXCEPTION((
beta_ <
zero) || (
beta_ >= one), std::invalid_argument,
100 ">>> ERROR (ROL::PD_HMCR2): Confidence parameter beta is out of range!");
125 const Real
zero(0), two(2);
126 Real val(0), lold(0), lnew(0), mdiff(0), gdiff(0), sum(0), gsum(0);
131 sum += sampler.
getMyWeight(i) * std::pow(lnew,two);
133 sampler.
sumAll(&sum,&gsum,1);
134 gsum = std::sqrt(gsum);
139 mdiff += sampler.
getMyWeight(i) * std::pow(lnew-lold,2);
142 sampler.
sumAll(&mdiff,&gdiff,1);
143 gdiff = std::sqrt(gdiff);
156 const std::vector<Real> &xstat,
158 const Real
zero(0), two(2);
162 Real arg = val - xstat[0];
169 const std::vector<Real> &xstat,
171 const Real half(0.5), one(1);
174 Real norm = std::sqrt(ev);
175 Real sig = one/(one-
beta_);
179 return xstat[0] + val;
184 const std::vector<Real> &xstat,
186 const Real
zero(0), two(2);
190 Real arg = val - xstat[0];
201 std::vector<Real> &gstat,
203 const std::vector<Real> &xstat,
206 std::vector<Real> mv = {
val_,
gv_};
207 std::vector<Real> ev(2,0);
208 sampler.
sumAll(&mv[0], &ev[0], 2);
209 Real norm = std::sqrt(ev[1]);
210 Real sig = one/(one-
beta_);
214 gstat[0] = one - scal * ev[0];
221 const std::vector<Real> &vstat,
223 const std::vector<Real> &xstat,
225 const Real
zero(0), two(2);
229 Real arg = val - xstat[0];
246 std::vector<Real> &hvstat,
248 const std::vector<Real> &vstat,
250 const std::vector<Real> &xstat,
254 std::vector<Real> ev(4,0);
255 sampler.
sumAll(&mv[0],&ev[0],4);
256 Real norm = std::sqrt(ev[0]);
257 Real sig = one/(one-
beta_);
261 hvstat[0] = scal * ev[1];
265 Real norm3 = ev[0]*norm;
266 hvstat[0] += sig/norm3 * (ev[3] - ev[2]*vstat[0]) * ev[2];
virtual void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
Provides the interface to evaluate objective functions.
void computeHessVec(Vector< Real > &hv, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
virtual void scale(const Real alpha)=0
Compute where .
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< Vector< Real > > hv_
Ptr< SampledVector< Real > > gradients_
void getHessVec(Vector< Real > &hv, std::vector< Real > &hvstat, const Vector< Real > &v, const std::vector< Real > &vstat, const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure Hessian-times-a-vector.
Contains definitions of custom data types in ROL.
void updateHessVec(Objective< Real > &obj, const Vector< Real > &v, const std::vector< Real > &vstat, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for Hessian-time-a-vector computation.
void setMultiplier(Real &lam, const std::vector< Real > &pt)
Ptr< SampledVector< Real > > hessvecs_
virtual std::vector< Real > getMyPoint(const int i) const
Real getPenaltyParameter(void) const
std::vector< Real > point_
virtual Real getMyWeight(const int i) const
Ptr< Vector< Real > > dualVector_
Defines the linear algebra or vector space interface.
virtual int numMySamples(void) const
Ptr< SampledScalar< Real > > gradvecs_
void sumAll(Real *input, Real *output, int dim) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Real computeDual(SampleGenerator< Real > &sampler)
PD_HMCR2(const Real beta)
virtual void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
void initializeStorage(void)
void initialize(const Vector< Real > &x)
Initialize temporary variables.
void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
virtual void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
void getMultiplier(Real &lam, const std::vector< Real > &pt) const
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
void getGradient(Vector< Real > &g, std::vector< Real > &gstat, const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure (sub)gradient.
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
Real computeGradVec(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Ptr< SampledScalar< Real > > values_
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
void setValue(const Real val, const std::vector< Real > &pt)
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
virtual void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)