10 #ifndef ROL_MEANDEVIATION_HPP
11 #define ROL_MEANDEVIATION_HPP
14 #include "ROL_ParameterList.hpp"
108 values_ = makePtr<ScalarController<Real>>();
109 gradvecs_ = makePtr<ScalarController<Real>>();
110 gradients_ = makePtr<VectorController<Real>>();
111 hessvecs_ = makePtr<VectorController<Real>>();
135 ROL_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
136 ">>> ERROR (ROL::MeanDeviation): Order and coefficient arrays have different sizes!");
137 Real
zero(0), two(2);
138 for (
int i = 0; i < oSize; i++) {
139 ROL_TEST_FOR_EXCEPTION((
order_[i] < two), std::invalid_argument,
140 ">>> ERROR (ROL::MeanDeviation): Element of order array out of range!");
141 ROL_TEST_FOR_EXCEPTION((
coeff_[i] <
zero), std::invalid_argument,
142 ">>> ERROR (ROL::MeanDeviation): Element of coefficient array out of range!");
145 ">>> ERROR (ROL::MeanDeviation): PositiveFunction pointer is null!");
177 const std::vector<Real> &coeff,
181 for (
uint i = 0; i < order.size(); i++ ) {
182 order_.push_back(order[i]);
184 for (
uint i = 0; i < coeff.size(); i++ ) {
185 coeff_.push_back(coeff[i]);
203 ROL::ParameterList &list
204 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Deviation");
207 order_ = ROL::getArrayFromStringParameter<double>(list,
"Orders");
209 coeff_ = ROL::getArrayFromStringParameter<double>(list,
"Coefficients");
212 std::string type = list.get<std::string>(
"Deviation Type");
213 if ( type ==
"Upper" ) {
216 else if ( type ==
"Absolute" ) {
220 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
221 ">>> (ROL::MeanDeviation): Deviation type is not recoginized!");
248 const std::vector<Real> &xstat,
256 const std::vector<Real> &xstat,
266 const std::vector<Real> &vstat,
268 const std::vector<Real> &xstat,
280 const std::vector<Real> &xstat,
286 Real diff(0), pf0(0), dev(0), one(1), weight(0);
305 std::vector<Real> &gstat,
307 const std::vector<Real> &xstat,
313 Real diff(0), pf0(0), pf1(0), c(0), one(1),
zero(0), weight(0);
322 dev1_[p] += weight * std::pow(pf0,
order_[p]-one) * pf1;
351 std::vector<Real> &hvstat,
353 const std::vector<Real> &vstat,
355 const std::vector<Real> &xstat,
358 std::vector<Real> myval(2), val(2);
361 sampler.
sumAll(&myval[0],&val[0],2);
362 Real ev = val[0], egv = val[1];
364 Real diff(0), pf0(0), pf1(0), pf2(0),
zero(0), one(1), two(2);
365 Real cg(0), ch(0), diff1(0), diff2(0), diff3(0), weight(0), gv(0);
375 dev1_[p] += weight * std::pow(pf0,
order_[p]-one) * pf1;
376 dev2_[p] += weight * std::pow(pf0,
order_[p]-two) * pf1 * pf1;
377 dev3_[p] += weight * std::pow(pf0,
order_[p]-one) * pf2;
423 diff2 = std::pow(pf0,
order_[p]-two)*pf1*pf1*(gv-egv)-
gvs2_[p];
424 diff3 = std::pow(pf0,
order_[p]-one)*pf2*(gv-egv)-
gvs3_[p];
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)
typename PV< Real >::size_type size_type
std::vector< Real > dev2_
std::vector< Real > gvs3_
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
MeanDeviation(const std::vector< Real > &order, const std::vector< Real > &coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
std::vector< Real > dev0_
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< Vector< Real > > hv_
Ptr< ScalarController< Real > > values_
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.
std::vector< Real >::size_type uint
std::vector< Real > dev3_
MeanDeviation(const Real order, const Real coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.
virtual std::vector< Real > getMyPoint(const int i) const
virtual Real getMyWeight(const int i) const
Ptr< Vector< Real > > dualVector_
std::vector< Real > des0_
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
MeanDeviation(ROL::ParameterList &parlist)
Constructor.
void sumAll(Real *input, Real *output, int dim) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
Provides an interface for the mean plus a sum of arbitrary order deviations.
std::vector< Real > gvp3_
std::vector< Real > order_
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 initialize(const Vector< Real > &x)
Initialize temporary variables.
std::vector< Real > gvp2_
Ptr< ScalarController< Real > > gradvecs_
std::vector< Real > des3_
std::vector< Real > dev1_
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
std::vector< Real > des2_
std::vector< Real > devp_
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
void setStorage(const Ptr< ScalarController< Real >> &value_storage, const Ptr< VectorController< Real >> &gradient_storage)
std::vector< Real > gvs2_
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...
Ptr< VectorController< Real > > gradients_
std::vector< Real > des1_
virtual void setHessVecStorage(const Ptr< ScalarController< Real >> &gradvec_storage, const Ptr< VectorController< Real >> &hessvec_storage)
std::vector< Real > gvp1_
std::vector< Real > coeff_
Ptr< VectorController< Real > > hessvecs_
void initializeStorage(void)
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
std::vector< Real > gvs1_
Ptr< PositiveFunction< Real > > positiveFunction_