Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
paramotopy.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <ios>
3 #include <string>
4 #include <fstream>
5 #include <unistd.h>
6 #include <stdlib.h>
7 #include <errno.h>
8 #include <sys/wait.h>
9 #include <sys/stat.h>
10 #include <sys/types.h>
11 #include <list>
12 #include <vector>
13 #include <map>
14 #include <sstream>
15 #include <cmath>
16 #include "mtrand.hpp"
17 #include "step1_funcs.hpp"
18 #include "random.hpp"
19 #include "step2_funcs.hpp"
20 #include "para_aux_funcs.hpp"
21 #include "paramotopy_enum.hpp"
22 #include "menu_cases.hpp"
23 #include "failed_paths.hpp"
24 #include "datagatherer.hpp"
25 #include "xml_preferences.hpp"
26 //#include "preferences.h"
27 #include "tinyxml.h"
28 #include <mpi.h>
29 #include "runinfo.hpp"
30 
31 
32 
33 
34 
35 
41 int main(int argC, char *args[]){
42 
43 
44 
45  // Data members used throughout the program
46  std::string homedir = getenv("HOME");
47  OPTIONS currentChoice = Start;
48  std::string path_to_inputfile;
49  bool parsed = false;
50  std::ifstream finconfig;
51 
52 
53  runinfo paramotopy_info; //holds all the info for the run
54  failinfo fail_info;
55 
56  std::vector< std::pair< std::pair< double, double >, std::pair< double, double > > > RandomRanges;
57 
58 
59  std::string mytemp;
60  std::ifstream fin3;
61  std::ofstream foutdir;
62  std::string tmpbase;
63  std::string tmpstr;
64 
65  std::string dirfilename;
66 
67  // to allow for the choice from the user
68  // to determine if
69  // a parameter continuation run should be done
70  // versus a standard bertini run
71  // bool standardstep2 = true; // should be a choice that changes
72  // only on the particular run
73  // and should be a user-choice
74  // as runs will be dependent on system
75 
76 
77 
78 
79 
80  std::string suppliedfilename;
81  if (argC==1) {
82  paramotopy_info.GetInputFileName();
83  }
84  else{
85  std::stringstream commandss;
86  commandss << args[1];
87 
88  suppliedfilename = commandss.str();
89 
90  paramotopy_info.GetInputFileName(suppliedfilename);
91  }
92  paramotopy_info.ParseData();
93 
94 
95 
96 
97  std::string prefdir = homedir;
98  prefdir.append("/.paramotopy");
99  boost::filesystem::create_directories(prefdir);
100 
101 
102  ProgSettings paramotopy_settings;
103  paramotopy_settings.set_name(paramotopy_settings.make_settings_name(paramotopy_info.inputfilename));
104  paramotopy_settings.load();
105 
106  //splash the bertini intro's for the library and the executable.
107  BertiniSplashScreen(paramotopy_settings.settings["system"]["bertinilocation"].value());
108 
109 
110 
111 
112 
113  paramotopy_info.AutoScanData(paramotopy_settings.settings["files"]["previousdatamethod"].intvalue);//sets the base_dir
114 
115 
116  if (!paramotopy_info.GetPrevRandom()){
117  paramotopy_info.MakeRandomValues();
118  std::cout << "made new random values" << std::endl;
119  }
120 
121 
122 
123  // Make the appropriate Directory to place the input file in
124  paramotopy_info.mkdirstep1();
125 
126 
127 
128 
129 
130  parsed=true;
131 
133 
134 
135  if (paramotopy_info.test_if_finished()){
136  std::cout << "\t*** * * * * * * * * * * * * ***\n"
137  << "\t***this run's step2 appears finished***\n"
138  << "\t*** * * * * * * * * * * * * ***\n";
139  }
140 
141  int intChoice=-1;
142 
143 
144 
145  while(currentChoice!=Quit){
146 
147  intChoice = ParamotopyMainMenu(); // gets the choice from the user.
148 
149  switch (intChoice){
150  case 1 :
151 
152  currentChoice = Input;
153 
154  paramotopy_info.GetInputFileName();
155  paramotopy_info.ParseData();
156 
157 
158  paramotopy_info.AutoScanData(paramotopy_settings.settings["files"]["previousdatamethod"].intvalue);
159 
160  if (!paramotopy_info.GetPrevRandom()){
161  paramotopy_info.MakeRandomValues();
162  std::cout << "made new random values" << std::endl;
163  }
164  paramotopy_info.mkdirstep1();
165  paramotopy_info.CopyUserDefinedFile();
166  parsed=true;
167 
168 
169  paramotopy_settings.set_name(paramotopy_settings.make_settings_name(paramotopy_info.inputfilename));
170  paramotopy_settings.load();
171 
172 
173  break;
174 
175 
176 
177  case 2:
178  //data management
179  DataManagementMainMenu(paramotopy_info);
180  boost::filesystem::create_directories(paramotopy_info.base_dir);
181  paramotopy_info.mkdirstep1();
182  std::cout << "file directory is now " << paramotopy_info.base_dir << "\n";
183  paramotopy_info.GetPrevRandom(); //if didn't find previous values to load, make new ones (but only if use wants to
184  if ( (paramotopy_info.RandomValues.size()==0) || ((paramotopy_info.made_new_folder) && (paramotopy_settings.settings["files"]["newrandom_newfolder"].intvalue == 1)) )
185  {
186  paramotopy_info.MakeRandomValues();
187  std::cout << "made new random values" << std::endl;
188  }
189 
190  paramotopy_info.CopyUserDefinedFile();
191  paramotopy_info.UpdateAndSave();
192  break;
193 
194 
195 
196  case 3: // for use later?
197  std::cout << "unprogrammed\n";
198 
199  break;
200 
201 
202 
203  case 4: // Random point management
204 
205 
206  paramotopy_info.RandomMenu();
207  break;
208 
209 
210 
211 
212  case 5: // Write Step1
213  currentChoice=WriteStepOne;
214  paramotopy_info.location = paramotopy_info.base_dir;
215  paramotopy_info.WriteOriginalParamotopy(paramotopy_info.base_dir);
216  WriteStep1(paramotopy_settings,
217  paramotopy_info);
218  paramotopy_info.UpdateAndSave();
219  break;
220 
221 
222 
223 
224  case 6: //run step 1
225 
226  currentChoice = RunStepOne;
227  paramotopy_info.location = paramotopy_info.base_dir;
228 
229 
230 
231 
232  if (!paramotopy_info.CheckRunStepOne()){
233  break;
234  }
235 
236  paramotopy_info.WriteOriginalParamotopy(paramotopy_info.base_dir);
237  WriteStep1(paramotopy_settings,
238  paramotopy_info);
239 
240  paramotopy_info.WriteRandomValues();
241  CallBertiniStep1(paramotopy_settings,
242  paramotopy_info);
243 
244  paramotopy_info.UpdateAndSave();
245 
246 
247  break;
248 
249 
250 
251  case 7: //run step 2
252 
253  std::cout << "\n\n***Step2***\n\n";
254 
255  currentChoice = Step2;
256  paramotopy_info.location = paramotopy_info.base_dir;
257  paramotopy_info.steptwomode = 2;
258 
259 
260  steptwo_case(paramotopy_settings,
261  paramotopy_info);
262 
263 
264 
265  paramotopy_info.UpdateAndSave();
266  break;
267 
268 
269  case 8: //do failed path whatnot.
270  currentChoice = FailedPaths;
271  paramotopy_info.steptwomode = 3;
272  fail_info.MainMenu(paramotopy_settings,paramotopy_info);
273  paramotopy_info.UpdateAndSave();
274  break;
275 
276 
277 
278  case 99: //change preferences
279  currentChoice=DetPrefs;
280  paramotopy_settings.MainMenu();
281  break;
282 
283 
284 
285  case 0: //quit
286 
287  currentChoice=Quit;
288  std::cout << "Quitting\n\n";
289 
290 
291  }//re: switch (intChoice)
292 
293  }//re: while(currentChoice!=Quit)
294 
295  return 0;
296 }//re: main function
int main(int argC, char *args[])
This is the main function for the paramotopy program. It acts as the user interface, and provides * the commands for calling bertini for step1, * the wrapper around the step2 program, * failed path functionality, *bertini settings.
Definition: paramotopy.cpp:41
The class for performing failed path analysis.
int steptwomode
Definition: runinfo.hpp:95
std::vector< std::pair< double, double > > RandomValues
Definition: runinfo.hpp:130
void WriteStep1(ProgSettings paramotopy_settings, runinfo paramotopy_info)
Definition: step1_funcs.cpp:54
boost::filesystem::path base_dir
Definition: runinfo.hpp:77
void set_name(boost::filesystem::path newfilename)
OPTIONS
void WriteOriginalParamotopy(boost::filesystem::path dir)
Definition: runinfo.cpp:70
void WriteRandomValues()
Definition: runinfo.cpp:349
void DataManagementMainMenu(runinfo &paramotopy_info)
void ParseData()
Definition: runinfo.cpp:636
void UpdateAndSave()
Definition: runinfo.cpp:1315
bool CheckRunStepOne()
Definition: runinfo.cpp:6
void MainMenu(ProgSettings &paramotopy_settings, runinfo &paramotopy_info)
Definition: failed_paths.cpp:6
void mkdirstep1()
Definition: runinfo.hpp:180
void CallBertiniStep1(ProgSettings paramotopy_settings, runinfo paramotopy_info)
Definition: step1_funcs.cpp:5
void load(boost::filesystem::path pFilename)
void BertiniSplashScreen(std::string bertinilocation)
void RandomMenu()
Definition: runinfo.hpp:221
int ParamotopyMainMenu()
bool test_if_finished()
Definition: runinfo.cpp:1287
boost::filesystem::path inputfilename
Definition: runinfo.hpp:90
boost::filesystem::path location
Definition: runinfo.hpp:71
void ParamotopySplashScreen()
void AutoScanData(const int preferred_behaviour)
Definition: runinfo.cpp:1481
categorymap settings
std::vector< std::pair< double, double > > MakeRandomValues(int garbageint)
Definition: runinfo.cpp:788
A class that stores the general program settings of Paramotopy.
boost::filesystem::path make_settings_name(boost::filesystem::path basename)
bool GetPrevRandom()
Definition: runinfo.cpp:451
void CopyUserDefinedFile()
Definition: runinfo.cpp:579
void GetInputFileName()
Definition: runinfo.cpp:299
bool made_new_folder
Definition: runinfo.hpp:218
A class for the input file parser.
Definition: runinfo.hpp:41