20 #include <qtextstream.h>
23 #include <qstringlist.h>
44 Props.append(
new Property(
"DE",
"3|50|2|20|0.85|1|3|1e-6|10|100",
false,
""));
58 Name = QObject::tr(
"optimization");
59 BitmapFile = (
char *)
"optimize";
70 s +=
"# ASCO configuration file(s) created\n";
72 s +=
"# Failed to create ASCO configuration file(s)\n";
84 QFile afile(
QucsHomeDir.filePath(
"asco_netlist.cfg"));
85 if(afile.open(IO_WriteOnly)) {
86 QTextStream stream(&afile);
88 stream <<
"* ASCO configuration file for '" <<
Name <<
"'\n";
91 stream <<
"#Optimization Flow#\n";
92 stream <<
"Alter:no\n";
93 stream <<
"MonteCarlo:no\n";
94 stream <<
"AlterMC cost:0.00\n";
95 stream <<
"ExecuteRF:no\n";
101 val = pp->
Value.section(
'|',0,0);
102 stream <<
"choice of method:" << val <<
"\n";
103 val = pp->
Value.section(
'|',1,1);
104 stream <<
"maximum no. of iterations:" << val <<
"\n";
105 val = pp->
Value.section(
'|',2,2);
106 stream <<
"Output refresh cycle:" << val <<
"\n";
107 val = pp->
Value.section(
'|',3,3);
108 stream <<
"No. of parents NP:" << val <<
"\n";
109 val= pp->
Value.section(
'|',4,4);
110 stream <<
"Constant F:" << val <<
"\n";
111 val = pp->
Value.section(
'|',5,5);
112 stream <<
"Crossing Over factor CR:" << val <<
"\n";
113 val = pp->
Value.section(
'|',6,6);
114 stream <<
"Seed for pseudo random number generator:" << val <<
"\n";
115 val = pp->
Value.section(
'|',7,7);
116 stream <<
"Minimum Cost Variance:" << val <<
"\n";
117 val = pp->
Value.section(
'|',8,8);
118 stream <<
"Cost objectives:" << val <<
"\n";
119 val = pp->
Value.section(
'|',9,9);
120 stream <<
"Cost constraints:" << val <<
"\n";
123 stream <<
"# Parameters #\n";
125 for(pp =
Props.at(2); pp != 0; pp =
Props.next(), i++) {
126 if(pp->
Name ==
"Var") {
127 stream <<
"Parameter " << i <<
":";
128 val = pp->
Value.section(
'|',0,0);
129 stream <<
"#" << val <<
"#" <<
":";
130 val = pp->
Value.section(
'|',2,2);
131 stream << val <<
":";
132 val = pp->
Value.section(
'|',3,3);
133 stream << val <<
":";
134 val = pp->
Value.section(
'|',4,4);
135 stream << val <<
":";
136 val = pp->
Value.section(
'|',5,5);
137 stream << val <<
":";
138 val = pp->
Value.section(
'|',1,1);
139 stream << ((val ==
"yes") ?
"OPT" :
"---") <<
"\n";
144 stream <<
"# Measurements #\n";
145 for(pp =
Props.at(2); pp != 0; pp =
Props.next(), i++) {
146 if(pp->
Name ==
"Goal") {
147 val = pp->
Value.section(
'|',1,1);
149 Value = pp->
Value.section(
'|',2,2);
150 if (val ==
"MIN" || val ==
"MAX" || val ==
"MON") {
154 val = pp->
Value.section(
'|',0,0);
157 << Type <<
":" << Value <<
"\n";
162 stream <<
"# Post Processing #\n";
169 if(!ExtractDir.cd(
"extract")) {
170 if(!ExtractDir.mkdir(
"extract"))
172 if(!ExtractDir.cd(
"extract"))
176 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
177 if(pp->
Name ==
"Goal") {
178 QString VarName = pp->
Value.section(
'|',0,0);
179 QFile efile(ExtractDir.filePath(VarName));
180 if(efile.open(IO_WriteOnly)) {
181 QTextStream stream(&efile);
182 stream <<
"# Info #\n";
184 stream <<
"# Commands #\n";
186 stream <<
"# Post Processing #\n";
187 stream <<
"MEASURE_VAR:#SYMBOL#:SEARCH_FOR:'<indep " << VarName
188 <<
"':S_COL:01:P_LINE:01:P_COL:01:31" <<
"\n";
203 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
204 if(pp->
Name ==
"Var") {
205 vars += pp->
Value.section(
'|',0,0);
210 QFile outfile(
QucsHomeDir.filePath(
"asco_netlist.txt"));
211 if(!infile.open(IO_ReadOnly))
return false;
212 if(!outfile.open(IO_WriteOnly))
return false;
213 QTextStream instream(&infile);
214 QTextStream outstream(&outfile);
216 while(!instream.atEnd()) {
217 Line = instream.readLine();
218 for(QStringList::Iterator it = vars.begin(); it != vars.end(); ++it ) {
219 QRegExp reg = QRegExp(
"=\"(" + *it +
")\"");
220 Line.replace(reg,
"=\"#\\1#\"");
222 outstream << Line <<
"\n";
232 bool changed =
false;
235 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
236 if(pp->
Name ==
"Var") {
237 vars += pp->
Value.section(
'|',0,0);
241 QFile infile(
QucsHomeDir.filePath(
"asco_out.log"));
242 if(!infile.open(IO_ReadOnly))
return false;
243 QTextStream instream(&infile);
245 while(!instream.atEnd()) Line = instream.readLine();
248 QStringList entries = QStringList::split(
':',Line);
249 QStringList::Iterator it;
250 for(it = entries.begin(); it != entries.end(); ++it ) {
252 Name = Name.stripWhiteSpace();
253 if(vars.contains(Name)) {
254 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
255 if(pp->
Name ==
"Var") {
257 val[0] = pp->
Value.section(
'|',0,0);
259 val[1] = pp->
Value.section(
'|',1,1);
260 val[2] = pp->
Value.section(
'|',2,2);
261 val[3] = pp->
Value.section(
'|',3,3);
262 val[4] = pp->
Value.section(
'|',4,4);
263 val[5] = pp->
Value.section(
'|',5,5);
266 Value = Value.stripWhiteSpace();
268 pp->
Value = val[0] +
"|" + val[1] +
"|" + val[2] +
"|" +
269 val[3] +
"|" + val[4] +
"|" + val[5];