44 #ifndef ROL_POINTWISECDFOBJECTIVE_H
45 #define ROL_POINTWISECDFOBJECTIVE_H
51 #include "ROL_Ptr.hpp"
59 std::vector<ROL::Ptr<Distribution<Real> > >
dist_;
60 ROL::Ptr<BatchManager<Real> >
bman_;
66 const int numSamples = x.getNumSamples();
67 Real val = 0., hs = 0., xpt = 0., xwt = 0.;
68 for (
int k = 0; k < numSamples; k++) {
69 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
76 Real
gradientCDF(std::vector<Real> &gradx, std::vector<Real> &gradp,
78 const int numSamples = x.getNumSamples();
79 gradx.resize(numSamples,0.); gradp.resize(numSamples,0.);
80 Real val = 0., hs = 0., xpt = 0., xwt = 0.;
81 for (
int k = 0; k < numSamples; k++) {
82 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
86 * std::exp(-std::pow((loc-xpt)/(
sqrt2_*scale_),2));
94 const int numSamples = x.getNumSamples();
95 hvx.resize(numSamples,0.);
96 Real val = 0., hs = 0., xpt = 0., xwt = 0., scale3 = std::pow(
scale_,3);
97 for (
int k = 0; k < numSamples; k++) {
98 xpt = (*x.getPoint(k))[dim]; xwt = x.getWeight(k);
102 * std::exp(-std::pow((loc-xpt)/(
sqrt2_*scale_),2)) * (loc-xpt);
110 const Real scale = 1.e-2)
116 const int dimension = ex.getDimension();
117 const int numSamples = ex.getNumSamples();
118 Real val = 0., diff = 0., xpt = 0., sum = 0.;
119 for (
int d = 0; d < dimension; d++) {
120 for (
int k = 0; k < numSamples; k++) {
121 xpt = (*ex.getPoint(k))[d];
123 val += std::pow(diff,2);
126 bman_->sumAll(&val,&sum,1);
133 const int dimension = ex.getDimension();
134 const int numSamples = ex.getNumSamples();
135 std::vector<Real> gradx(numSamples,0.), gradp(numSamples,0.);
136 Real diff = 0., xpt = 0., val = 0., sum = 0.;
137 std::vector<Real> val_wt(numSamples,0.), tmp(dimension,0.);
138 std::vector<std::vector<Real> > val_pt(numSamples,tmp);
139 for (
int d = 0; d < dimension; d++) {
140 for (
int k = 0; k < numSamples; k++) {
141 xpt = (*ex.getPoint(k))[d];
143 diff = (val-
dist_[d]->evaluateCDF(xpt));
145 for (
int j = 0; j < numSamples; j++) {
146 (val_pt[j])[d] += diff * gradx[j];
147 val_wt[j] += diff * gradp[j];
150 (val_pt[k])[d] += diff * (sum -
dist_[d]->evaluatePDF(xpt));
153 for (
int k = 0; k < numSamples; k++) {
154 eg.setPoint(k,val_pt[k]);
155 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_