44 #ifndef ROL_MEANDEVIATION_HPP
45 #define ROL_MEANDEVIATION_HPP
48 #include "ROL_ParameterList.hpp"
142 values_ = makePtr<SampledScalar<Real>>();
143 gradvecs_ = makePtr<SampledScalar<Real>>();
145 hessvecs_ = makePtr<SampledVector<Real>>();
169 ROL_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
170 ">>> ERROR (ROL::MeanDeviation): Order and coefficient arrays have different sizes!");
171 Real
zero(0), two(2);
172 for (
int i = 0; i < oSize; i++) {
173 ROL_TEST_FOR_EXCEPTION((
order_[i] < two), std::invalid_argument,
174 ">>> ERROR (ROL::MeanDeviation): Element of order array out of range!");
175 ROL_TEST_FOR_EXCEPTION((
coeff_[i] <
zero), std::invalid_argument,
176 ">>> ERROR (ROL::MeanDeviation): Element of coefficient array out of range!");
179 ">>> ERROR (ROL::MeanDeviation): PositiveFunction pointer is null!");
211 const std::vector<Real> &coeff,
215 for (
uint i = 0; i < order.size(); i++ ) {
216 order_.push_back(order[i]);
218 for (
uint i = 0; i < coeff.size(); i++ ) {
219 coeff_.push_back(coeff[i]);
237 ROL::ParameterList &list
238 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Deviation");
241 order_ = ROL::getArrayFromStringParameter<double>(list,
"Orders");
243 coeff_ = ROL::getArrayFromStringParameter<double>(list,
"Coefficients");
246 std::string type = list.get<std::string>(
"Deviation Type");
247 if ( type ==
"Upper" ) {
250 else if ( type ==
"Absolute" ) {
254 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
255 ">>> (ROL::MeanDeviation): Deviation type is not recoginized!");
282 const std::vector<Real> &xstat,
290 const std::vector<Real> &xstat,
300 const std::vector<Real> &vstat,
302 const std::vector<Real> &xstat,
314 const std::vector<Real> &xstat,
320 Real diff(0), pf0(0), dev(0), one(1), weight(0);
339 std::vector<Real> &gstat,
341 const std::vector<Real> &xstat,
347 Real diff(0), pf0(0), pf1(0), c(0), one(1),
zero(0), weight(0);
356 dev1_[p] += weight * std::pow(pf0,
order_[p]-one) * pf1;
385 std::vector<Real> &hvstat,
387 const std::vector<Real> &vstat,
389 const std::vector<Real> &xstat,
392 std::vector<Real> myval(2), val(2);
395 sampler.
sumAll(&myval[0],&val[0],2);
396 Real ev = val[0], egv = val[1];
398 Real diff(0), pf0(0), pf1(0), pf2(0),
zero(0), one(1), two(2);
399 Real cg(0), ch(0), diff1(0), diff2(0), diff3(0), weight(0), gv(0);
409 dev1_[p] += weight * std::pow(pf0,
order_[p]-one) * pf1;
410 dev2_[p] += weight * std::pow(pf0,
order_[p]-two) * pf1 * pf1;
411 dev3_[p] += weight * std::pow(pf0,
order_[p]-one) * pf2;
457 diff2 = std::pow(pf0,
order_[p]-two)*pf1*pf1*(gv-egv)-
gvs2_[p];
458 diff3 = std::pow(pf0,
order_[p]-one)*pf2*(gv-egv)-
gvs3_[p];
virtual void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
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)
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_
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
Ptr< SampledVector< Real > > gradients_
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_
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_
virtual void setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
Ptr< SampledScalar< Real > > gradvecs_
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 setStorage(const Ptr< SampledScalar< Real >> &value_storage, const Ptr< SampledVector< Real >> &gradient_storage)
void initialize(const Vector< Real > &x)
Initialize temporary variables.
std::vector< Real > gvp2_
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_
Ptr< SampledVector< Real > > hessvecs_
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
void setHessVecStorage(const Ptr< SampledScalar< Real >> &gradvec_storage, const Ptr< SampledVector< Real >> &hessvec_storage)
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
std::vector< Real > gvs2_
Real computeGradVec(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Ptr< SampledScalar< Real > > values_
Provides the interface to implement any functional that maps a random variable to a (extended) real n...
std::vector< Real > des1_
std::vector< Real > gvp1_
std::vector< Real > coeff_
void initializeStorage(void)
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
std::vector< Real > gvs1_
Ptr< PositiveFunction< Real > > positiveFunction_