44 #ifndef ROL_USERINPUTGENERATOR_HPP
45 #define ROL_USERINPUTGENERATOR_HPP
60 void sample(
const std::string &file_pt,
61 const std::string &file_wt,
67 std::fstream input_pt;
68 input_pt.open(file_pt.c_str(),std::ios::in);
69 std::fstream input_wt;
70 input_wt.open(file_wt.c_str(),std::ios::in);
71 if ( !input_pt.is_open() || !input_wt.is_open() ) {
72 if ( !input_pt.is_open() ) {
73 if ( bman->batchID() == 0 ) {
74 std::cout <<
"CANNOT OPEN " << file_pt.c_str() <<
"\n";
77 if ( !input_wt.is_open() ) {
78 if ( bman->batchID() == 0 ) {
79 std::cout <<
"CANNOT OPEN " << file_wt.c_str() <<
"\n";
84 std::vector<std::vector<Real> > pt(n);
85 std::vector<Real> wt(n,0.0);
86 std::vector<Real> point(dim,0.0);;
87 for (
int i = 0; i < n; i++) {
88 for (
int j = 0; j <
dim; j++) {
95 int rank = bman->batchID();
96 int nProc = bman->numBatches();
104 std::vector<std::vector<Real> > my_pt(N);
105 std::vector<Real> my_wt(N,0.0);
107 for (
int i = 0; i < N; i++) {
108 index = i*nProc + rank;
109 my_pt[i] = pt[index];
110 my_wt[i] = wt[index];
123 ROL::ParameterList &list
124 = parlist.sublist(
"SOL").sublist(
"Sample Generator").sublist(
"User Input");
125 if ( list.isParameter(
"Points File") &&
126 list.isParameter(
"Weights File") &&
127 list.isParameter(
"Number of Samples") &&
128 list.isParameter(
"Dimension") ) {
129 std::string file_pt = list.get(
"Points File Name",
"points.txt");
130 std::string file_wt = list.get(
"Weights File Name",
"weights.txt");
131 int n = list.get(
"Number of Samples",100);
132 int dim = list.get(
"Dimension",4);
133 sample(file_pt,file_wt,n,dim,bman);
136 ROL_TEST_FOR_EXCEPTION(
true,std::invalid_argument,
137 ">>> (ROL::UserInputGenerator): ParameterList does not contain sufficient information.");
142 const std::string file_wt,
147 sample(file_pt,file_wt,n,dim,bman);
void setPoints(std::vector< std::vector< Real > > &p)
void setWeights(std::vector< Real > &w)