GPLIB++
SurfInvGaConf.cpp
Go to the documentation of this file.
1 #include <fstream>
2 #include <algorithm>
3  #include <CFatalException.h>
4 #include "SurfInvGaConf.h"
5 using namespace std;
6 void SurfInvGaConf::GetData(string filename)
7 {
8 ifstream infile;
9 infile.open(filename.c_str());
10 infile.peek();
11 if (!infile)
12  throw CFatalException("No Configurationfile found !");
13  GetData(infile);infile.close();
14 }
15 
16 void SurfInvGaConf::GetData(std::ifstream &instream)
17 {
18 SurfInvGaConfLexer lexer(instream);
19 SurfInvGaConfParser parser(lexer);
20 parser.configfile();
21 verbose= parser.verbose;
22 usevrefmodel= parser.usevrefmodel;
23 vrefmodel= parser.vrefmodel;
24 backgroundmodel= parser.backgroundmodel;
25 fitexponent= parser.fitexponent;
26 popsize= parser.popsize;
27 inittemp= parser.inittemp;
28 coolingratio= parser.coolingratio;
29 generations= parser.generations;
30 mutationprob= parser.mutationprob;
31 crossoverprob= parser.crossoverprob;
32 poisson= parser.poisson;
33 threads= parser.threads;
34 errorlevel= parser.errorlevel;
35 gatype= parser.gatype;
36 outputbase= parser.outputbase;
37 inputdata= parser.inputdata;
38 annealinggeneration= parser.annealinggeneration;
39 elitist= parser.elitist;
40 thickbase.assign(parser.thickbase.size(),0);
41 copy(parser.thickbase.begin(),parser.thickbase.end(),thickbase.begin());
42 thickstep.assign(parser.thickstep.size(),0);
43 copy(parser.thickstep.begin(),parser.thickstep.end(),thickstep.begin());
44 thicksizes.assign(parser.thicksizes.size(),0);
45 copy(parser.thicksizes.begin(),parser.thicksizes.end(),thicksizes.begin());
46 svelbase.assign(parser.svelbase.size(),0);
47 copy(parser.svelbase.begin(),parser.svelbase.end(),svelbase.begin());
48 svelstep.assign(parser.svelstep.size(),0);
49 copy(parser.svelstep.begin(),parser.svelstep.end(),svelstep.begin());
50 svelsizes.assign(parser.svelsizes.size(),0);
51 copy(parser.svelsizes.begin(),parser.svelsizes.end(),svelsizes.begin());
52 weights.assign(parser.weights.size(),0);
53 copy(parser.weights.begin(),parser.weights.end(),weights.begin());
54 }
55 
56 void SurfInvGaConf::WriteData(string filename)
57 {
58 ofstream confout(filename.c_str());
59 WriteData(confout);}
60 
61 void SurfInvGaConf::WriteData(std::ofstream &outstream)
62 {
63 outstream << "verbose" << "=" ;
64 outstream << (verbose ? "true" : "false") << endl;
65 outstream << "usevrefmodel" << "=" ;
66 outstream << (usevrefmodel ? "true" : "false") << endl;
67 outstream << "vrefmodel" << "=" ;
68 outstream << vrefmodel << endl;
69 outstream << "backgroundmodel" << "=" ;
70 outstream << backgroundmodel << endl;
71 outstream << "fitexponent" << "=" ;
72 outstream << fitexponent << endl;
73 outstream << "popsize" << "=" ;
74 outstream << popsize << endl;
75 outstream << "inittemp" << "=" ;
76 outstream << inittemp << endl;
77 outstream << "coolingratio" << "=" ;
78 outstream << coolingratio << endl;
79 outstream << "generations" << "=" ;
80 outstream << generations << endl;
81 outstream << "mutationprob" << "=" ;
82 outstream << mutationprob << endl;
83 outstream << "crossoverprob" << "=" ;
84 outstream << crossoverprob << endl;
85 outstream << "poisson" << "=" ;
86 outstream << poisson << endl;
87 outstream << "threads" << "=" ;
88 outstream << threads << endl;
89 outstream << "errorlevel" << "=" ;
90 outstream << errorlevel << endl;
91 outstream << "gatype" << "=" ;
92 outstream << gatype << endl;
93 outstream << "outputbase" << "=" ;
94 outstream << outputbase << endl;
95 outstream << "inputdata" << "=" ;
96 outstream << inputdata << endl;
97 outstream << "annealinggeneration" << "=" ;
98 outstream << annealinggeneration << endl;
99 outstream << "elitist" << "=" ;
100 outstream << (elitist ? "true" : "false") << endl;
101 outstream << "thickbase" << "=" ;
102 for (size_t i = 0; i < thickbase.size(); ++i)
103  outstream << thickbase.at(i) << " ";
104 outstream << endl;
105 
106 outstream << "thickstep" << "=" ;
107 for (size_t i = 0; i < thickstep.size(); ++i)
108  outstream << thickstep.at(i) << " ";
109 outstream << endl;
110 
111 outstream << "thicksizes" << "=" ;
112 for (size_t i = 0; i < thicksizes.size(); ++i)
113  outstream << thicksizes.at(i) << " ";
114 outstream << endl;
115 
116 outstream << "svelbase" << "=" ;
117 for (size_t i = 0; i < svelbase.size(); ++i)
118  outstream << svelbase.at(i) << " ";
119 outstream << endl;
120 
121 outstream << "svelstep" << "=" ;
122 for (size_t i = 0; i < svelstep.size(); ++i)
123  outstream << svelstep.at(i) << " ";
124 outstream << endl;
125 
126 outstream << "svelsizes" << "=" ;
127 for (size_t i = 0; i < svelsizes.size(); ++i)
128  outstream << svelsizes.at(i) << " ";
129 outstream << endl;
130 
131 outstream << "weights" << "=" ;
132 for (size_t i = 0; i < weights.size(); ++i)
133  outstream << weights.at(i) << " ";
134 outstream << endl;
135 
136 }
137 
void GetData(std::ifstream &instream)
void WriteData(std::ofstream &outstream)