• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

D:/LIACS/mies/SerialES/main.cpp

Go to the documentation of this file.
00001 #include "main.h"
00002 
00003 int main(int argc, char* argv[])
00004 { 
00005   if (argc < 2) 
00006   { 
00007     cerr << "No input file supplied! Exiting." << endl;   
00008     return 1;
00009   }
00010 
00011   char line[LEN];
00012   ifstream infile(argv[1]);
00013 
00014   /* Read constant simulator parameters from input file */
00015   vector<string> constSimParams;
00016   skipLinesUntil(infile, HEADER_CONSTANTS);
00017 
00018   infile.getline(line, LEN);
00019   while (line[0] != '\0')
00020   {
00021     constSimParams.push_back(strtok(line, " ;"));
00022     findAndReplace(constSimParams.back(), SPACE, " ");
00023     infile.getline(line, LEN);
00024   }
00025 
00026   /* Read variable simulator parameter names from input file */ 
00027   vector<string> varSimParamNames;
00028   skipLinesUntil(infile, HEADER_NAMES);
00029 
00030   infile.getline(line, LEN);
00031   while (line[0] != '\0')
00032   {
00033     varSimParamNames.push_back(strtok(line, " ;"));
00034     infile.getline(line, LEN);
00035   }
00036 
00037   /* Read MIES parameters from input file */
00038   skipLinesUntil(infile, HEADER_MIES);
00039   
00040   unsigned n_r       = atoi(getValue(infile)),
00041            n_z       = atoi(getValue(infile)),
00042            n_d       = atoi(getValue(infile)),
00043            n_sigma_r = atoi(getValue(infile)),
00044            n_sigma_z = atoi(getValue(infile)),
00045            n_prob    = atoi(getValue(infile)),
00046            n_f       = atoi(getValue(infile)),
00047            mu        = atoi(getValue(infile)),
00048            rho       = atoi(getValue(infile)),
00049            kappa     = atoi(getValue(infile)),
00050            lambda    = atoi(getValue(infile));
00051 
00052   vector<double> lBound_r, uBound_r; 
00053   vector<int> lBound_z, uBound_z, lBound_d, uBound_d; 
00054 
00055   getBound(infile, &lBound_r, NULL, n_r);
00056   getBound(infile, &uBound_r, NULL, n_r);
00057 
00058   getBound(infile, NULL, &lBound_z, n_z);
00059   getBound(infile, NULL, &uBound_z, n_z);
00060 
00061   getBound(infile, NULL, &lBound_d, n_d);
00062   getBound(infile, NULL, &uBound_d, n_d);
00063 
00064   double prob_min = atof(getValue(infile)),
00065          prob_max = atof(getValue(infile));
00066 
00067   bool disRec_r       = (atoi(getValue(infile)) == 0) ? false : true,
00068        disRec_z       = (atoi(getValue(infile)) == 0) ? false : true, 
00069        disRec_sigma_r = (atoi(getValue(infile)) == 0) ? false : true,
00070        disRec_sigma_z = (atoi(getValue(infile)) == 0) ? false : true, 
00071        disRec_prob    = (atoi(getValue(infile)) == 0) ? false : true,
00072        selfAdaptation = (atoi(getValue(infile)) == 0) ? false : true; 
00073 
00074   vector<int> direction; 
00075   for (unsigned i = 0; i < n_f; i++)
00076     direction.push_back(atoi(getValue(infile)));
00077 
00078   unsigned selectDimension = atoi(getValue(infile));
00079 
00080   vector<unsigned> selectFunction;
00081   for (unsigned i = 0; i < selectDimension; i++)
00082     selectFunction.push_back(atoi(getValue(infile)));
00083 
00084   unsigned evaluations = atoi(getValue(infile));
00085 
00086   vector<double> optimalF;
00087   for (unsigned i = 0; i < n_f; i++)
00088     optimalF.push_back(atof(getValue(infile)));
00089 
00090   double initialSigma_r = atof(getValue(infile)),
00091          initialSigma_z = atof(getValue(infile)),
00092          initialProb    = atof(getValue(infile));
00093 
00094   string initialPopFileName = getStringValue(infile);
00095 
00096   int randomSeed = atoi(getValue(infile));
00097 
00098   bool feedback = (atoi(getValue(infile)) == 1) ? true : false;
00099 
00100   string ES = getStringValue(infile);
00101 
00102   string MOproblem;
00103   if (ES == "TestFunctions_MIES")
00104     MOproblem = getStringValue(infile);
00105 
00106   bool excludeParent;
00107 #ifdef STEADY
00108   excludeParent = (atoi(getValue(infile)) == 0) ? false : true;
00109 #endif
00110 
00111   /* Read simulator file names from input file */
00112   skipLinesUntil(infile, HEADER_SIMULATOR);
00113   string simulator         = getStringValue(infile),
00114          path              = getStringValue(infile),
00115          simInputFileName  = getStringValue(infile),
00116          simOutputFileName = getStringValue(infile);
00117 
00118   unsigned timeOutValue = 0;
00119 #ifdef PARALLEL
00120   /* Read time out value from input file */
00121   skipLinesUntil(infile, "server");
00122   timeOutValue = atoi(getValue(infile));
00123 #endif
00124   infile.close();
00125 
00126   findAndReplace(initialPopFileName, SPACE, " ");
00127   findAndReplace(MOproblem, SPACE, " ");
00128   findAndReplace(simulator, SPACE, " ");
00129   findAndReplace(path, SPACE, " ");
00130   findAndReplace(simInputFileName, SPACE, " ");
00131   findAndReplace(simOutputFileName, SPACE, " ");
00132 
00133   ifstream* initialPopFile = (initialPopFileName == " ") ? NULL : new ifstream(initialPopFileName.c_str());
00134 
00135   simulator = "\"\"\"" + simulator + "\" \"" + path + "\"\"\"";  
00136  
00137 #ifndef PARALLEL
00138   if (ES == "TestFunctions_MIES")
00139   {
00140     TestFunctions_MIES testMies(n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f, 
00141                                  mu, rho, kappa, lambda,  
00142                                    lBound_r, uBound_r, lBound_z, uBound_z, 
00143                                      lBound_d, uBound_d, prob_min,  prob_max,
00144                                        disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob,
00145                                          selfAdaptation, direction, 
00146                                            evaluations, optimalF, initialSigma_r, initialSigma_z, initialProb, initialPopFile, 
00147                                              randomSeed, feedback, timeOutValue,
00148                                                selectDimension, selectFunction,
00149                                                  MOproblem, excludeParent);
00150     testMies.run();
00151   }
00152 #endif
00153   
00154 #ifdef MASPROJ
00155   if (ES == "SingleAisle_MIES")
00156   {       
00157 # ifdef PARALLEL
00158     SingleAisle_MIES_P saMies(n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f, 
00159                                mu, rho, kappa, lambda,  
00160                                  lBound_r, uBound_r, lBound_z, uBound_z, 
00161                                    lBound_d, uBound_d, prob_min, prob_max,
00162                                      disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob,
00163                                        selfAdaptation, direction, 
00164                                          evaluations, optimalF, initialSigma_r, initialSigma_z, initialProb, initialPopFile, 
00165                                            randomSeed, feedback, timeOutValue,
00166                                              simulator, simInputFileName, simOutputFileName,
00167                                                constSimParams, varSimParamNames,
00168                                                  selectDimension, selectFunction);
00169 # else
00170     SingleAisle_MIES saMies(n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f, 
00171                              mu, rho, kappa, lambda,  
00172                                lBound_r, uBound_r, lBound_z, uBound_z, 
00173                                  lBound_d, uBound_d, prob_min, prob_max,
00174                                    disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob,
00175                                      selfAdaptation, direction, 
00176                                        evaluations, optimalF, initialSigma_r, initialSigma_z, initialProb, initialPopFile, 
00177                                          randomSeed, feedback, timeOutValue,
00178                                            simulator, simInputFileName, simOutputFileName,
00179                                              constSimParams, varSimParamNames,
00180                                                selectDimension, selectFunction);
00181 # endif
00182     saMies.run();
00183   }
00184 
00185   else if (ES == "MultiAisle_MIES")
00186   {       
00187 # ifdef PARALLEL
00188     MultiAisle_MIES_P maMies(n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f, 
00189                                mu, rho, kappa, lambda,  
00190                                  lBound_r, uBound_r, lBound_z, uBound_z, 
00191                                    lBound_d, uBound_d, prob_min, prob_max,
00192                                      disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob,
00193                                        selfAdaptation, direction, 
00194                                          evaluations, optimalF, initialSigma_r, initialSigma_z, initialProb, initialPopFile, 
00195                                            randomSeed, feedback, timeOutValue,
00196                                              simulator, simInputFileName, simOutputFileName,
00197                                                constSimParams, varSimParamNames,
00198                                                  selectDimension, selectFunction);
00199 # else
00200     MultiAisle_MIES maMies(n_r, n_z, n_d, n_sigma_r, n_sigma_z, n_prob, n_f, 
00201                              mu, rho, kappa, lambda,  
00202                                lBound_r, uBound_r, lBound_z, uBound_z, 
00203                                  lBound_d, uBound_d, prob_min, prob_max,
00204                                    disRec_r, disRec_z, disRec_sigma_r, disRec_sigma_z, disRec_prob,
00205                                      selfAdaptation, direction, 
00206                                        evaluations, optimalF, initialSigma_r, initialSigma_z, initialProb, initialPopFile, 
00207                                          randomSeed, feedback, timeOutValue,
00208                                            simulator, simInputFileName, simOutputFileName,
00209                                              constSimParams, varSimParamNames,
00210                                                selectDimension, selectFunction);
00211 # endif
00212     maMies.run();
00213   }
00214 #endif
00215 
00216   return 0;
00217 }
00218 

Generated on Tue Oct 4 2011 16:25:19 for WDN by  doxygen 1.7.2