10 #ifndef ROL_MEANSEMIDEVIATION_HPP
11 #define ROL_MEANSEMIDEVIATION_HPP
62 values_ = makePtr<ScalarController<Real>>();
63 gradvecs_ = makePtr<ScalarController<Real>>();
64 gradients_ = makePtr<VectorController<Real>>();
65 hessvecs_ = makePtr<VectorController<Real>>();
78 ROL_TEST_FOR_EXCEPTION((
coeff_ < zero), std::invalid_argument,
79 ">>> ERROR (ROL::MeanSemiDeviation): Coefficient must be positive!");
80 ROL_TEST_FOR_EXCEPTION(
plusFunction_ == nullPtr, std::invalid_argument,
81 ">>> ERROR (ROL::MeanSemiDeviation): PlusFunction pointer is null!");
108 ROL::ParameterList &list
109 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Semi-Deviation");
111 coeff_ = list.get<Real>(
"Coefficient");
139 const std::vector<Real> &xstat,
146 const std::vector<Real> &xstat,
152 Real diff(0), pf(0), dev(0), weight(0);
159 sampler.
sumAll(&pf,&dev,1);
166 const std::vector<Real> &xstat,
174 std::vector<Real> &gstat,
176 const std::vector<Real> &xstat,
182 Real diff(0), dev(0), pf (0), c(0), one(1), weight(0);
189 sampler.
sumAll(&pf,&dev,1);
197 c = one +
coeff_ * (pf - dev);
206 const std::vector<Real> &vstat,
208 const std::vector<Real> &xstat,
218 std::vector<Real> &hvstat,
220 const std::vector<Real> &vstat,
222 const std::vector<Real> &xstat,
226 std::vector<Real> mval = {
val_,
gv_};
227 std::vector<Real> gval(2,0);
228 sampler.
sumAll(&mval[0],&gval[0],2);
229 Real ev = gval[0], egv = gval[1];
231 Real diff(0), pf1(0), pf2(0), weight(0), gv(0), c(0);
232 std::vector<Real> pf(2,0), dev(2,0);
239 pf[1] += weight *
plusFunction_->evaluate(diff,2) * (gv - egv);
241 sampler.
sumAll(&pf[0],&dev[0],2);
249 c = one +
coeff_ * (pf1 - dev[0]);
253 c =
coeff_ * (pf2 - dev[1]);
Provides the interface to evaluate objective functions.
Ptr< PlusFunction< Real > > plusFunction_
void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
Ptr< ScalarController< Real > > gradvecs_
void computeHessVec(Vector< Real > &hv, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
Ptr< VectorController< Real > > gradients_
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_
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()
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.
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.
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 initializeStorage(void)
Ptr< VectorController< Real > > hessvecs_
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.
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 setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
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.
Ptr< ScalarController< Real > > values_
virtual void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.