44 #ifndef ROL_SAMPLEGENERATOR_HPP
45 #define ROL_SAMPLEGENERATOR_HPP
57 ROL::Ptr<BatchManager<Real> >
bman_;
62 void setPoints(std::vector<std::vector<Real> > &p) {
64 points_.assign(p.begin(),p.end());
103 Real gnms =
static_cast<Real
>(0);
105 return static_cast<int>(gnms);
121 return bman_->batchID();
125 return bman_->numBatches();
129 bman_->sumAll(input, output, dim);
133 bman_->sumAll(input,output);
137 bman_->broadcast(input,cnt,root);
148 void print(
const std::string &filename =
"samples",
149 const int prec = 12)
const {
150 int width = prec + 5 + 4;
151 std::stringstream name;
152 name << filename <<
"_" <<
batchID() <<
".txt";
153 std::ofstream file(name.str().c_str());
154 if (file.is_open()) {
155 file << std::scientific << std::setprecision(prec);
159 for (
int j = 0; j < static_cast<int>(pt.size()); ++j) {
160 file << std::setw(width) << std::left << pt[j];
162 file << std::setw(width) << std::left << wt << std::endl;
167 ROL_TEST_FOR_EXCEPTION(
true, std::invalid_argument,
168 ">>> (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)