44 #ifndef ROL_MEANSEMIDEVIATION_HPP
45 #define ROL_MEANSEMIDEVIATION_HPP
97 values_ = makePtr<SampledScalar<Real>>();
98 gradvecs_ = makePtr<SampledScalar<Real>>();
100 hessvecs_ = makePtr<SampledVector<Real>>();
113 ROL_TEST_FOR_EXCEPTION((
coeff_ < zero), std::invalid_argument,
114 ">>> ERROR (ROL::MeanSemiDeviation): Coefficient must be positive!");
115 ROL_TEST_FOR_EXCEPTION(
plusFunction_ == nullPtr, std::invalid_argument,
116 ">>> ERROR (ROL::MeanSemiDeviation): PlusFunction pointer is null!");
143 ROL::ParameterList &list
144 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Semi-Deviation");
146 coeff_ = list.get<Real>(
"Coefficient");
174 const std::vector<Real> &xstat,
181 const std::vector<Real> &xstat,
187 Real diff(0), pf(0), dev(0), weight(0);
194 sampler.
sumAll(&pf,&dev,1);
201 const std::vector<Real> &xstat,
209 std::vector<Real> &gstat,
211 const std::vector<Real> &xstat,
217 Real diff(0), dev(0), pf (0), c(0), one(1), weight(0);
224 sampler.
sumAll(&pf,&dev,1);
232 c = one +
coeff_ * (pf - dev);
241 const std::vector<Real> &vstat,
243 const std::vector<Real> &xstat,
253 std::vector<Real> &hvstat,
255 const std::vector<Real> &vstat,
257 const std::vector<Real> &xstat,
259 const Real
zero(0), one(1);
261 std::vector<Real> mval = {
val_,
gv_};
262 std::vector<Real> gval(2,0);
263 sampler.
sumAll(&mval[0],&gval[0],2);
264 Real ev = gval[0], egv = gval[1];
266 Real diff(0), pf1(0), pf2(0), weight(0), gv(0), c(0);
267 std::vector<Real> pf(2,0), dev(2,0);
274 pf[1] += weight *
plusFunction_->evaluate(diff,2) * (gv - egv);
276 sampler.
sumAll(&pf[0],&dev[0],2);
284 c = one +
coeff_ * (pf1 - dev[0]);
288 c =
coeff_ * (pf2 - dev[1]);
virtual void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
Provides the interface to evaluate objective functions.
Ptr< PlusFunction< Real > > plusFunction_
void computeHessVec(Vector< Real > &hv, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Ptr< SampledScalar< Real > > values_
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
Ptr< Vector< Real > > hv_
void initialize(const Vector< Real > &x)
Initialize temporary variables.
virtual std::vector< Real > getMyPoint(const int i) const
virtual Real getMyWeight(const int i) const
Ptr< Vector< Real > > dualVector_
Defines the linear algebra or vector space interface.
virtual int numMySamples(void) const
void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
void sumAll(Real *input, Real *output, int dim) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
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.
MeanSemiDeviation(const Real coeff, const Ptr< PlusFunction< Real > > &pf)
Constructor.
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
virtual void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
MeanSemiDeviation(ROL::ParameterList &parlist)
Constructor.
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.
Ptr< SampledVector< Real > > hessvecs_
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
void initializeStorage(void)
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
Provides an interface for the mean plus upper semideviation of order 1.
Ptr< SampledScalar< Real > > gradvecs_
Ptr< SampledVector< Real > > gradients_
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 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.
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.