9 <<
"*******************************\n"
10 <<
" Welcome to Paramotopy.\n"
11 <<
" parametrized system analysis software by\n"
12 <<
" daniel brake and matthew niemerg, with dan bates.\n\n"
13 <<
" www.paramotopy.com danielthebrake@gmail.com matthew.niemerg@gmail.com \n"
14 <<
"**************************" << std::endl;
24 args_splash[0] =
const_cast<char *
>(
"bertini");
25 args_splash[1] =
const_cast<char *
>(
"--version");
28 std::cout <<
"\n\nlinked library bertini:\n\n";
30 std::cout <<
"\n\nstand-alone bertini:\n\n";
33 std::stringstream command;
34 command << bertinilocation <<
"/bertini --version" ;
35 system(command.str().c_str());
46 std::map < std::string , int > possible_savefiles;
47 possible_savefiles[
"real_solutions"] = 1;
48 possible_savefiles[
"nonsingular_solutions"] = 1;
49 possible_savefiles[
"singular_solutions"] = 1;
50 possible_savefiles[
"raw_data"] = -1;
51 possible_savefiles[
"raw_solutions"] = -1;
52 possible_savefiles[
"main_data"] = -1;
53 possible_savefiles[
"midpath_data"] = -1;
54 possible_savefiles[
"failed_paths"] = 2;
55 possible_savefiles[
"real_finite_solutions"] = 1;
58 return possible_savefiles[filename];
67 std::vector< std::string > & gather_savefiles,
68 std::vector< int > & gather_parser_indices)
70 std::vector < std::string > possible_savefiles;
71 possible_savefiles.push_back(
"real_solutions");
72 possible_savefiles.push_back(
"nonsingular_solutions");
73 possible_savefiles.push_back(
"singular_solutions");
74 possible_savefiles.push_back(
"raw_data");
75 possible_savefiles.push_back(
"raw_solutions");
76 possible_savefiles.push_back(
"main_data");
77 possible_savefiles.push_back(
"midpath_data");
78 possible_savefiles.push_back(
"failed_paths");
79 possible_savefiles.push_back(
"real_finite_solutions");
80 std::vector < int > possible_parser_indices;
81 possible_parser_indices.push_back(1);
82 possible_parser_indices.push_back(1);
83 possible_parser_indices.push_back(1);
84 possible_parser_indices.push_back(-1);
85 possible_parser_indices.push_back(-1);
86 possible_parser_indices.push_back(-1);
87 possible_parser_indices.push_back(-1);
88 possible_parser_indices.push_back(2);
89 possible_parser_indices.push_back(1);
91 for (
int ii = 0; ii < int(possible_savefiles.size()); ii++){
92 boost::filesystem::path temppath = run_to_analyze;
93 temppath /=
"step2/DataCollected/c1";
94 std::string expression =
"^";
95 expression.append(possible_savefiles[ii]);
96 std::vector < boost::filesystem::path > filelist =
FindFiles(temppath, expression);
97 if (
int(filelist.size())>0){
98 gather_savefiles.push_back(possible_savefiles[ii]);
99 gather_parser_indices.push_back(possible_parser_indices[ii]);
112 boost::filesystem::path appended_path = path_to_check;
113 appended_path /=
"step2finished";
115 if (boost::filesystem::exists(appended_path)){
134 if (tmpstr.length()==0) {
138 for (
int i=0; i<3+numvariables; ++i) {
155 found=workwithme.find(
'~');
156 if ( (
int(found)==0) ) {
157 std::string replaced_string = getenv(
"HOME");
158 replaced_string.append( workwithme.substr(found+1,workwithme.length()-1));
159 return replaced_string;
167 std::vector<boost::filesystem::path>
FindDirectories(boost::filesystem::path dir, std::string expression){
168 boost::filesystem::path p(dir);
169 boost::regex e(expression);
170 std::vector<boost::filesystem::path> found_folders;
172 if (boost::filesystem::exists(p)) {
173 boost::filesystem::directory_iterator dir_end;
174 boost::filesystem::path filename;
175 for(boost::filesystem::directory_iterator dir_iter(p); dir_iter != dir_end; ++dir_iter) {
176 filename = dir_iter->path().filename();
177 if (boost::regex_search(filename.string(),e)) {
178 if (is_directory(dir_iter->path())){
179 found_folders.push_back(dir_iter->path());
185 std::cerr <<
"directory " << dir.string() <<
" does not exist!\n";
187 std::sort(found_folders.begin(), found_folders.end());
188 return found_folders;
194 std::vector< boost::filesystem::path >
FindFiles(boost::filesystem::path dir, std::string expression){
196 boost::filesystem::path p(dir);
197 boost::regex e(expression);
198 std::vector<boost::filesystem::path> found_files;
201 if (boost::filesystem::exists(p)) {
202 boost::filesystem::directory_iterator dir_end;
203 boost::filesystem::path filename;
204 for(boost::filesystem::directory_iterator dir_iter(p); dir_iter != dir_end; ++dir_iter) {
205 filename = dir_iter->path().filename();
206 if (boost::regex_search(filename.string(),e)) {
207 if (is_regular_file(dir_iter->path())){
208 found_files.push_back(dir_iter->path());
214 std::cerr <<
"directory " << dir <<
" does not exist!\n";
218 std::sort(found_files.begin(), found_files.end());
228 boost::filesystem::path dir =
"bfiles_";
230 dir /= filename.filename();
243 std::istringstream parser( text );
244 return parser >> results >> std::ws && parser.peek() == EOF;
251 std::cin.ignore( std::numeric_limits<std::streampos>::max(),
'\n' ) ;
257 while ( ! std::getline( std::cin, line ) )
260 std::cin.ignore( std::numeric_limits<std::streampos>::max(),
'\n' ) ;
266 std::cout <<
"Only 'numeric' value(s) allowed:" << std::endl;
281 while (!std::getline(std::cin,tmpstr)) {
295 while (!std::getline(std::cin,tmpstr)) {
301 std::istringstream parser( tmpstr);
302 std::string returnme;
312 std::istringstream parser( text );
314 return !(parser.fail());
320 std::cin.ignore( std::numeric_limits<std::streampos>::max(),
'\n' ) ;
326 while ( ! std::getline( std::cin, line ) )
329 std::cin.ignore( std::numeric_limits<std::streampos>::max(),
'\n' ) ;
335 std::cout <<
"Only 'numeric' value(s) allowed:" << std::endl;
349 std::cout << display_string;
351 int userinput = min_value - 1;
358 if (userinput <= max_value && userinput >= min_value){
362 std::cout <<
"value out of bounds." << std::endl;
389 std::stringstream menu;
391 menu <<
"\n\nYour choices : \n\n"
392 <<
"1) Parse an appropriate input file. \n"
393 <<
"2) Data Management. \n"
394 <<
"3) -unprogrammed- \n"
395 <<
"4) Manage start point (load/save/new). \n"
396 <<
"5) Write Step 1.\n"
397 <<
"6) Run Step 1.\n"
398 <<
"7) Run Step 2.\n"
399 <<
"8) Failed Path Analysis.\n"
401 <<
"99) Preferences.\n"
403 <<
"0) Quit the program.\n\n"
404 <<
"Enter the integer value of your choice : ";
406 std::cout << menu.str();
409 while ( (intChoice>=9 && intChoice<=98) || (intChoice >=100 || intChoice < 0) ) {
430 const size_t chunkSize=255;
431 const int maxChunks=10240;
433 char stackBuffer[chunkSize];
434 if(getcwd(stackBuffer,
sizeof(stackBuffer))!=NULL)
439 throw std::runtime_error(
"Cannot determine the current path.");
443 for(
int chunks=2; chunks<maxChunks ; chunks++)
447 std::auto_ptr<char> cwd(
new char[chunkSize*chunks]);
448 if(getcwd(cwd.get(),chunkSize*chunks)!=NULL)
453 throw std::runtime_error(
"Cannot determine the current path.");
457 throw std::runtime_error(
"Cannot determine the current path; the path is apparently unreasonably long");
467 success = chdir(desired_directory.c_str());
472 std::string throwme =
"failed to change directory to ";
473 throwme.append(desired_directory);
474 throwme.append(
" giving error ");
475 throwme.append(strerror (errno));
476 throw std::runtime_error(throwme);
487 found=workwithme.find(
' ');
488 std::string newstring =
"";
491 while (found != std::string::npos) {
492 newstring.append(workwithme.substr(0,found));
493 newstring.append(
"\\ ");
494 workwithme = workwithme.substr(found+1,workwithme.length()-1);
495 found=workwithme.find(
' ');
498 newstring.append(workwithme);
std::vector< boost::filesystem::path > FindFiles(boost::filesystem::path dir, std::string expression)
std::string stackoverflow_getcwd()
bool TestIfFinished(boost::filesystem::path &path_to_check)
std::string getAlphaNumeric()
int ParseFailedPaths(std::ifstream &fin, int numvariables)
the parser for the failed_paths file type, which is output from bertini.
std::string replace_tilde_with_home(std::string workwithme)
boost::filesystem::path make_base_dir_name(boost::filesystem::path filename)
void GetFilesToParse(boost::filesystem::path run_to_analyze, std::vector< std::string > &gather_savefiles, std::vector< int > &gather_parser_indices)
void safe_chdir(std::string desired_directory)
int get_int_choice(std::string display_string, int min_value, int max_value)
std::vector< boost::filesystem::path > FindDirectories(boost::filesystem::path dir, std::string expression)
std::string getAlphaNumeric_WithSpaces()
void ParamotopySplashScreen()
bool parseInteger(std::string const &text, int &results)
void BertiniSplashScreen(std::string bertinilocation)
std::string convert_spaces_to_escaped(std::string workwithme)
int GetFileParserIndex(std::string filename)
bool parseDouble(std::string const &text, double &results)