10 #ifndef ROL_SAMPLEGENERATOR_HPP
11 #define ROL_SAMPLEGENERATOR_HPP
23 ROL::Ptr<BatchManager<Real> >
bman_;
28 void setPoints(std::vector<std::vector<Real> > &p) {
30 points_.assign(p.begin(),p.end());
69 Real gnms =
static_cast<Real
>(0);
71 return static_cast<int>(gnms);
78 virtual std::vector<Real>
getMyPoint(
const int i)
const {
87 return bman_->batchID();
91 return bman_->numBatches();
94 void sumAll(Real *input, Real *output,
int dim)
const {
95 bman_->sumAll(input, output, dim);
99 bman_->sumAll(input,output);
103 bman_->broadcast(input,cnt,root);
114 void print(
const std::string &filename =
"samples",
115 const int prec = 12)
const {
116 int width = prec + 5 + 4;
117 std::stringstream name;
118 name << filename <<
"_" <<
batchID() <<
".txt";
119 std::ofstream file(name.str().c_str());
120 if (file.is_open()) {
121 file << std::scientific << std::setprecision(prec);
125 for (
int j = 0; j < static_cast<int>(pt.size()); ++j) {
126 file << std::setw(width) << std::left << pt[j];
128 file << std::setw(width) << std::left << wt << std::endl;
133 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
134 ">>> (ROL::SampleGenerator::print): Unable to open file!");
virtual ~SampleGenerator()
void sumAll(Vector< Real > &input, Vector< Real > &output) const
virtual void update(const Vector< Real > &x)
virtual int numGlobalSamples(void) const
virtual void setSamples(bool inConstructor=false)
virtual std::vector< Real > getMyPoint(const int i) const
void broadcast(Real *input, int cnt, int root) const
virtual Real getMyWeight(const int i) const
Defines the linear algebra or vector space interface.
virtual int numMySamples(void) const
void sumAll(Real *input, Real *output, int dim) const
void print(const std::string &filename="samples", const int prec=12) const
ROL::Ptr< BatchManager< Real > > bman_
virtual void refine(void)
virtual Real computeError(std::vector< ROL::Ptr< Vector< Real > > > &vals, const Vector< Real > &x)
std::vector< Real > weights_
const ROL::Ptr< BatchManager< Real > > getBatchManager(void) const
SampleGenerator(const SampleGenerator< Real > &sampler)
std::vector< std::vector< Real > > points_
int numBatches(void) const
virtual Real computeError(std::vector< Real > &vals)
void setPoints(std::vector< std::vector< Real > > &p)
void setWeights(std::vector< Real > &w)
SampleGenerator(const ROL::Ptr< BatchManager< Real > > &bman)