10 #ifndef ROL_PD_HMCR2_HPP
11 #define ROL_PD_HMCR2_HPP
49 values_ = makePtr<ScalarController<Real>>();
50 gradvecs_ = makePtr<ScalarController<Real>>();
51 gradients_ = makePtr<VectorController<Real>>();
52 hessvecs_ = makePtr<VectorController<Real>>();
65 ROL_TEST_FOR_EXCEPTION((
beta_ <
zero) || (
beta_ >= one), std::invalid_argument,
66 ">>> ERROR (ROL::PD_HMCR2): Confidence parameter beta is out of range!");
91 const Real
zero(0), two(2);
92 Real val(0), lold(0), lnew(0), mdiff(0), gdiff(0), sum(0), gsum(0);
99 sampler.
sumAll(&sum,&gsum,1);
100 gsum = std::sqrt(gsum);
105 mdiff += sampler.
getMyWeight(i) * std::pow(lnew-lold,2);
108 sampler.
sumAll(&mdiff,&gdiff,1);
109 gdiff = std::sqrt(gdiff);
122 const std::vector<Real> &xstat,
124 const Real
zero(0), two(2);
128 Real arg = val - xstat[0];
135 const std::vector<Real> &xstat,
137 const Real half(0.5), one(1);
140 Real norm = std::sqrt(ev);
141 Real sig = one/(one-
beta_);
145 return xstat[0] + val;
150 const std::vector<Real> &xstat,
152 const Real
zero(0), two(2);
156 Real arg = val - xstat[0];
167 std::vector<Real> &gstat,
169 const std::vector<Real> &xstat,
172 std::vector<Real> mv = {
val_,
gv_};
173 std::vector<Real> ev(2,0);
174 sampler.
sumAll(&mv[0], &ev[0], 2);
175 Real norm = std::sqrt(ev[1]);
176 Real sig = one/(one-
beta_);
180 gstat[0] = one - scal * ev[0];
187 const std::vector<Real> &vstat,
189 const std::vector<Real> &xstat,
191 const Real
zero(0), two(2);
195 Real arg = val - xstat[0];
212 std::vector<Real> &hvstat,
214 const std::vector<Real> &vstat,
216 const std::vector<Real> &xstat,
220 std::vector<Real> ev(4,0);
221 sampler.
sumAll(&mv[0],&ev[0],4);
222 Real norm = std::sqrt(ev[0]);
223 Real sig = one/(one-
beta_);
227 hvstat[0] = scal * ev[1];
231 Real norm3 = ev[0]*norm;
232 hvstat[0] += sig/norm3 * (ev[3] - ev[2]*vstat[0]) * ev[2];
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 .
virtual void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
void setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
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_
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)
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_
virtual void setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
Defines the linear algebra or vector space interface.
virtual int numMySamples(void) const
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)
void initializeStorage(void)
Ptr< ScalarController< Real > > values_
virtual void setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
void initialize(const Vector< Real > &x)
Initialize temporary variables.
Ptr< VectorController< Real > > gradients_
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)
Ptr< VectorController< Real > > hessvecs_
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 setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
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.
Real computeGradVec(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
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.
Ptr< ScalarController< Real > > gradvecs_
virtual void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)