Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
datagatherer.hpp
Go to the documentation of this file.
1 //contains the runinfo class
2 #include <vector>
3 #include <map>
4 #include <iostream>
5 #include <string>
6 #include <sstream>
7 #include <fstream>
8 #include <cmath>
9 #include <stdio.h>
10 #include <unistd.h>
11 #include <stdlib.h>
12 #include <errno.h>
13 #include <sys/wait.h>
14 #include <sys/stat.h>
15 #include <sys/types.h>
16 
17 
18 #include "random.hpp"
19 #include "para_aux_funcs.hpp"
20 
21 #include <boost/filesystem/operations.hpp>
22 #include <boost/filesystem/path.hpp>
23 #include <boost/progress.hpp>
24 #include <boost/regex.hpp>
25 
26 #include "tinyxml.h"
27 #include "point.hpp"
28 
29 #ifndef __DATAGATHERER_H__
30 #define __DATAGATHERER_H__
31 
32 #include "runinfo.hpp"
33 #include "xml_preferences.hpp"
34 #include "timing.hpp"
35 
36 
37 
47 class fileinfo {
48 
49 
50 public:
51 
55  parser_index = -11;
56  runningfile = "";
57  }
58 
59  int filesize;
60  int filecount;
62 
63  std::string runningfile;
64 
66 
67 
68 
69 
70 };
71 
72 
82 class datagatherer {
83 
84 
85 public:
86 
87 
88 
91  fundamental_dir = "";
92  numvariables = 0;
93  base_dir = "";
94  };
95 
97  datagatherer(boost::filesystem::path bdir, boost::filesystem::path fundir, int numvar){
98  this->base_dir = bdir;
99  this->fundamental_dir = fundir;
100  this->numvariables = numvar;
101  this->run_to_analyze = "";
102  };
103 
105  datagatherer(int numvar, boost::filesystem::path loc){
106  this->fundamental_dir = "";
107  this->numvariables = numvar;
108  this->run_to_analyze = loc;
109  };
110 
111 
112 
113  //data members
114 
115 
117  boost::filesystem::path fundamental_dir;
119  boost::filesystem::path base_dir;
122 
124  boost::filesystem::path run_to_analyze;
125 
127  std::vector < std::string > gather_savefiles;
129  std::vector < int > gather_parser_indices;
130 
131 
132  std::vector<std::string> ParamNames;
133  int numfiles;
134  boost::filesystem::path DataCollectedbase_dir;
137  int myid;
138  std::string real_filename;
139  std::map< std::string, fileinfo> slavemap; // a map between file names and fileinfo (as defined above)
141 
142 
143  int num_reals(){
144  return this->slavemap[this->real_filename].num_found_solns;
145  }
146 
147  void slave_init(){
148  ParamNames.clear();
149  slavemap.clear();
150  this->standardstep2 = 0;
151  this->numfiles = 0;
152  this->buffersize = this->newfilethreshold = -1;
153  this->myid = -1;
154  this->DataCollectedbase_dir = "";
155  }
156 
157 
158 
159 
160 
161  void add_file_to_save(std::string filename){
162 
163  fileinfo blankinfo;
164 
165  this->slavemap[filename] = blankinfo;
166  this->numfiles ++;
167 
168  this->slavemap[filename].parser_index = GetFileParserIndex(filename);
169 
170 
171  }
172 
173  boost::filesystem::path MakeTargetFilename(std::string filename);
174 
175 
176 
177 
178  void SlaveSetup(ProgSettings & paramotopy_settings,
179  runinfo & paramotopy_info,
180  int myid,
181  boost::filesystem::path called_dir);
182 
183 
184 
192  bool SlaveCollectAndWriteData(double *current_params,
193  ProgSettings & paramotopy_settings,
194  timer & process_timer);
195 
196 
204  void AppendOnlyPosReal(std::string orig_filename,
205  double *current_params,
206  ProgSettings & paramotopy_settings);
207 
208 
209 
210 
216  void AppendData(std::string orig_filename,
217  double *current_params);
218 
219 
220 
221 
222 
223  void WriteAllData();
224 
225 
226 
232  void WriteData(std::string outstring,
233  boost::filesystem::path target_file);
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 
246 
252  bool GatherDataForFails(std::vector< point > terminal_fails,
253  std::vector< point > & successful_resolves);
254 
256  void GatherDataFromMenu();
257 
262  std::vector< point > CompareInitial_Gathered(std::vector< point > terminal_fails,
263  std::vector< point > current_data);
264 
268  std::vector < point > GatherFinalizedDataToMemory(boost::filesystem::path folder_with_data);
269 
274  void WriteUnsuccessfulResolves(std::map< int, point> successful_resolves);
275 
279  std::map< int, point > ReadSuccessfulResolves();
280 
287  void CheckForResolvedFailedPoint(std::string file_to_gather,
288  int next_index,
289  std::string & next_data,
290  std::map< int, point> successful_resolves);
291 
296  boost::filesystem::path GetAvailableRuns();
297 
305  void CollectSpecificFiles(std::string file_to_gather,
306  std::vector < boost::filesystem::path > folders_with_data,
307  boost::filesystem::path run_to_analyze,
308  int parser_index,
309  bool mergefailed);
310 
314  std::vector< boost::filesystem::path > GetFoldersForData(boost::filesystem::path dir);
315 
321  void IncrementOutputFolder(boost::filesystem::path & output_folder_name,
322  boost::filesystem::path base_output_folder_name,
323  int & output_folder_index);
324 
331  void MergeFolders(std::string file_to_gather,
332  boost::filesystem::path left_folder,
333  boost::filesystem::path right_folder,
334  boost::filesystem::path output_folder_name,
335  int parser_index);
336 
345  void finalize_run_to_file(std::string file_to_gather, boost::filesystem::path source_folder,
346  boost::filesystem::path base_output_folder_name, int parser_index, bool mergefailed);
347 
357  void rest_of_files(std::ifstream & datafile, std::string & output_buffer, std::ofstream & outputfile,
358  std::vector < boost::filesystem::path > filelist, int file_index, int parser_index);
359 
366  bool endoffile_stuff(std::ifstream & datafile, int & file_index, std::vector < boost::filesystem::path > filelist);
367 
368 
374  bool ReadPoint(std::ifstream & fin, std::string & data, int parser_index);
382  bool ReadPoint(std::ifstream & fin, int & next_index, std::string & data, int parser_index);
383 
388  std::string ParseSolutionsFile(std::ifstream & fin);
389 
395  std::vector< std::vector < std::pair< std::string, std::string > > > ParseSolutionsFile_ActualSolutions(std::ifstream & fin);
396 
402  std::string ParseFailedPaths(std::ifstream & fin);
403 
404 
405 
406 
407 private:
408 
409 
410 
411 };
412 
413 
415 void DataManagementMainMenu(runinfo & paramotopy_info);
416 
417 
418 
419 #endif
420 
421 
422 
423 
void MergeFolders(std::string file_to_gather, boost::filesystem::path left_folder, boost::filesystem::path right_folder, boost::filesystem::path output_folder_name, int parser_index)
std::map< int, point > ReadSuccessfulResolves()
std::vector< int > gather_parser_indices
bool ReadPoint(std::ifstream &fin, std::string &data, int parser_index)
void GatherDataFromMenu()
Class for caching/storing gathered temp output files.
std::vector< point > GatherFinalizedDataToMemory(boost::filesystem::path folder_with_data)
std::map< std::string, fileinfo > slavemap
boost::filesystem::path DataCollectedbase_dir
std::vector< std::string > ParamNames
boost::filesystem::path GetAvailableRuns()
datagatherer(int numvar, boost::filesystem::path loc)
std::string real_filename
void DataManagementMainMenu(runinfo &paramotopy_info)
std::vector< boost::filesystem::path > GetFoldersForData(boost::filesystem::path dir)
std::string runningfile
file text
void AppendOnlyPosReal(std::string orig_filename, double *current_params, ProgSettings &paramotopy_settings)
std::vector< std::string > gather_savefiles
bool GatherDataForFails(std::vector< point > terminal_fails, std::vector< point > &successful_resolves)
std::string ParseFailedPaths(std::ifstream &fin)
the parser for the failed_paths file type, which is output from bertini.
void rest_of_files(std::ifstream &datafile, std::string &output_buffer, std::ofstream &outputfile, std::vector< boost::filesystem::path > filelist, int file_index, int parser_index)
std::vector< point > CompareInitial_Gathered(std::vector< point > terminal_fails, std::vector< point > current_data)
int num_found_solns
the most recent number of found solutions.
boost::filesystem::path MakeTargetFilename(std::string filename)
Definition: datagatherer.cpp:9
int filesize
number of characters.
std::vector< std::vector< std::pair< std::string, std::string > > > ParseSolutionsFile_ActualSolutions(std::ifstream &fin)
bool SlaveCollectAndWriteData(double *current_params, ProgSettings &paramotopy_settings, timer &process_timer)
void CollectSpecificFiles(std::string file_to_gather, std::vector< boost::filesystem::path > folders_with_data, boost::filesystem::path run_to_analyze, int parser_index, bool mergefailed)
void WriteData(std::string outstring, boost::filesystem::path target_file)
void IncrementOutputFolder(boost::filesystem::path &output_folder_name, boost::filesystem::path base_output_folder_name, int &output_folder_index)
boost::filesystem::path base_dir
bool endoffile_stuff(std::ifstream &datafile, int &file_index, std::vector< boost::filesystem::path > filelist)
void SlaveSetup(ProgSettings &paramotopy_settings, runinfo &paramotopy_info, int myid, boost::filesystem::path called_dir)
void add_file_to_save(std::string filename)
std::string ParseSolutionsFile(std::ifstream &fin)
void CheckForResolvedFailedPoint(std::string file_to_gather, int next_index, std::string &next_data, std::map< int, point > successful_resolves)
int parser_index
the parser switch index.
void WriteAllData()
void finalize_run_to_file(std::string file_to_gather, boost::filesystem::path source_folder, boost::filesystem::path base_output_folder_name, int parser_index, bool mergefailed)
Class for gathering data, from failed path analysis, and from completed runs.
void WriteUnsuccessfulResolves(std::map< int, point > successful_resolves)
A class that stores the general program settings of Paramotopy.
int filecount
current index of file. like 0 in real_solutions0
A class for the input file parser.
Definition: runinfo.hpp:41
void AppendData(std::string orig_filename, double *current_params)
int GetFileParserIndex(std::string filename)
boost::filesystem::path fundamental_dir
datagatherer(boost::filesystem::path bdir, boost::filesystem::path fundir, int numvar)
Capable of timing arbitrary categories of processes, using a map of timer_data's. ...
Definition: timing.hpp:71
boost::filesystem::path run_to_analyze