GPLIB++
AnisoGAJointConf.cpp
Go to the documentation of this file.
1 #include <fstream>
2 #include <algorithm>
3  #include <CFMException.h>
4 #include "AnisoGAJointConf.h"
5 using namespace std;
6 void AnisoGAJointConf::GetData(string filename)
7 {
8 ifstream infile;
9 infile.open(filename.c_str());
10 infile.peek();
11 if (!infile)
12  throw CFMException("No Configurationfile found !");
13  GetData(infile);infile.close();
14 }
15 
16 void AnisoGAJointConf::GetData(std::ifstream &instream)
17 {
18 AnisoGAJointConfLexer lexer(instream);
19 AnisoGAJointConfParser parser(lexer);
20 parser.configfile();
21 verbose= parser.verbose;
22 mtfitexponent= parser.mtfitexponent;
23 popsize= parser.popsize;
24 inittemp= parser.inittemp;
25 coolingratio= parser.coolingratio;
26 generations= parser.generations;
27 mutationprob= parser.mutationprob;
28 crossoverprob= parser.crossoverprob;
29 threads= parser.threads;
30 starttime= parser.starttime;
31 endtime= parser.endtime;
32 tensorerror= parser.tensorerror;
33 reserror= parser.reserror;
34 phaseerror= parser.phaseerror;
35 gatype= parser.gatype;
36 outputbase= parser.outputbase;
37 mode= parser.mode;
38 mtfit= parser.mtfit;
39 mtinputdata= parser.mtinputdata;
40 ptensordata= parser.ptensordata;
41 annealinggeneration= parser.annealinggeneration;
42 elitist= parser.elitist;
43 thickbase.assign(parser.thickbase.size(),0);
44 copy(parser.thickbase.begin(),parser.thickbase.end(),thickbase.begin());
45 thickstep.assign(parser.thickstep.size(),0);
46 copy(parser.thickstep.begin(),parser.thickstep.end(),thickstep.begin());
47 thicksizes.assign(parser.thicksizes.size(),0);
48 copy(parser.thicksizes.begin(),parser.thicksizes.end(),thicksizes.begin());
49 resbase.assign(parser.resbase.size(),0);
50 copy(parser.resbase.begin(),parser.resbase.end(),resbase.begin());
51 resstep.assign(parser.resstep.size(),0);
52 copy(parser.resstep.begin(),parser.resstep.end(),resstep.begin());
53 ressizes.assign(parser.ressizes.size(),0);
54 copy(parser.ressizes.begin(),parser.ressizes.end(),ressizes.begin());
55 velbase.assign(parser.velbase.size(),0);
56 copy(parser.velbase.begin(),parser.velbase.end(),velbase.begin());
57 velstep.assign(parser.velstep.size(),0);
58 copy(parser.velstep.begin(),parser.velstep.end(),velstep.begin());
59 velsizes.assign(parser.velsizes.size(),0);
60 copy(parser.velsizes.begin(),parser.velsizes.end(),velsizes.begin());
61 aresbase.assign(parser.aresbase.size(),0);
62 copy(parser.aresbase.begin(),parser.aresbase.end(),aresbase.begin());
63 aresstep.assign(parser.aresstep.size(),0);
64 copy(parser.aresstep.begin(),parser.aresstep.end(),aresstep.begin());
65 aressizes.assign(parser.aressizes.size(),0);
66 copy(parser.aressizes.begin(),parser.aressizes.end(),aressizes.begin());
67 avelbase.assign(parser.avelbase.size(),0);
68 copy(parser.avelbase.begin(),parser.avelbase.end(),avelbase.begin());
69 avelstep.assign(parser.avelstep.size(),0);
70 copy(parser.avelstep.begin(),parser.avelstep.end(),avelstep.begin());
71 avelsizes.assign(parser.avelsizes.size(),0);
72 copy(parser.avelsizes.begin(),parser.avelsizes.end(),avelsizes.begin());
73 strikebase.assign(parser.strikebase.size(),0);
74 copy(parser.strikebase.begin(),parser.strikebase.end(),strikebase.begin());
75 strikestep.assign(parser.strikestep.size(),0);
76 copy(parser.strikestep.begin(),parser.strikestep.end(),strikestep.begin());
77 strikesizes.assign(parser.strikesizes.size(),0);
78 copy(parser.strikesizes.begin(),parser.strikesizes.end(),strikesizes.begin());
79 dstrikebase.assign(parser.dstrikebase.size(),0);
80 copy(parser.dstrikebase.begin(),parser.dstrikebase.end(),dstrikebase.begin());
81 dstrikestep.assign(parser.dstrikestep.size(),0);
82 copy(parser.dstrikestep.begin(),parser.dstrikestep.end(),dstrikestep.begin());
83 dstrikesizes.assign(parser.dstrikesizes.size(),0);
84 copy(parser.dstrikesizes.begin(),parser.dstrikesizes.end(),dstrikesizes.begin());
85 weights.assign(parser.weights.size(),0);
86 copy(parser.weights.begin(),parser.weights.end(),weights.begin());
87 conddiffweight= parser.conddiffweight;
88 anisotropyweight= parser.anisotropyweight;
89 strikediffweight= parser.strikediffweight;
90 veldiffweight= parser.veldiffweight;
91 anisovelweight= parser.anisovelweight;
92 deltastrikediffweight= parser.deltastrikediffweight;
93 avelratio= parser.avelratio;
94 }
95 
96 void AnisoGAJointConf::WriteData(string filename)
97 {
98 ofstream confout(filename.c_str());
99 WriteData(confout);}
100 
101 void AnisoGAJointConf::WriteData(std::ofstream &outstream)
102 {
103 outstream << "verbose" << "=" ;
104 outstream << (verbose ? "true" : "false") << endl;
105 outstream << "mtfitexponent" << "=" ;
106 outstream << mtfitexponent << endl;
107 outstream << "popsize" << "=" ;
108 outstream << popsize << endl;
109 outstream << "inittemp" << "=" ;
110 outstream << inittemp << endl;
111 outstream << "coolingratio" << "=" ;
112 outstream << coolingratio << endl;
113 outstream << "generations" << "=" ;
114 outstream << generations << endl;
115 outstream << "mutationprob" << "=" ;
116 outstream << mutationprob << endl;
117 outstream << "crossoverprob" << "=" ;
118 outstream << crossoverprob << endl;
119 outstream << "threads" << "=" ;
120 outstream << threads << endl;
121 outstream << "starttime" << "=" ;
122 outstream << starttime << endl;
123 outstream << "endtime" << "=" ;
124 outstream << endtime << endl;
125 outstream << "tensorerror" << "=" ;
126 outstream << tensorerror << endl;
127 outstream << "reserror" << "=" ;
128 outstream << reserror << endl;
129 outstream << "phaseerror" << "=" ;
130 outstream << phaseerror << endl;
131 outstream << "gatype" << "=" ;
132 outstream << gatype << endl;
133 outstream << "outputbase" << "=" ;
134 outstream << outputbase << endl;
135 outstream << "mode" << "=" ;
136 outstream << mode << endl;
137 outstream << "mtfit" << "=" ;
138 outstream << mtfit << endl;
139 outstream << "mtinputdata" << "=" ;
140 outstream << mtinputdata << endl;
141 outstream << "ptensordata" << "=" ;
142 outstream << ptensordata << endl;
143 outstream << "annealinggeneration" << "=" ;
144 outstream << annealinggeneration << endl;
145 outstream << "elitist" << "=" ;
146 outstream << (elitist ? "true" : "false") << endl;
147 outstream << "thickbase" << "=" ;
148 for (size_t i = 0; i < thickbase.size(); ++i)
149  outstream << thickbase.at(i) << " ";
150 outstream << endl;
151 
152 outstream << "thickstep" << "=" ;
153 for (size_t i = 0; i < thickstep.size(); ++i)
154  outstream << thickstep.at(i) << " ";
155 outstream << endl;
156 
157 outstream << "thicksizes" << "=" ;
158 for (size_t i = 0; i < thicksizes.size(); ++i)
159  outstream << thicksizes.at(i) << " ";
160 outstream << endl;
161 
162 outstream << "resbase" << "=" ;
163 for (size_t i = 0; i < resbase.size(); ++i)
164  outstream << resbase.at(i) << " ";
165 outstream << endl;
166 
167 outstream << "resstep" << "=" ;
168 for (size_t i = 0; i < resstep.size(); ++i)
169  outstream << resstep.at(i) << " ";
170 outstream << endl;
171 
172 outstream << "ressizes" << "=" ;
173 for (size_t i = 0; i < ressizes.size(); ++i)
174  outstream << ressizes.at(i) << " ";
175 outstream << endl;
176 
177 outstream << "velbase" << "=" ;
178 for (size_t i = 0; i < velbase.size(); ++i)
179  outstream << velbase.at(i) << " ";
180 outstream << endl;
181 
182 outstream << "velstep" << "=" ;
183 for (size_t i = 0; i < velstep.size(); ++i)
184  outstream << velstep.at(i) << " ";
185 outstream << endl;
186 
187 outstream << "velsizes" << "=" ;
188 for (size_t i = 0; i < velsizes.size(); ++i)
189  outstream << velsizes.at(i) << " ";
190 outstream << endl;
191 
192 outstream << "aresbase" << "=" ;
193 for (size_t i = 0; i < aresbase.size(); ++i)
194  outstream << aresbase.at(i) << " ";
195 outstream << endl;
196 
197 outstream << "aresstep" << "=" ;
198 for (size_t i = 0; i < aresstep.size(); ++i)
199  outstream << aresstep.at(i) << " ";
200 outstream << endl;
201 
202 outstream << "aressizes" << "=" ;
203 for (size_t i = 0; i < aressizes.size(); ++i)
204  outstream << aressizes.at(i) << " ";
205 outstream << endl;
206 
207 outstream << "avelbase" << "=" ;
208 for (size_t i = 0; i < avelbase.size(); ++i)
209  outstream << avelbase.at(i) << " ";
210 outstream << endl;
211 
212 outstream << "avelstep" << "=" ;
213 for (size_t i = 0; i < avelstep.size(); ++i)
214  outstream << avelstep.at(i) << " ";
215 outstream << endl;
216 
217 outstream << "avelsizes" << "=" ;
218 for (size_t i = 0; i < avelsizes.size(); ++i)
219  outstream << avelsizes.at(i) << " ";
220 outstream << endl;
221 
222 outstream << "strikebase" << "=" ;
223 for (size_t i = 0; i < strikebase.size(); ++i)
224  outstream << strikebase.at(i) << " ";
225 outstream << endl;
226 
227 outstream << "strikestep" << "=" ;
228 for (size_t i = 0; i < strikestep.size(); ++i)
229  outstream << strikestep.at(i) << " ";
230 outstream << endl;
231 
232 outstream << "strikesizes" << "=" ;
233 for (size_t i = 0; i < strikesizes.size(); ++i)
234  outstream << strikesizes.at(i) << " ";
235 outstream << endl;
236 
237 outstream << "dstrikebase" << "=" ;
238 for (size_t i = 0; i < dstrikebase.size(); ++i)
239  outstream << dstrikebase.at(i) << " ";
240 outstream << endl;
241 
242 outstream << "dstrikestep" << "=" ;
243 for (size_t i = 0; i < dstrikestep.size(); ++i)
244  outstream << dstrikestep.at(i) << " ";
245 outstream << endl;
246 
247 outstream << "dstrikesizes" << "=" ;
248 for (size_t i = 0; i < dstrikesizes.size(); ++i)
249  outstream << dstrikesizes.at(i) << " ";
250 outstream << endl;
251 
252 outstream << "weights" << "=" ;
253 for (size_t i = 0; i < weights.size(); ++i)
254  outstream << weights.at(i) << " ";
255 outstream << endl;
256 
257 outstream << "conddiffweight" << "=" ;
258 outstream << conddiffweight << endl;
259 outstream << "anisotropyweight" << "=" ;
260 outstream << anisotropyweight << endl;
261 outstream << "strikediffweight" << "=" ;
262 outstream << strikediffweight << endl;
263 outstream << "veldiffweight" << "=" ;
264 outstream << veldiffweight << endl;
265 outstream << "anisovelweight" << "=" ;
266 outstream << anisovelweight << endl;
267 outstream << "deltastrikediffweight" << "=" ;
268 outstream << deltastrikediffweight << endl;
269 outstream << "avelratio" << "=" ;
270 outstream << avelratio << endl;
271 }
272 
void GetData(std::ifstream &instream)
void WriteData(std::ofstream &outstream)