10 std::cout <<
"\n\nthe run for " << paramotopy_info.
inputfilename <<
" appears not completed. please complete the run." << std::endl;
23 boost::filesystem::path makeme = paramotopy_info.
base_dir;
24 makeme /=
"failure_analysis";
25 boost::filesystem::create_directory(makeme);
32 std::cout <<
"\nCurrently " << this->
totalfails <<
" points with path failures.\n";
33 std::stringstream menu;
34 menu <<
"\n\nPath Failure Menu:\n\n"
35 <<
"1) ReRun Failed Paths\n"
36 <<
"2) Clear Failed Path Data (start over)\n"
37 <<
"3) Change path failure settings (resets tolerance tightening)\n"
38 <<
"4) Report failed paths to screen\n"
49 std::cout <<
"exiting path failure\n";
92 boost::filesystem::path dirtosearch = paramotopy_info.
base_dir;
93 dirtosearch /=
"failure_analysis";
94 std::vector< boost::filesystem::path > found_runs =
FindDirectories(dirtosearch,
"^pass");
96 for (
int ii = 0; ii<int(found_runs.size()); ++ii) {
97 boost::filesystem::remove_all(found_runs[ii]);
136 boost::filesystem::path dirtosearch = paramotopy_info.
base_dir;
137 std::vector< boost::filesystem::path > failure_paths =
FindDirectories(dirtosearch,
"^failure_analysis");
138 if (failure_paths.size()==0) {
145 dirtosearch /=
"failure_analysis";
147 std::vector< boost::filesystem::path > found_runs =
FindDirectories(dirtosearch,
"^pass");
149 if (found_runs.size()==0) {
156 int highestiteration = -1;
157 for (
int ii = 0; ii<int(found_runs.size()); ++ii) {
158 std::cout <<
"found " << found_runs[ii].string() << std::endl;
159 boost::filesystem::path tmppath = found_runs[ii];
161 std::ifstream fin(tmppath.c_str());
164 std::stringstream ss;
172 std::cout <<
"removing folder " << found_runs[ii] <<
" because was not finished..." << std::endl;
173 boost::filesystem::remove_all(found_runs[ii]);
177 if (tmpiteration > highestiteration){
178 highestiteration = tmpiteration;
218 std::map< int, std::vector< point> >::iterator iter;
220 std::cout <<
"initial:" << std::endl;
222 std::cout << iter->first << std::endl;
224 for (
int ii=0; ii<int(iter->second.size()); ++ii) {
225 std::cout << iter->second[ii].index << std::endl;
229 std::cout <<
"terminal:" << std::endl;
231 for (
int ii=0; ii<int(iter->second.size()); ++ii) {
232 std::cout << iter->second[ii].index << std::endl;
236 std::cout <<
"master:" << std::endl;
249 std::map< int, point >::iterator iter;
250 std::vector< point > tmpcrap;
252 for (iter=successful_resolves.begin(); iter!= successful_resolves.end(); iter++) {
256 tmpcrap.push_back(iter->second);
260 std::sort(tmpcrap.begin(),tmpcrap.end());
274 paramotopy_info.
location /=
"failure_analysis/pass";
275 std::stringstream ss;
277 paramotopy_info.
location += ss.str();
298 for (
int mm=0; (mm< paramotopy_settings.
settings[
"PathFailure"][
"maxautoiterations"].intvalue) && (
totalfails>0); ++mm) {
302 std::cout <<
"analyzing failed paths, iteration " << mm+1 <<
" of " << paramotopy_settings.
settings[
"PathFailure"][
"maxautoiterations"].intvalue <<
"\n";
305 boost::filesystem::create_directory(paramotopy_info.
location);
307 boost::filesystem::path openme = paramotopy_info.
location;
309 std::ofstream fout(openme.c_str());
315 std::cout <<
"writing modified paramotopy\n";
319 if (paramotopy_settings.
settings[
"PathFailure"][
"tightentolerances"].intvalue==1){
325 boost::filesystem::path makeme = paramotopy_info.
location;
326 boost::filesystem::create_directories(makeme/=
"step1");
328 if (paramotopy_settings.
settings[
"PathFailure"][
"newrandommethod"].intvalue==1) {
329 std::cout <<
"doing new step one\n";
340 std::string previous_start_file =
"";
341 if (paramotopy_settings.
settings[
"PathFailure"][
"newrandommethod"].intvalue==1) {
342 previous_start_file = paramotopy_settings.
settings[
"mode"][
"startfilename"].value();
343 paramotopy_settings.
setValue(
"mode",
"startfilename",std::string(
"nonsingular_solutions"));
348 if (terminationint==0) {
349 std::cerr <<
"have 0 points to solve for some reason." << std::endl;
353 int previous_mainmode = paramotopy_settings.
settings[
"mode"][
"main_mode"].intvalue;
354 int previous_num_procs = paramotopy_settings.
settings[
"parallelism"][
"numprocs"].intvalue;
355 int previous_numfilesatatime = paramotopy_settings.
settings[
"parallelism"][
"numfilesatatime"].intvalue;
357 if (terminationint+1 < previous_num_procs) {
358 paramotopy_settings.
setValue(
"parallelism",
"numprocs",terminationint+1);
359 paramotopy_settings.
setValue(
"parallelism",
"numfilesatatime",1);
362 double fractpart, intpart;
364 fractpart = modf ( (terminationint+1) / previous_num_procs , &intpart);
366 int numprocstouse = std::max(
double(1),intpart/5);
367 paramotopy_settings.
setValue(
"parallelism",
"numfilesatatime",numprocstouse);
370 paramotopy_settings.
setValue(
"mode",
"main_mode",
int(0));
385 if (paramotopy_settings.
settings[
"PathFailure"][
"newrandommethod"].intvalue==1) {
386 paramotopy_settings.
setValue(
"mode",
"startfilename",std::string(previous_start_file));
389 paramotopy_settings.
setValue(
"mode",
"main_mode",previous_mainmode);
390 paramotopy_settings.
setValue(
"parallelism",
"numprocs",previous_num_procs);
391 paramotopy_settings.
setValue(
"parallelism",
"numfilesatatime",previous_numfilesatatime);
395 boost::filesystem::path path_to_check = paramotopy_info.
location;
398 std::cout <<
"it appears the run failed. removing files." << std::endl;
412 this->current_iteration++;
427 boost::filesystem::path file_to_write_to = paramotopy_info.
base_dir;
430 file_to_write_to /=
"failure_analysis/successful_resolves";
432 std::ofstream outputfile(file_to_write_to.string().c_str());
434 if (!outputfile.is_open()) {
435 std::cerr <<
"failed to open " << file_to_write_to.string() <<
" to write resolve data" << std::endl;
446 std::map<std::string, std::string>::iterator iter;
447 std::stringstream namelist;
448 std::stringstream datalist;
451 namelist << iter->first <<
" ";
452 datalist << iter->second;
454 outputfile << namelist.str() <<
"\n";
455 outputfile << datalist.str();
461 boost::filesystem::path blabla = paramotopy_info.
base_dir;
462 blabla /=
"failure_analysis/resolved_file";
464 std::ofstream outputfile2(blabla.string().c_str());
465 outputfile2 << file_to_write_to.string();
476 std::vector< point > current_successful_resolves;
481 std::vector< int > relative_indices, final_indices;
482 relative_indices.resize(current_successful_resolves.size());
483 final_indices.resize(current_successful_resolves.size());
486 for (
int ii=0; ii<int(current_successful_resolves.size()); ++ii) {
487 int failed_again_index = current_successful_resolves[ii].index;
489 if (current_iteration == 0){
490 relative_indices[ii] = failed_again_index;
493 for (
int jj = current_iteration; jj>=0; --jj) {
494 failed_again_index =
initial_fails[jj][failed_again_index].index;
496 relative_indices[ii] = failed_again_index;
499 final_indices[ii] = failed_again_index;
516 for (
int ii=0; ii<int( current_successful_resolves.size() ); ++ii) {
517 if (
master_fails[relative_indices[ii]].index != final_indices[ii]) {
518 std::cerr <<
"mismatch in indices when commiting to master list" << std::endl;
521 master_fails[relative_indices[ii]].collected_data = current_successful_resolves[ii].collected_data;
534 std::cout <<
current_iteration <<
" congratulations, your run had 0 path failures total!\n";
540 int premie = std::cout.precision();
541 std::cout << std::setiosflags(std::ios::fixed | std::ios::showpoint);
542 std::cout.precision(3);
545 std::cout <<
"last ";
554 std::vector< bool > have_imaginary;
555 have_imaginary.resize(paramotopy_info.
numparam);
556 for (
int ii = 0;ii< paramotopy_info.
numparam; ++ii) {
557 have_imaginary[ii] =
false;
562 for (
int jj = 0; jj<paramotopy_info.
numparam; ++jj) {
564 have_imaginary[jj] =
true;
569 std::vector< int > column_widths;
570 column_widths.resize(paramotopy_info.
numparam);
571 for (
int ii = 0; ii<paramotopy_info.
numparam; ++ii) {
572 if (have_imaginary[ii]) {
573 column_widths[ii] = 16;
576 column_widths[ii] = 9;
579 for (
int ii = 0; ii<paramotopy_info.
numparam; ++ii) {
581 for (
int jj=0; jj<(column_widths[ii]- int(paramotopy_info.
ParameterNames[ii].length())+2); ++jj) {
585 std::cout << std::endl << std::endl;
587 for (
int jj = 0; jj<paramotopy_info.
numparam; ++jj) {
588 std::stringstream ss;
593 std::string tmpstr = ss.str();
595 for (
int kk=0; kk<( column_widths[jj]-int(tmpstr.size()) ); ++kk) {
599 std::cout << std::endl;
605 std::cout.precision(premie);
606 std::cout.unsetf(std::ios::fixed | std::ios::showpoint);
614 int iteration, std::string startfilename){
617 boost::filesystem::path from_file = from_dir;
619 from_file /=
"step1";
620 from_file /= startfilename;
622 boost::filesystem::path to_file = to_dir;
624 to_file /= startfilename;
626 std::ifstream fin(from_file.c_str());
627 if (!fin.is_open()) {
628 std::cerr <<
"failed to open " << from_file <<
" to read" << std::endl;
630 std::ofstream fout(to_file.c_str());
631 if (!fout.is_open()) {
632 std::cerr <<
"failed to open " << to_file <<
" to write" << std::endl;
638 while (getline(fin,tmpstr)) {
639 fout << tmpstr <<
"\n";
660 paramotopy_settings.
settings[
"mode"][
"startfilename"].value());
665 std::vector< std::pair< double, double> > new_random_values = paramotopy_info.
MakeRandomValues(42);
675 boost::filesystem::path bertinifilename = paramotopy_info.
location;
676 bertinifilename /=
"step1";
677 boost::filesystem::create_directories(bertinifilename);
678 bertinifilename /=
"input";
680 fout.open(bertinifilename.c_str());
681 if (!fout.is_open()) {
682 std::cerr <<
"writing step1(2) input for failed paths FAILED to open to write\n";
687 bertinifilename = paramotopy_info.
location;
688 bertinifilename /=
"step1";
689 bertinifilename /=
"start";
690 fout.open(bertinifilename.c_str());
691 if (!fout.is_open()) {
692 std::cerr <<
"writing step1(2) start file for failed paths FAILED to open\n";
699 int previous_num_procs = paramotopy_settings.
settings[
"parallelism"][
"numprocs"].intvalue;
701 if (num_paths_to_track < previous_num_procs) {
702 paramotopy_settings.
setValue(
"parallelism",
"numprocs",num_paths_to_track+1);
712 if (num_paths_to_track < previous_num_procs) {
713 paramotopy_settings.
setValue(
"parallelism",
"numprocs",previous_num_procs);
719 std::string start_string =
"unset start string";
737 boost::filesystem::path mcfilename = paramotopy_info.
location;
740 if (boost::filesystem::exists(mcfilename)) {
741 boost::filesystem::remove(mcfilename);
748 fout.open(mcfilename.c_str());
749 if (!fout.is_open()) {
750 std::cerr <<
"failed to open " << mcfilename <<
" to write mc file. cannot continue." << std::endl;
757 for (
int jj = 0; jj < paramotopy_info.
numparam; ++jj) {
766 boost::filesystem::path failname = paramotopy_info.
location;
767 failname /=
"fail_indices";
768 fout.open(failname.c_str());
785 if (temporal_flag==0) {
796 std::vector< point > temporary_fails;
799 std::string inputfilename, outputfilename, wasteme, tmp, tmpstr;
803 std::stringstream ss, intstream;
812 std::string tempname;
814 for (
int folder_counter=0; folder_counter<int(
foldervector.size()); ++folder_counter){
817 inputfilename.append(
"/failed_paths");
820 int filenum = 0, totalfails_thisfolder = 0;
821 struct stat filestatus;
823 tempname = inputfilename;
824 tempname.append(
"0");
827 while ( stat( tempname.c_str(), &filestatus ) ==0 ) {
828 fin.open(tempname.c_str());
830 int num_points_inspected_individual = 0;
831 while ( getline(fin,tmpstr) ) {
832 if (tmpstr.length()==0 ){
840 ++num_points_inspected_individual;
842 ss >> temppoint.
index;
850 for (
int i = 0; i < paramotopy_info.
numparam; ++i) {
862 if (tempfailnum > 0){
863 temporary_fails.push_back(temppoint);
864 totalfails_thisfolder++;
872 std::cout << tempname <<
" "
873 << totalfails_thisfolder <<
" "
874 << num_points_inspected_individual <<
"\n";
879 tempname = inputfilename;
880 tempname.append(ss.str());
889 std::sort( temporary_fails.begin(), temporary_fails.end() );
895 switch (temporal_flag) {
909 std::cerr <<
"invalid temporal flag passed in find_failed_paths" << std::endl;
934 boost::filesystem::path foldername = dir;
935 foldername /=
"folders";
936 std::ifstream folderstream;
937 folderstream.open(foldername.c_str());
939 if (!folderstream.is_open()) {
940 std::cerr <<
"failed to open file to read folders " << foldername.string() << std::endl;
946 while (getline(folderstream,tmpstr)) {
949 folderstream.close();
int ParseFailedPaths(std::ifstream &fin, int numvariables)
the parser for the failed_paths file type, which is output from bertini.
std::map< int, std::vector< point > > initial_fails
void report_restored_data()
void write_successful_resolves(runinfo paramotopy_info)
int find_failed_paths(runinfo paramotopy_info, int temporal_flag, int iteration)
void merge_successful_resolves(std::vector< point > current_successful_resolves, std::vector< int > relative_indices, std::vector< int > final_indices)
void DisplayCurrentSettings(std::string category_name)
std::vector< std::pair< double, double > > RandomValues
std::map< int, point > ReadSuccessfulResolves()
void report_failed_paths(runinfo paramotopy_info)
boost::filesystem::path base_dir
void RecoverProgress(runinfo ¶motopy_info)
this function does three things: recovers the iteration number, recovers the list of points which hav...
boost::filesystem::path fundamental_dir
void get_folders_for_fail(boost::filesystem::path dir)
void StartOver(runinfo ¶motopy_info)
int GetMcNumLines(boost::filesystem::path base_dir, int numparam)
void copy_step_one(boost::filesystem::path from_dir, boost::filesystem::path to_dir, int iteration, std::string startfilename)
void find_successful_resolves(runinfo ¶motopy_info)
std::vector< boost::filesystem::path > FindDirectories(boost::filesystem::path, std::string expression)
void MainMenu(ProgSettings ¶motopy_settings, runinfo ¶motopy_info)
Class containing parameter values, index, and collected data.
bool TestIfFinished(boost::filesystem::path &path_to_check)
bool GatherDataForFails(std::vector< point > terminal_fails, std::vector< point > &successful_resolves)
std::vector< std::string > foldervector
void CallBertiniStep1(ProgSettings paramotopy_settings, runinfo paramotopy_info)
int get_int_choice(std::string display_string, int min_value, int max_value)
void set_location_fail(runinfo ¶motopy_info)
std::map< int, std::vector< point > > terminal_fails
void PerformAnalysis(ProgSettings ¶motopy_settings, runinfo ¶motopy_info)
void set_path_failure_settings()
std::vector< std::string > ParameterNames
void make_master_from_recovered(std::map< int, point > successful_resolves)
boost::filesystem::path inputfilename
boost::filesystem::path location
Class for gathering data, from failed path analysis, and from completed runs.
std::string new_step_one(ProgSettings ¶motopy_settings, runinfo ¶motopy_info)
std::vector< std::pair< double, double > > parameter_values
std::vector< std::pair< double, double > > MakeRandomValues(int garbageint)
A class that stores the general program settings of Paramotopy.
std::vector< point > master_fails
A class for the input file parser.
std::string WriteFailStep2(std::vector< std::pair< double, double > > CValues, ProgSettings paramotopy_settings, runinfo paramotopy_info)
void write_failed_paths(runinfo paramotopy_info, int iteration)
void WriteModifiedParamotopy(boost::filesystem::path dir, int iteration)
void setValue(std::string categoryName, std::string settingName, std::string settingValue)
int GetStart(boost::filesystem::path dir, std::string &start, std::string startfilename)