10 #ifndef ROL_MEANSEMIDEVIATION_HPP
11 #define ROL_MEANSEMIDEVIATION_HPP
63 values_ = makePtr<ScalarController<Real>>();
64 gradvecs_ = makePtr<ScalarController<Real>>();
65 gradients_ = makePtr<VectorController<Real>>();
66 hessvecs_ = makePtr<VectorController<Real>>();
79 ROL_TEST_FOR_EXCEPTION((
coeff_ < zero), std::invalid_argument,
80 ">>> ERROR (ROL::MeanSemiDeviation): Coefficient must be positive!");
81 ROL_TEST_FOR_EXCEPTION(
plusFunction_ == nullPtr, std::invalid_argument,
82 ">>> ERROR (ROL::MeanSemiDeviation): PlusFunction pointer is null!");
109 ROL::ParameterList &list
110 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Semi-Deviation");
112 coeff_ = list.get<Real>(
"Coefficient");
140 const std::vector<Real> &xstat,
147 const std::vector<Real> &xstat,
153 Real diff(0), pf(0), dev(0), weight(0);
160 sampler.
sumAll(&pf,&dev,1);
167 const std::vector<Real> &xstat,
175 std::vector<Real> &gstat,
177 const std::vector<Real> &xstat,
183 Real diff(0), dev(0), pf (0), c(0), one(1), weight(0);
190 sampler.
sumAll(&pf,&dev,1);
198 c = one +
coeff_ * (pf - dev);
207 const std::vector<Real> &vstat,
209 const std::vector<Real> &xstat,
219 std::vector<Real> &hvstat,
221 const std::vector<Real> &vstat,
223 const std::vector<Real> &xstat,
227 std::vector<Real> mval = {
val_,
gv_};
228 std::vector<Real> gval(2,0);
229 sampler.
sumAll(&mval[0],&gval[0],2);
230 Real ev = gval[0], egv = gval[1];
232 Real diff(0), pf1(0), pf2(0), weight(0), gv(0), c(0);
233 std::vector<Real> pf(2,0), dev(2,0);
240 pf[1] += weight *
plusFunction_->evaluate(diff,2) * (gv - egv);
242 sampler.
sumAll(&pf[0],&dev[0],2);
250 c = one +
coeff_ * (pf1 - dev[0]);
254 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.