10 #ifndef ROL_POINTWISECDFOBJECTIVE_H
11 #define ROL_POINTWISECDFOBJECTIVE_H
17 #include "ROL_Ptr.hpp"
25 std::vector<ROL::Ptr<Distribution<Real> > >
dist_;
26 ROL::Ptr<BatchManager<Real> >
bman_;
32 const int numSamples = x.getNumSamples();
33 Real val = 0., hs = 0., xpt = 0., xwt = 0.;
34 for (
int k = 0; k < numSamples; k++) {
35 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
42 Real
gradientCDF(std::vector<Real> &gradx, std::vector<Real> &gradp,
44 const int numSamples = x.getNumSamples();
45 gradx.resize(numSamples,0.); gradp.resize(numSamples,0.);
46 Real val = 0., hs = 0., xpt = 0., xwt = 0.;
47 for (
int k = 0; k < numSamples; k++) {
48 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
52 * std::exp(-std::pow((loc-xpt)/(
sqrt2_*scale_),2));
60 const int numSamples = x.getNumSamples();
61 hvx.resize(numSamples,0.);
62 Real val = 0., hs = 0., xpt = 0., xwt = 0., scale3 = std::pow(
scale_,3);
63 for (
int k = 0; k < numSamples; k++) {
64 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
68 * std::exp(-std::pow((loc-xpt)/(
sqrt2_*scale_),2)) * (loc-xpt);
76 const Real scale = 1.e-2)
82 const int dimension = ex.getDimension();
83 const int numSamples = ex.getNumSamples();
84 Real val = 0., diff = 0., xpt = 0., sum = 0.;
85 for (
int d = 0; d < dimension; d++) {
86 for (
int k = 0; k < numSamples; k++) {
87 xpt = (*ex.getPoint(k))[d];
89 val += std::pow(diff,2);
92 bman_->sumAll(&val,&sum,1);
99 const int dimension = ex.getDimension();
100 const int numSamples = ex.getNumSamples();
101 std::vector<Real> gradx(numSamples,0.), gradp(numSamples,0.);
102 Real diff = 0., xpt = 0., val = 0., sum = 0.;
103 std::vector<Real> val_wt(numSamples,0.), tmp(dimension,0.);
104 std::vector<std::vector<Real> > val_pt(numSamples,tmp);
105 for (
int d = 0; d < dimension; d++) {
106 for (
int k = 0; k < numSamples; k++) {
107 xpt = (*ex.getPoint(k))[d];
109 diff = (val-
dist_[d]->evaluateCDF(xpt));
111 for (
int j = 0; j < numSamples; j++) {
112 (val_pt[j])[d] += diff * gradx[j];
113 val_wt[j] += diff * gradp[j];
116 (val_pt[k])[d] += diff * (sum -
dist_[d]->evaluatePDF(xpt));
119 for (
int k = 0; k < numSamples; k++) {
120 eg.setPoint(k,val_pt[k]);
121 eg.setWeight(k,val_wt[k]);
Provides the interface to evaluate objective functions.
Real valueCDF(const int dim, const Real loc, const SROMVector< Real > &x) const
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Defines the linear algebra or vector space interface.
PointwiseCDFObjective(const std::vector< ROL::Ptr< Distribution< Real > > > &dist, ROL::Ptr< BatchManager< Real > > &bman, const Real scale=1.e-2)
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Real hessVecCDF(std::vector< Real > &hvx, const int dim, const Real loc, const SROMVector< Real > &x, const SROMVector< Real > &v) const
Provides the std::vector implementation of the ROL::Vector interface.
ROL::Ptr< BatchManager< Real > > bman_
Real gradientCDF(std::vector< Real > &gradx, std::vector< Real > &gradp, const int dim, const Real loc, const SROMVector< Real > &x) const
std::vector< ROL::Ptr< Distribution< Real > > > dist_