Paramotopy
parallel parameter homotopy through bertini
|
Class for gathering data, from failed path analysis, and from completed runs. More...
#include <datagatherer.hpp>
Public Member Functions | |
datagatherer () | |
datagatherer (boost::filesystem::path bdir, boost::filesystem::path fundir, int numvar) | |
datagatherer (int numvar, boost::filesystem::path loc) | |
int | num_reals () |
void | slave_init () |
void | add_file_to_save (std::string filename) |
boost::filesystem::path | MakeTargetFilename (std::string filename) |
void | SlaveSetup (ProgSettings ¶motopy_settings, runinfo ¶motopy_info, int myid, boost::filesystem::path called_dir) |
bool | SlaveCollectAndWriteData (double *current_params, ProgSettings ¶motopy_settings, timer &process_timer) |
void | AppendOnlyPosReal (std::string orig_filename, double *current_params, ProgSettings ¶motopy_settings) |
void | AppendData (std::string orig_filename, double *current_params) |
void | WriteAllData () |
void | WriteData (std::string outstring, boost::filesystem::path target_file) |
bool | GatherDataForFails (std::vector< point > terminal_fails, std::vector< point > &successful_resolves) |
void | GatherDataFromMenu () |
std::vector< point > | CompareInitial_Gathered (std::vector< point > terminal_fails, std::vector< point > current_data) |
std::vector< point > | GatherFinalizedDataToMemory (boost::filesystem::path folder_with_data) |
void | WriteUnsuccessfulResolves (std::map< int, point > successful_resolves) |
std::map< int, point > | ReadSuccessfulResolves () |
void | CheckForResolvedFailedPoint (std::string file_to_gather, int next_index, std::string &next_data, std::map< int, point > successful_resolves) |
boost::filesystem::path | GetAvailableRuns () |
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) |
std::vector < boost::filesystem::path > | GetFoldersForData (boost::filesystem::path dir) |
void | IncrementOutputFolder (boost::filesystem::path &output_folder_name, boost::filesystem::path base_output_folder_name, int &output_folder_index) |
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) |
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) |
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) |
bool | endoffile_stuff (std::ifstream &datafile, int &file_index, std::vector< boost::filesystem::path > filelist) |
bool | ReadPoint (std::ifstream &fin, std::string &data, int parser_index) |
bool | ReadPoint (std::ifstream &fin, int &next_index, std::string &data, int parser_index) |
std::string | ParseSolutionsFile (std::ifstream &fin) |
std::vector< std::vector < std::pair< std::string, std::string > > > | ParseSolutionsFile_ActualSolutions (std::ifstream &fin) |
std::string | ParseFailedPaths (std::ifstream &fin) |
the parser for the failed_paths file type, which is output from bertini. More... | |
Public Attributes | |
boost::filesystem::path | fundamental_dir |
boost::filesystem::path | base_dir |
int | numvariables |
boost::filesystem::path | run_to_analyze |
std::vector< std::string > | gather_savefiles |
std::vector< int > | gather_parser_indices |
std::vector< std::string > | ParamNames |
int | numfiles |
boost::filesystem::path | DataCollectedbase_dir |
int | buffersize |
int | newfilethreshold |
int | myid |
std::string | real_filename |
std::map< std::string, fileinfo > | slavemap |
int | standardstep2 |
Class for gathering data, from failed path analysis, and from completed runs.
contains methods for gathering data from the bfiles_filename/run0/step2/DataCollected/c0 folders (or in another respective location).
Definition at line 82 of file datagatherer.hpp.
|
inline |
default constructor
Definition at line 90 of file datagatherer.hpp.
References base_dir, fundamental_dir, and numvariables.
|
inline |
constructor with instantiation of base_dir, fundamental_dir, and numvar. intended for use in the collection of data for a complete run, including merging of failed path successes.
Definition at line 97 of file datagatherer.hpp.
References base_dir, fundamental_dir, numvariables, and run_to_analyze.
|
inline |
constructor with instantiation of numvariables, and run_to_analyze. intended for use in failed path analysis
Definition at line 105 of file datagatherer.hpp.
References fundamental_dir, numvariables, and run_to_analyze.
|
inline |
Definition at line 161 of file datagatherer.hpp.
References GetFileParserIndex(), and fileinfo::parser_index.
Referenced by SlaveSetup().
void datagatherer::AppendData | ( | std::string | orig_filename, |
double * | current_params | ||
) |
creates a string to append read-in data to the running file.
orig_filename | Name of the data file to be read. |
current_parameter_values | Current parameter values. |
Definition at line 259 of file datagatherer.cpp.
References ParamNames, and slavemap.
Referenced by SlaveCollectAndWriteData().
void datagatherer::AppendOnlyPosReal | ( | std::string | orig_filename, |
double * | current_params, | ||
ProgSettings & | paramotopy_settings | ||
) |
sorts the input file for positive real solutions creates a string to append read-in data to the running file.
orig_filename | Name of the data file to be read. |
current_parameter_values | Current parameter values. |
paramotopy_settings | the settings structure, passed by reference |
Definition at line 155 of file datagatherer.cpp.
References numvariables, ParamNames, ParseSolutionsFile_ActualSolutions(), ProgSettings::settings, and slavemap.
Referenced by SlaveCollectAndWriteData().
void datagatherer::CheckForResolvedFailedPoint | ( | std::string | file_to_gather, |
int | next_index, | ||
std::string & | next_data, | ||
std::map< int, point > | successful_resolves | ||
) |
file_to_gather | The name of the file we are sorting and merging. |
next_index | The index. Used in lookup in the map successful_resolves. |
next_data | A mutable string containing the data. If successful_resolves has a point with the same index, and it was successfully resolved, we replace the next_data with that in the map. |
successful_resolves | Map of points containing the data produced by failed path analysis |
Definition at line 882 of file datagatherer.cpp.
Referenced by finalize_run_to_file().
void datagatherer::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 | ||
) |
Main loop for gathering a particular file in a particular completed run.
file_to_gather | The name of the bertini output file to gather. |
folders_with_data | Vector with the names of the folders containing the data. |
run_to_analyze | The name of the run. |
parser_index | The index corresponding to the filename. Different file types have different parsers. |
mergefailed | Bool determining whether to merge data from failed path analysis. This is false if collecting from a run DURING failed path analysis (it would break things), but is true if doing a menu collection. |
Definition at line 521 of file datagatherer.cpp.
References finalize_run_to_file(), IncrementOutputFolder(), MergeFolders(), and run_to_analyze.
Referenced by GatherDataForFails(), and GatherDataFromMenu().
std::vector< point > datagatherer::CompareInitial_Gathered | ( | std::vector< point > | terminal_fails, |
std::vector< point > | current_data | ||
) |
Compares initially run data to re-solved during failed path analysis. Reads in data from the successful_resolves file.
Definition at line 376 of file datagatherer.cpp.
Referenced by GatherDataForFails().
bool datagatherer::endoffile_stuff | ( | std::ifstream & | datafile, |
int & | file_index, | ||
std::vector< boost::filesystem::path > | filelist | ||
) |
Reads the remainder of a file into memory, after a point at which we are certain there is not more sorting to be done.
datafile | The data file being read. |
file_index | The integer index of the file being read. |
filelist | The vector containing the list of the files to read. |
Definition at line 1206 of file datagatherer.cpp.
Referenced by MergeFolders().
void datagatherer::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 | ||
) |
Write the total collected data to a single file, and verify that the data is in order.
file_to_gather | The name of the Bertini output file we are gathering currently. |
source_folder | The name of the source folder. |
base_output_folder_name. | The name of the bfiles_filename/run#/gathered_data. We append with /finalized. |
parser_index | The parser choice to use. Corresponds to file_to_gather. |
mergefailed | Boolean indicating whether the data checks out. |
Definition at line 727 of file datagatherer.cpp.
References CheckForResolvedFailedPoint(), FindFiles(), ReadPoint(), ReadSuccessfulResolves(), and WriteUnsuccessfulResolves().
Referenced by CollectSpecificFiles().
bool datagatherer::GatherDataForFails | ( | std::vector< point > | terminal_fails, |
std::vector< point > & | successful_resolves | ||
) |
outermost method for gathering data during failure analysis mode. keeps track of which points were successful (or not).
terminal_fails | vector containing the indices of the attempted resolves. |
successful_resolves | Vector of points for holding the successful data. |
Definition at line 339 of file datagatherer.cpp.
References CollectSpecificFiles(), CompareInitial_Gathered(), gather_parser_indices, gather_savefiles, GatherFinalizedDataToMemory(), GetFilesToParse(), GetFoldersForData(), and run_to_analyze.
Referenced by failinfo::find_successful_resolves().
void datagatherer::GatherDataFromMenu | ( | ) |
outermost method for gathering data from main menu. no input necessary
Definition at line 485 of file datagatherer.cpp.
References CollectSpecificFiles(), gather_parser_indices, gather_savefiles, GetAvailableRuns(), GetFilesToParse(), GetFoldersForData(), and run_to_analyze.
Referenced by DataManagementMainMenu().
std::vector< point > datagatherer::GatherFinalizedDataToMemory | ( | boost::filesystem::path | folder_with_data | ) |
gather the data from a completed, gathered, finalized step2, to memory.
folder_with_data | Path having data in it. |
Definition at line 417 of file datagatherer.cpp.
References point::collected_data, gather_parser_indices, gather_savefiles, point::index, and ReadPoint().
Referenced by GatherDataForFails().
boost::filesystem::path datagatherer::GetAvailableRuns | ( | ) |
search for completed runs with this filename.
Definition at line 909 of file datagatherer.cpp.
References FindDirectories(), fundamental_dir, get_int_choice(), run_to_analyze, and TestIfFinished().
Referenced by GatherDataFromMenu().
std::vector< boost::filesystem::path > datagatherer::GetFoldersForData | ( | boost::filesystem::path | dir | ) |
Read the folders containing the data. The folder names are contained in a plain text file.
dir | String containing the name of the directory in which to look. |
Definition at line 1452 of file datagatherer.cpp.
Referenced by GatherDataForFails(), and GatherDataFromMenu().
void datagatherer::IncrementOutputFolder | ( | boost::filesystem::path & | output_folder_name, |
boost::filesystem::path | base_output_folder_name, | ||
int & | output_folder_index | ||
) |
A lower-level function. Increases the output folder index by 1, during a merge.
output_folder_name | MUTABLE string to hold the new folder name. |
base_output_folder_name | The string from which we build output_folder_name |
output_folder_index | MUTABLE integer, which herein is incremented, and contatenated to base_... to make the output_folder_name. |
Definition at line 1433 of file datagatherer.cpp.
Referenced by CollectSpecificFiles().
boost::filesystem::path datagatherer::MakeTargetFilename | ( | std::string | filename | ) |
Definition at line 9 of file datagatherer.cpp.
References DataCollectedbase_dir, and slavemap.
Referenced by SlaveCollectAndWriteData(), and WriteAllData().
void datagatherer::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 | ||
) |
A lower-level function. Actually merges two folders, left and right, into the output_folder_name, using the parser determined by parser_index.
file_to_gather | The name of the bertini output file we are gathering. |
left_folder | The name of the left folder currently being merged. |
output_folder_name | The name of the folder into which to place the merged data. |
parser_index | The index of the parser to use on this filetype. |
Definition at line 953 of file datagatherer.cpp.
References endoffile_stuff(), FindFiles(), ReadPoint(), and rest_of_files().
Referenced by CollectSpecificFiles().
|
inline |
Definition at line 143 of file datagatherer.hpp.
References real_filename.
Referenced by slave_process::LoopSearch().
std::string datagatherer::ParseFailedPaths | ( | std::ifstream & | fin | ) |
the parser for the failed_paths file type, which is output from bertini.
function for parsing the failed_paths file (just one instance of it) gets called repeatedly to see if any points had failed paths (each point has one failed_paths file)
fin | The handle to the file. |
Definition at line 1405 of file datagatherer.cpp.
References numvariables.
Referenced by ReadPoint().
std::string datagatherer::ParseSolutionsFile | ( | std::ifstream & | fin | ) |
function for parsing ***_solutions files, as output from bertini.
fin | The file handle. |
Definition at line 1357 of file datagatherer.cpp.
References numvariables.
Referenced by ReadPoint().
std::vector< std::vector< std::pair< std::string, std::string > > > datagatherer::ParseSolutionsFile_ActualSolutions | ( | std::ifstream & | fin | ) |
Function for getting the solutions and parameter values, for sorting
fin |
Definition at line 1300 of file datagatherer.cpp.
References numvariables.
Referenced by AppendOnlyPosReal().
bool datagatherer::ReadPoint | ( | std::ifstream & | fin, |
std::string & | data, | ||
int | parser_index | ||
) |
function for parsing ***_solutions files, as output from bertini.
fin | The file handle. |
data | The string to which to read the data. |
parser_index | The parser to use. |
Definition at line 1227 of file datagatherer.cpp.
References ParseFailedPaths(), and ParseSolutionsFile().
Referenced by finalize_run_to_file(), GatherFinalizedDataToMemory(), MergeFolders(), ReadSuccessfulResolves(), and rest_of_files().
bool datagatherer::ReadPoint | ( | std::ifstream & | fin, |
int & | next_index, | ||
std::string & | data, | ||
int | parser_index | ||
) |
function for parsing ***_solutions files, as output from bertini.
fin | The file handle. |
next_index | The index of the point just read. |
data | The string to which to read the data. |
parser_index | The parser to use. |
Definition at line 1261 of file datagatherer.cpp.
References ParseFailedPaths(), and ParseSolutionsFile().
std::map< int, point > datagatherer::ReadSuccessfulResolves | ( | ) |
Reads data produced by failed path analysis into memory.
Definition at line 607 of file datagatherer.cpp.
References base_dir, point::collected_data, point::index, and ReadPoint().
Referenced by finalize_run_to_file(), and failinfo::RecoverProgress().
void datagatherer::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 | ||
) |
While merging, we will get to a point when there is no more sorting to do. The rest of the data is in set of files, and in order, so all that remains is to copy the rest of the file in to the output file. This function does that.
datafile | The stream for reading the data. |
output_buffer | The string we read into. |
outputfile | The output stream we write to. |
filelist | Vector containing the names of the files to be read. |
file_index | Index integer of the file currently being read. |
parser_index | The integer index of the parser being used. |
Definition at line 1152 of file datagatherer.cpp.
References ReadPoint().
Referenced by MergeFolders().
|
inline |
Definition at line 147 of file datagatherer.hpp.
Referenced by SlaveSetup().
bool datagatherer::SlaveCollectAndWriteData | ( | double * | current_params, |
ProgSettings & | paramotopy_settings, | ||
timer & | process_timer | ||
) |
reads data from bertini output files, and writes it to files in DataCollected folder, if the threshold is big enough
linenumber | Parameter point index |
AllParams | Current parameter values. |
paramotopy_settings | the settings structure, passed by reference |
process_timer | Timer object for collecting timing data. |
Definition at line 83 of file datagatherer.cpp.
References timer::add_time(), AppendData(), AppendOnlyPosReal(), buffersize, MakeTargetFilename(), timer::press_start(), ProgSettings::settings, slavemap, and WriteData().
Referenced by slave_process::LoopBasic(), and slave_process::LoopSearch().
void datagatherer::SlaveSetup | ( | ProgSettings & | paramotopy_settings, |
runinfo & | paramotopy_info, | ||
int | myid, | ||
boost::filesystem::path | called_dir | ||
) |
Definition at line 23 of file datagatherer.cpp.
References add_file_to_save(), buffersize, DataCollectedbase_dir, runinfo::location, myid, newfilethreshold, runinfo::numvariables, numvariables, runinfo::ParameterNames, ParamNames, real_filename, ProgSettings::settings, slave_init(), and standardstep2.
Referenced by slave_process::slave_main().
void datagatherer::WriteAllData | ( | ) |
Definition at line 292 of file datagatherer.cpp.
References MakeTargetFilename(), slavemap, and WriteData().
Referenced by slave_process::LoopBasic(), and slave_process::LoopSearch().
void datagatherer::WriteData | ( | std::string | outstring, |
boost::filesystem::path | target_file | ||
) |
Write data to disk.
outstring | The file to write |
target_file | name of the file to write to. |
Definition at line 303 of file datagatherer.cpp.
References ParamNames.
Referenced by SlaveCollectAndWriteData(), and WriteAllData().
void datagatherer::WriteUnsuccessfulResolves | ( | std::map< int, point > | successful_resolves | ) |
write persistent fails to disk.
successful_resolves | Map of points and collected data. If has no data, then persistently failed through failed path analysis. |
Definition at line 703 of file datagatherer.cpp.
References base_dir.
Referenced by finalize_run_to_file().
boost::filesystem::path datagatherer::base_dir |
base directory, including the run number. – bfiles_filename/run0
Definition at line 119 of file datagatherer.hpp.
Referenced by datagatherer(), ReadSuccessfulResolves(), and WriteUnsuccessfulResolves().
int datagatherer::buffersize |
Definition at line 135 of file datagatherer.hpp.
Referenced by SlaveCollectAndWriteData(), and SlaveSetup().
boost::filesystem::path datagatherer::DataCollectedbase_dir |
Definition at line 134 of file datagatherer.hpp.
Referenced by MakeTargetFilename(), and SlaveSetup().
boost::filesystem::path datagatherer::fundamental_dir |
fundamental directory – bfiles_filename
Definition at line 109 of file datagatherer.hpp.
Referenced by datagatherer(), and GetAvailableRuns().
std::vector< int > datagatherer::gather_parser_indices |
index for parser choice. different filetypes use different parsers
Definition at line 129 of file datagatherer.hpp.
Referenced by GatherDataForFails(), GatherDataFromMenu(), and GatherFinalizedDataToMemory().
std::vector< std::string > datagatherer::gather_savefiles |
names of files to gather
Definition at line 127 of file datagatherer.hpp.
Referenced by GatherDataForFails(), GatherDataFromMenu(), and GatherFinalizedDataToMemory().
int datagatherer::myid |
Definition at line 137 of file datagatherer.hpp.
Referenced by SlaveSetup().
int datagatherer::newfilethreshold |
Definition at line 136 of file datagatherer.hpp.
Referenced by SlaveSetup().
int datagatherer::numfiles |
Definition at line 133 of file datagatherer.hpp.
int datagatherer::numvariables |
number of variables in the problem
Definition at line 121 of file datagatherer.hpp.
Referenced by AppendOnlyPosReal(), datagatherer(), ParseFailedPaths(), ParseSolutionsFile(), ParseSolutionsFile_ActualSolutions(), and SlaveSetup().
std::vector<std::string> datagatherer::ParamNames |
Definition at line 132 of file datagatherer.hpp.
Referenced by AppendData(), AppendOnlyPosReal(), SlaveSetup(), and WriteData().
std::string datagatherer::real_filename |
Definition at line 138 of file datagatherer.hpp.
Referenced by num_reals(), and SlaveSetup().
boost::filesystem::path datagatherer::run_to_analyze |
the run to collect data from
Definition at line 124 of file datagatherer.hpp.
Referenced by CollectSpecificFiles(), datagatherer(), GatherDataForFails(), GatherDataFromMenu(), and GetAvailableRuns().
std::map< std::string, fileinfo> datagatherer::slavemap |
Definition at line 139 of file datagatherer.hpp.
Referenced by AppendData(), AppendOnlyPosReal(), MakeTargetFilename(), SlaveCollectAndWriteData(), and WriteAllData().
int datagatherer::standardstep2 |
Definition at line 140 of file datagatherer.hpp.
Referenced by SlaveSetup().