00001 #include <fstream>
00002 #include <algorithm>
00003 #include <CFatalException.h>
00004 #include "C1dInvGaConf.h"
00005 using namespace std;
00006 void C1dInvGaConf::GetData(string filename)
00007 {
00008 ifstream infile;
00009 infile.open(filename.c_str());
00010 infile.peek();
00011 if (!infile)
00012 throw CFatalException("No Configurationfile found !");
00013 GetData(infile);infile.close();
00014 }
00015
00016 void C1dInvGaConf::GetData(std::ifstream &instream)
00017 {
00018 C1dInvGaConfLexer lexer(instream);
00019 C1dInvGaConfParser parser(lexer);
00020 parser.configfile();
00021 verbose= parser.verbose;
00022 usevrefmodel= parser.usevrefmodel;
00023 vrefmodel= parser.vrefmodel;
00024 mtfitexponent= parser.mtfitexponent;
00025 recfitexponent= parser.recfitexponent;
00026 surffitexponent= parser.surffitexponent;
00027 popsize= parser.popsize;
00028 inittemp= parser.inittemp;
00029 coolingratio= parser.coolingratio;
00030 generations= parser.generations;
00031 mutationprob= parser.mutationprob;
00032 crossoverprob= parser.crossoverprob;
00033 cc= parser.cc;
00034 poisson= parser.poisson;
00035 threads= parser.threads;
00036 starttime= parser.starttime;
00037 endtime= parser.endtime;
00038 tensorerror= parser.tensorerror;
00039 reserror= parser.reserror;
00040 phaseerror= parser.phaseerror;
00041 surferror= parser.surferror;
00042 recinfofile= parser.recinfofile;
00043 recmethod= parser.recmethod;
00044 gatype= parser.gatype;
00045 outputbase= parser.outputbase;
00046 mode= parser.mode;
00047 mtfit= parser.mtfit;
00048 mtinputdata= parser.mtinputdata;
00049 rfabsveldata= parser.rfabsveldata;
00050 dispdata= parser.dispdata;
00051 annealinggeneration= parser.annealinggeneration;
00052 elitist= parser.elitist;
00053 thickbase.assign(parser.thickbase.size(),0);
00054 copy(parser.thickbase.begin(),parser.thickbase.end(),thickbase.begin());
00055 thickstep.assign(parser.thickstep.size(),0);
00056 copy(parser.thickstep.begin(),parser.thickstep.end(),thickstep.begin());
00057 thicksizes.assign(parser.thicksizes.size(),0);
00058 copy(parser.thicksizes.begin(),parser.thicksizes.end(),thicksizes.begin());
00059 resbase.assign(parser.resbase.size(),0);
00060 copy(parser.resbase.begin(),parser.resbase.end(),resbase.begin());
00061 resstep.assign(parser.resstep.size(),0);
00062 copy(parser.resstep.begin(),parser.resstep.end(),resstep.begin());
00063 ressizes.assign(parser.ressizes.size(),0);
00064 copy(parser.ressizes.begin(),parser.ressizes.end(),ressizes.begin());
00065 svelbase.assign(parser.svelbase.size(),0);
00066 copy(parser.svelbase.begin(),parser.svelbase.end(),svelbase.begin());
00067 svelstep.assign(parser.svelstep.size(),0);
00068 copy(parser.svelstep.begin(),parser.svelstep.end(),svelstep.begin());
00069 svelsizes.assign(parser.svelsizes.size(),0);
00070 copy(parser.svelsizes.begin(),parser.svelsizes.end(),svelsizes.begin());
00071 weights.assign(parser.weights.size(),0);
00072 copy(parser.weights.begin(),parser.weights.end(),weights.begin());
00073 recweight= parser.recweight;
00074 absvelweight= parser.absvelweight;
00075 }
00076
00077 void C1dInvGaConf::WriteData(string filename)
00078 {
00079 ofstream confout(filename.c_str());
00080 WriteData(confout);}
00081
00082 void C1dInvGaConf::WriteData(std::ofstream &outstream)
00083 {
00084 outstream << "verbose" << "=" ;
00085 outstream << (verbose ? "true" : "false") << endl;
00086 outstream << "usevrefmodel" << "=" ;
00087 outstream << (usevrefmodel ? "true" : "false") << endl;
00088 outstream << "vrefmodel" << "=" ;
00089 outstream << vrefmodel << endl;
00090 outstream << "mtfitexponent" << "=" ;
00091 outstream << mtfitexponent << endl;
00092 outstream << "recfitexponent" << "=" ;
00093 outstream << recfitexponent << endl;
00094 outstream << "surffitexponent" << "=" ;
00095 outstream << surffitexponent << endl;
00096 outstream << "popsize" << "=" ;
00097 outstream << popsize << endl;
00098 outstream << "inittemp" << "=" ;
00099 outstream << inittemp << endl;
00100 outstream << "coolingratio" << "=" ;
00101 outstream << coolingratio << endl;
00102 outstream << "generations" << "=" ;
00103 outstream << generations << endl;
00104 outstream << "mutationprob" << "=" ;
00105 outstream << mutationprob << endl;
00106 outstream << "crossoverprob" << "=" ;
00107 outstream << crossoverprob << endl;
00108 outstream << "cc" << "=" ;
00109 outstream << cc << endl;
00110 outstream << "poisson" << "=" ;
00111 outstream << poisson << endl;
00112 outstream << "threads" << "=" ;
00113 outstream << threads << endl;
00114 outstream << "starttime" << "=" ;
00115 outstream << starttime << endl;
00116 outstream << "endtime" << "=" ;
00117 outstream << endtime << endl;
00118 outstream << "tensorerror" << "=" ;
00119 outstream << tensorerror << endl;
00120 outstream << "reserror" << "=" ;
00121 outstream << reserror << endl;
00122 outstream << "phaseerror" << "=" ;
00123 outstream << phaseerror << endl;
00124 outstream << "surferror" << "=" ;
00125 outstream << surferror << endl;
00126 outstream << "recinfofile" << "=" ;
00127 outstream << recinfofile << endl;
00128 outstream << "recmethod" << "=" ;
00129 outstream << recmethod << endl;
00130 outstream << "gatype" << "=" ;
00131 outstream << gatype << endl;
00132 outstream << "outputbase" << "=" ;
00133 outstream << outputbase << endl;
00134 outstream << "mode" << "=" ;
00135 outstream << mode << endl;
00136 outstream << "mtfit" << "=" ;
00137 outstream << mtfit << endl;
00138 outstream << "mtinputdata" << "=" ;
00139 outstream << mtinputdata << endl;
00140 outstream << "rfabsveldata" << "=" ;
00141 outstream << rfabsveldata << endl;
00142 outstream << "dispdata" << "=" ;
00143 outstream << dispdata << endl;
00144 outstream << "annealinggeneration" << "=" ;
00145 outstream << annealinggeneration << endl;
00146 outstream << "elitist" << "=" ;
00147 outstream << (elitist ? "true" : "false") << endl;
00148 outstream << "thickbase" << "=" ;
00149 for (size_t i = 0; i < thickbase.size(); ++i)
00150 outstream << thickbase.at(i) << " ";
00151 outstream << endl;
00152
00153 outstream << "thickstep" << "=" ;
00154 for (size_t i = 0; i < thickstep.size(); ++i)
00155 outstream << thickstep.at(i) << " ";
00156 outstream << endl;
00157
00158 outstream << "thicksizes" << "=" ;
00159 for (size_t i = 0; i < thicksizes.size(); ++i)
00160 outstream << thicksizes.at(i) << " ";
00161 outstream << endl;
00162
00163 outstream << "resbase" << "=" ;
00164 for (size_t i = 0; i < resbase.size(); ++i)
00165 outstream << resbase.at(i) << " ";
00166 outstream << endl;
00167
00168 outstream << "resstep" << "=" ;
00169 for (size_t i = 0; i < resstep.size(); ++i)
00170 outstream << resstep.at(i) << " ";
00171 outstream << endl;
00172
00173 outstream << "ressizes" << "=" ;
00174 for (size_t i = 0; i < ressizes.size(); ++i)
00175 outstream << ressizes.at(i) << " ";
00176 outstream << endl;
00177
00178 outstream << "svelbase" << "=" ;
00179 for (size_t i = 0; i < svelbase.size(); ++i)
00180 outstream << svelbase.at(i) << " ";
00181 outstream << endl;
00182
00183 outstream << "svelstep" << "=" ;
00184 for (size_t i = 0; i < svelstep.size(); ++i)
00185 outstream << svelstep.at(i) << " ";
00186 outstream << endl;
00187
00188 outstream << "svelsizes" << "=" ;
00189 for (size_t i = 0; i < svelsizes.size(); ++i)
00190 outstream << svelsizes.at(i) << " ";
00191 outstream << endl;
00192
00193 outstream << "weights" << "=" ;
00194 for (size_t i = 0; i < weights.size(); ++i)
00195 outstream << weights.at(i) << " ";
00196 outstream << endl;
00197
00198 outstream << "recweight" << "=" ;
00199 outstream << recweight << endl;
00200 outstream << "absvelweight" << "=" ;
00201 outstream << absvelweight << endl;
00202 }
00203