10 #ifndef ROL_MEANVARIANCE_HPP
11 #define ROL_MEANVARIANCE_HPP
18 #include "ROL_ParameterList.hpp"
72 values_ = makePtr<ScalarController<Real>>();
73 gradvecs_ = makePtr<ScalarController<Real>>();
74 gradients_ = makePtr<VectorController<Real>>();
75 hessvecs_ = makePtr<VectorController<Real>>();
83 ROL_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
84 ">>> ERROR (ROL::MeanVariance): Order and coefficient arrays have different sizes!");
86 for (
int i = 0; i < oSize; i++) {
87 ROL_TEST_FOR_EXCEPTION((
order_[i] < two), std::invalid_argument,
88 ">>> ERROR (ROL::MeanVariance): Element of order array out of range!");
89 ROL_TEST_FOR_EXCEPTION((
coeff_[i] <
zero), std::invalid_argument,
90 ">>> ERROR (ROL::MeanVariance): Element of coefficient array out of range!");
93 ">>> ERROR (ROL::MeanVariance): PositiveFunction pointer is null!");
126 const std::vector<Real> &coeff,
130 for (
uint i = 0; i < order.size(); i++ ) {
131 order_.push_back(order[i]);
133 for (
uint i = 0; i < coeff.size(); i++ ) {
134 coeff_.push_back(coeff[i]);
153 ROL::ParameterList &list
154 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Variance");
156 order_ = ROL::getArrayFromStringParameter<double>(list,
"Orders");
157 coeff_ = ROL::getArrayFromStringParameter<double>(list,
"Coefficients");
159 std::string type = list.get<std::string>(
"Deviation Type");
160 if ( type ==
"Upper" ) {
163 else if ( type ==
"Absolute" ) {
167 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
168 ">>> (ROL::MeanVariance): Variance type is not recoginized!");
191 const std::vector<Real> &xstat,
198 const std::vector<Real> &xstat,
204 Real val(0), diff(0), pf0(0), var(0), weight(0);
214 sampler.
sumAll(&val,&var,1);
221 const std::vector<Real> &xstat,
230 std::vector<Real> &gstat,
232 const std::vector<Real> &xstat,
235 Real ev(0),
zero(0), one(1);
240 Real diff(0), pf0(0), pf1(0), c(0), ec(0), ecs(0), weight(0);
256 sampler.
sumAll(&ec,&ecs,1);
264 const std::vector<Real> &vstat,
266 const std::vector<Real> &xstat,
278 std::vector<Real> &hvstat,
280 const std::vector<Real> &vstat,
282 const std::vector<Real> &xstat,
285 std::vector<Real> myval(2), val(2);
288 sampler.
sumAll(&myval[0],&val[0],2);
289 Real ev = myval[0], egv = myval[1];
294 g_->zero();
hv_->zero();
295 Real diff(0), pf0(0), pf1(0), pf2(0),
zero(0), one(1), two(2);
296 Real cg(0), ecg(0), ecgs(0), ch(0), ech(0), echs(0), weight(0), gv(0);
310 std::pow(pf0,
order_[p]-one)*pf2);
316 g_->axpy(weight*cg,*
hv_);
318 g_->axpy(weight*ch,*
hv_);
320 sampler.
sumAll(&ech,&echs,1);
322 sampler.
sumAll(&ecg,&ecgs,1);
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
Provides the interface to evaluate objective functions.
MeanVariance(const Real order, const Real coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.
void computeHessVec(Vector< Real > &hv, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
typename PV< Real >::size_type size_type
virtual void scale(const Real alpha)=0
Compute where .
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
virtual void plus(const Vector &x)=0
Compute , where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< Vector< Real > > hv_
std::vector< Real > order_
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)
std::vector< Real > coeff_
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 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.
MeanVariance(ROL::ParameterList &parlist)
Constructor.
Ptr< ScalarController< Real > > gradvecs_
void setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
std::vector< Real >::size_type uint
Real computeGradVec(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Ptr< VectorController< Real > > hessvecs_
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
Ptr< ScalarController< Real > > values_
void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
Provides an interface for the mean plus a sum of arbitrary order variances.
virtual void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
Ptr< VectorController< 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.
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.
MeanVariance(const std::vector< Real > &order, const std::vector< Real > &coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.
Ptr< PositiveFunction< Real > > positiveFunction_