20 #include <QTextStream>
23 #include <QStringList>
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 if(afile.open(QIODevice::WriteOnly)) {
85 QTextStream stream(&afile);
87 stream <<
"* ASCO configuration file for '" <<
Name <<
"'\n";
90 stream <<
"#Optimization Flow#\n";
91 stream <<
"Alter:no\n";
92 stream <<
"MonteCarlo:no\n";
93 stream <<
"AlterMC cost:0.00\n";
94 stream <<
"ExecuteRF:no\n";
100 val = pp->
Value.section(
'|',0,0);
101 stream <<
"choice of method:" << val <<
"\n";
102 val = pp->
Value.section(
'|',1,1);
103 stream <<
"maximum no. of iterations:" << val <<
"\n";
104 val = pp->
Value.section(
'|',2,2);
105 stream <<
"Output refresh cycle:" << val <<
"\n";
106 val = pp->
Value.section(
'|',3,3);
107 stream <<
"No. of parents NP:" << val <<
"\n";
108 val= pp->
Value.section(
'|',4,4);
109 stream <<
"Constant F:" << val <<
"\n";
110 val = pp->
Value.section(
'|',5,5);
111 stream <<
"Crossing Over factor CR:" << val <<
"\n";
112 val = pp->
Value.section(
'|',6,6);
113 stream <<
"Seed for pseudo random number generator:" << val <<
"\n";
114 val = pp->
Value.section(
'|',7,7);
115 stream <<
"Minimum Cost Variance:" << val <<
"\n";
116 val = pp->
Value.section(
'|',8,8);
117 stream <<
"Cost objectives:" << val <<
"\n";
118 val = pp->
Value.section(
'|',9,9);
119 stream <<
"Cost constraints:" << val <<
"\n";
122 stream <<
"# Parameters #\n";
124 for(pp =
Props.at(2); pp != 0; pp =
Props.next(), i++) {
125 if(pp->
Name ==
"Var") {
126 stream <<
"Parameter " << i <<
":";
127 val = pp->
Value.section(
'|',0,0);
128 stream <<
"#" << val <<
"#" <<
":";
129 val = pp->
Value.section(
'|',2,2);
130 stream << val <<
":";
131 val = pp->
Value.section(
'|',3,3);
132 stream << val <<
":";
133 val = pp->
Value.section(
'|',4,4);
134 stream << val <<
":";
135 val = pp->
Value.section(
'|',5,5);
136 stream << val <<
":";
137 val = pp->
Value.section(
'|',1,1);
138 stream << ((val ==
"yes") ?
"OPT" :
"---") <<
"\n";
143 stream <<
"# Measurements #\n";
144 for(pp =
Props.at(2); pp != 0; pp =
Props.next(), i++) {
145 if(pp->
Name ==
"Goal") {
146 val = pp->
Value.section(
'|',1,1);
148 Value = pp->
Value.section(
'|',2,2);
149 if (val ==
"MIN" || val ==
"MAX" || val ==
"MON") {
153 val = pp->
Value.section(
'|',0,0);
156 << Type <<
":" << Value <<
"\n";
161 stream <<
"# Post Processing #\n";
168 if(!ExtractDir.cd(
"extract")) {
169 if(!ExtractDir.mkdir(
"extract"))
171 if(!ExtractDir.cd(
"extract"))
175 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
176 if(pp->
Name ==
"Goal") {
177 QString VarName = pp->
Value.section(
'|',0,0);
178 QFile efile(ExtractDir.filePath(VarName));
179 if(efile.open(QIODevice::WriteOnly)) {
180 QTextStream stream(&efile);
181 stream <<
"# Info #\n";
183 stream <<
"# Commands #\n";
185 stream <<
"# Post Processing #\n";
186 stream <<
"MEASURE_VAR:#SYMBOL#:SEARCH_FOR:'<indep " << VarName
187 <<
"':S_COL:01:P_LINE:01:P_COL:01:31" <<
"\n";
207 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
208 if(pp->
Name ==
"Var") {
209 vars += pp->
Value.section(
'|',0,0);
215 if(!infile.open(QIODevice::ReadOnly))
return false;
216 if(!outfile.open(QIODevice::WriteOnly))
return false;
217 QTextStream instream(&infile);
218 QTextStream outstream(&outfile);
220 while(!instream.atEnd()) {
221 Line = instream.readLine();
222 for(QStringList::Iterator it = vars.begin(); it != vars.end(); ++it ) {
223 if(Line.contains(
"Eqn:"))
225 QStringList splitLine = Line.split(
"\"");
227 for(
int i=1;i<splitLine.size()-3;i+=2)
229 if(splitLine[i].compare(
"yes")!=0 && splitLine[i].compare(
"no")!=0)
231 splitLine[i].replace(*it,
"#"+*it+
"#");
234 Line = splitLine.join(
"\"");
239 QRegExp reg = QRegExp(
"=\"(" + *it +
")\"");
240 Line.replace(reg,
"=\"#\\1#\"");
244 outstream << Line <<
"\n";
254 bool changed =
false;
257 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
258 if(pp->
Name ==
"Var") {
259 vars += pp->
Value.section(
'|',0,0);
264 if(!infile.open(QIODevice::ReadOnly))
return false;
265 QTextStream instream(&infile);
267 while(!instream.atEnd()) Line = instream.readLine();
270 QStringList entries = QStringList::split(
':',Line);
271 QStringList::Iterator it;
272 for(it = entries.begin(); it != entries.end(); ++it ) {
274 Name = Name.stripWhiteSpace();
275 if(vars.contains(Name)) {
276 for(pp =
Props.at(2); pp != 0; pp =
Props.next()) {
277 if(pp->
Name ==
"Var") {
279 val[0] = pp->
Value.section(
'|',0,0);
281 val[1] = pp->
Value.section(
'|',1,1);
282 val[2] = pp->
Value.section(
'|',2,2);
283 val[3] = pp->
Value.section(
'|',3,3);
284 val[4] = pp->
Value.section(
'|',4,4);
285 val[5] = pp->
Value.section(
'|',5,5);
288 Value = Value.stripWhiteSpace();
290 pp->
Value = val[0] +
"|" + val[1] +
"|" + val[2] +
"|" +
291 val[3] +
"|" + val[4] +
"|" + val[5];
tQucsSettings QucsSettings
static Element * info(QString &, char *&, bool getNewOne=false)
bool createASCOnetlist()
Optimize_Sim::createASCOnetlist create ASCO netlist out or input input netlist.
Definitions and declarations for the main application.
Q3PtrList< Property > Props
Superclass of all schematic drawing elements.