44 #ifndef ROL_MEANDEVIATIONFROMTARGET_HPP
45 #define ROL_MEANDEVIATIONFROMTARGET_HPP
48 #include "ROL_ParameterList.hpp"
88 std::vector<Ptr<Vector<Real> > >
pg0_;
89 std::vector<Ptr<Vector<Real> > >
pg_;
90 std::vector<Ptr<Vector<Real> > >
phv_;
120 ROL_TEST_FOR_EXCEPTION((oSize!=cSize),std::invalid_argument,
121 ">>> ERROR (ROL::MeanDeviationFromTarget): Order and coefficient arrays have different sizes!");
122 ROL_TEST_FOR_EXCEPTION((oSize!=tSize),std::invalid_argument,
123 ">>> ERROR (ROL::MeanDeviationFromTarget): Order and target arrays have different sizes!");
124 Real
zero(0), two(2);
125 for (
int i = 0; i < oSize; i++) {
126 ROL_TEST_FOR_EXCEPTION((
order_[i] < two), std::invalid_argument,
127 ">>> ERROR (ROL::MeanDeviationFromTarget): Element of order array out of range!");
128 ROL_TEST_FOR_EXCEPTION((
coeff_[i] <
zero), std::invalid_argument,
129 ">>> ERROR (ROL::MeanDeviationFromTarget): Element of coefficient array out of range!");
132 ">>> ERROR (ROL::MeanDeviationFromTarget): PositiveFunction pointer is null!");
168 const std::vector<Real> &order,
169 const std::vector<Real> &coeff,
173 for (
uint i = 0; i < target.size(); i++ ) {
176 for (
uint i = 0; i < order.size(); i++ ) {
177 order_.push_back(order[i]);
179 for (
uint i = 0; i < coeff.size(); i++ ) {
180 coeff_.push_back(coeff[i]);
200 ROL::ParameterList &list
201 = parlist.sublist(
"SOL").sublist(
"Risk Measure").sublist(
"Mean Plus Deviation From Target");
204 target_ = ROL::getArrayFromStringParameter<double>(list,
"Targets");
206 order_ = ROL::getArrayFromStringParameter<double>(list,
"Orders");
208 coeff_ = ROL::getArrayFromStringParameter<double>(list,
"Coefficients");
211 std::string type = list.get<std::string>(
"Deviation Type");
212 if ( type ==
"Upper" ) {
215 else if ( type ==
"Absolute" ) {
219 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
220 ">>> (ROL::MeanDeviation): Deviation type is not recoginized!");
246 const std::vector<Real> &xstat,
248 Real diff(0), pf0(0);
259 const std::vector<Real> &xstat,
274 const std::vector<Real> &xstat,
276 Real diff(0), pf0(0), pf1(0), c(0), one(1);
283 c = std::pow(pf0,
order_[p]-one) * pf1;
291 std::vector<Real> &gstat,
293 const std::vector<Real> &xstat,
295 const Real
zero(0), one(1);
300 if ( pval_sum[p] >
zero ) {
310 const std::vector<Real> &vstat,
312 const std::vector<Real> &xstat,
314 const Real one(1), two(2);
315 Real diff(0), pf0(0), pf1(0), pf2(0), p0(0), p1(0), p2(0), c(0);
324 p0 = std::pow(pf0,
order_[p]);
325 p1 = std::pow(pf0,
order_[p]-one);
326 p2 = std::pow(pf0,
order_[p]-two);
327 c = -(
order_[p]-one)*p1*pf1;
329 c = gv*((
order_[p]-one)*p2*pf1*pf1 + p1*pf2);
340 std::vector<Real> &hvstat,
342 const std::vector<Real> &vstat,
344 const std::vector<Real> &xstat,
346 const Real
zero(0), one(1), two(2);
354 if ( pval_sum[p] >
zero ) {
357 c =
coeff_[p]*(pgv_sum[p]/std::pow(pval_sum[p],two-one/
order_[p]));
Provides the interface to evaluate objective functions.
MeanDeviationFromTarget(const Real target, const Real order, const Real coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
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< Ptr< Vector< Real > > > pg_
Real computeValue(Objective< Real > &obj, const Vector< Real > &x, Real &tol)
std::vector< Real > target_
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Ptr< Vector< Real > > hv_
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< PositiveFunction< Real > > positiveFunction_
void initialize(const Vector< Real > &x)
Initialize temporary variables.
MeanDeviationFromTarget(ROL::ParameterList &parlist)
Constructor.
Ptr< Vector< Real > > dualVector_
void updateGradient(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal risk measure storage for gradient computation.
Provides an interface for the mean plus a sum of arbitrary order deviations from targets.
Defines the linear algebra or vector space interface.
void updateValue(Objective< Real > &obj, const Vector< Real > &x, const std::vector< Real > &xstat, Real &tol)
Update internal storage for value computation.
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.
void sumAll(Real *input, Real *output, int dim) const
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
std::vector< Real > coeff_
std::vector< Real >::size_type uint
std::vector< Ptr< Vector< Real > > > pg0_
std::vector< Real > pval_
void computeGradient(Vector< Real > &g, Objective< Real > &obj, const Vector< Real > &x, Real &tol)
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 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.
std::vector< Real > order_
std::vector< Ptr< Vector< Real > > > phv_
Real getValue(const Vector< Real > &x, const std::vector< Real > &xstat, SampleGenerator< Real > &sampler)
Return risk measure value.
virtual void initialize(const Vector< Real > &x)
Initialize temporary variables.
MeanDeviationFromTarget(const std::vector< Real > &target, const std::vector< Real > &order, const std::vector< Real > &coeff, const Ptr< PositiveFunction< Real > > &pf)
Constructor.