16 QList< US_SolveSim::DataSet* >& dsets, QWidget*
p )
51 DbgLv(0) <<
"*ERROR* AnalysisControl has no pointer back to Main PCSA";
52 QMessageBox::critical(
this, tr(
"Parent Pointer NULL!" ),
53 tr(
"*ERROR* AnalysisControl has no pointer back to Main PCSA" ) );
58 setObjectName(
"US_AnalysisControlPc" );
59 setAttribute( Qt::WA_DeleteOnClose,
true );
63 QFontMetrics fmet( font() );
67 tr(
"Parametrically Constrained Spectrum Analysis Controls" ) );
79 QLabel* lb_fitting =
us_banner( tr(
"Fitting Controls:" ) );
80 QLabel* lb_curvtype =
us_label( tr(
"Curve Type:" ) );
81 QLabel* lb_x_type =
us_label( tr(
"X Axis Type:" ) );
82 QLabel* lb_y_type =
us_label( tr(
"Y Axis Type:" ) );
83 QLabel* lb_z_type =
us_label( tr(
"Z Axis Type:" ) );
84 QLabel* lb_z_value =
us_label( tr(
"Z Value/Coeffs." ) );
85 QLabel* lb_range_x =
us_label( tr(
"X range:" ) );
86 QLabel* lb_range_y =
us_label( tr(
"Y range:" ) );
87 QLabel* lb_varcount =
us_label( tr(
"Variations Count:" ) );
88 QLabel* lb_gfiters =
us_label( tr(
"Grid Fit Iterations:" ) );
89 QLabel* lb_gfthresh =
us_label( tr(
"Threshold Delta-RMSD Ratio:" ) );
90 QLabel* lb_cresolu =
us_label( tr(
"Curve Resolution Points:" ) );
91 QLabel* lb_lmmxcall =
us_label( tr(
"Maximum L-M Evaluate Calls:" ) );
92 QLabel* lb_tralpha =
us_label( tr(
"Regularization Parameter:" ) );
93 QLabel* lb_thrdcnt =
us_label( tr(
"Thread Count:" ) );
94 QLabel* lb_minvari =
us_label( tr(
"Best Model Variance:" ) );
95 QLabel* lb_minrmsd =
us_label( tr(
"Best Model RMSD:" ) );
96 QLabel* lb_status =
us_label( tr(
"Status:" ) );
120 rb_x_s ->setChecked(
true );
122 rb_y_s ->setEnabled(
false );
124 QLabel* lb_statinfo =
us_banner( tr(
"Status Information:" ) );
139 QLayout* lo_lmalpha =
141 QLayout* lo_fxalpha =
151 nthr = ( nthr > 1 ) ? nthr : QThread::idealThreadCount();
152 DbgLv(1) <<
"idealThrCout" << nthr;
179 cb_curvtype->addItem(
"Horizontal Line [ C(s) ]" );
260 le_minrmsd->setMinimumWidth( lb_minrmsd->width() );
261 te_status ->setMinimumWidth( lb_minrmsd->width()*4 );
264 edata = &dsets[ 0 ]->run_data;
265 double vbar = dsets[ 0 ]->vbar20;
266 le_z_func->setText( QString::number( vbar ) );
275 connect(
ct_tralpha, SIGNAL( valueChanged(
double ) ),
288 connect(
pb_plot, SIGNAL( clicked() ),
289 this, SLOT(
plot() ) );
290 connect(
pb_save, SIGNAL( clicked() ),
291 this, SLOT(
save() ) );
294 connect(
pb_help, SIGNAL( clicked() ),
295 this, SLOT(
help() ) );
296 connect(
pb_close, SIGNAL( clicked() ),
303 int fwidth = fmet.maxWidth();
305 int cminw = fwidth * 7;
306 int csizw = cminw + fwidth;
329 qApp->processEvents();
337 bool use_noise = (
ct_tralpha->value() == 0.0 );
342 qApp->processEvents();
361 tr(
"The \"s\" or \"f/f0\" ranges are inconsistent.\n"
362 "Please re-check the limits and correct them\n"
363 "before again clicking \"Start Fit\"." );
365 QMessageBox::critical(
this, tr(
"Limits Inconsistent!" ), msg );
377 dsets[ 0 ]->zcoeffs[ 1 ] = 0.0;
378 dsets[ 0 ]->zcoeffs[ 2 ] = 0.0;
379 dsets[ 0 ]->zcoeffs[ 3 ] = 0.0;
380 DbgLv(1) <<
"AnaC: (A)zcoeff0" <<
dsets[0]->zcoeffs[0];
413 QMessageBox::critical(
this,
414 tr(
"Implied Grid Size is Too Large!" ), smsg );
431 int noif = (
ck_tinoise->isChecked() ? 1 : 0 ) +
448 else if (
ck_fxalpha->isChecked() && alpha != 0.0 )
449 alpha = -alpha - 1.0;
450 else if (
ck_lmalpha->isChecked() && alpha != 0.0 )
465 connect(
processor, SIGNAL( progress_update(
double ) ),
467 connect(
processor, SIGNAL( message_update( QString,
bool ) ),
469 connect(
processor, SIGNAL( stage_complete(
int,
int ) ),
471 connect(
processor, SIGNAL( process_complete(
int ) ),
480 DbgLv(1) <<
"(2)pb_plot-Enabled" <<
pb_plot->isEnabled();
482 qApp->processEvents();
486 nthr, noif, lmmxc, gfits, gfthr, alpha );
491 qApp->processEvents();
497 DbgLv(1) <<
"AC:SF:StopFit";
506 qApp->processEvents();
507 DbgLv(1) <<
"(3)pb_plot-Enabled" <<
pb_plot->isEnabled();
514 DbgLv(1) <<
"AC:SF: processor stopping...";
517 DbgLv(1) <<
"AC:SF: processor stopped";
520 qApp->processEvents();
536 DbgLv(1) <<
"AC:advanced";
537 DbgLv(1) <<
"AC:advanced mrecs.size" <<
mrecs.size();
539 DbgLv(1) <<
"AC:advanced mrecs0 p1 p2" <<
mrecs[0].par1 <<
mrecs[0].par2
540 <<
"ctype" <<
mrecs[0].ctype;
546 if ( aadiag->exec() == QDialog::Accepted )
548 DbgLv(1) <<
"AC:advanced dialog exec() return - ACCEPTED";
550 bool mrsupd = ( ( state & 3 ) != 0 );
551 bool mmcupd = ( ( state & 4 ) != 0 );
552 int ncsols = mrsupd ?
mrecs[ 0 ].csolutes.size() : 0;
553 double rmsdf = mrsupd ?
mrecs[ 0 ].rmsd : 0.0;
554 double varif = mrsupd ?
mrecs[ 0 ].variance : 0.0;
555 int mciter = mmcupd ?
mrecs_mc.size() : 0;
556 DbgLv(1) <<
"AC:advanced dialog state=" << state <<
"mainw" << mainw;
557 DbgLv(1) <<
"AC:adv:(1)rmsd" <<
mrecs[0].rmsd;
561 QMessageBox::warning(
this, tr(
"Problematic combination!" ),
562 tr(
"The combination of one or two noise fits selected and "
563 "Advanced Controls chosen is problematic, since model "
564 "records only specify fitting curves and not noise "
566 "You may proceed, but the safest course is to click on "
567 "the Recompute Best Model button to re-fit with noises.\n\n"
568 "Any Save Results where noise is involved is better "
569 "executed *before* Advanced Controls." ) );
581 DbgLv(1) <<
"AC:adv:(2)rmsd" <<
mrecs[0].rmsd;
587 DbgLv(1) <<
"AC:advanced: mrec0 sols" <<
mrecs[0].csolutes.size()
588 <<
"mrecs size" <<
mrecs.size() <<
"mrecs_mc size" <<
mrecs_mc.size()
594 "\nA newer best model has been created by %1 Monte Carlo\n"
595 " iterations ( %2-solute, with RMSD = %3 )" )
596 .arg( mciter ).arg( ncsols ).arg( rmsdf );
599 le_minvari->setText( QString::number( varif ) );
600 le_minrmsd->setText( QString::number( rmsdf ) );
606 "\nA newer best model has been created from Advanced Controls\n"
607 " action ( %1-solute, with RMSD = %2 )" )
608 .arg( ncsols ).arg( rmsdf );
611 le_minvari->setText( QString::number( varif ) );
612 le_minrmsd->setText( QString::number( rmsdf ) );
614 DbgLv(1) <<
"AC:adv:(3)rmsd" <<
mrecs[0].rmsd;
628 DbgLv(1) <<
"AC:adv:(4)rmsd" <<
mrecs[0].rmsd;
639 dsets[ 0 ]->zcoeffs[ 1 ] = 0.0;
640 dsets[ 0 ]->zcoeffs[ 2 ] = 0.0;
641 dsets[ 0 ]->zcoeffs[ 3 ] = 0.0;
644 DbgLv(1) <<
"AC:advanced: put_mrecs";
645 DbgLv(1) <<
"AC:adv:putm: rmsd" <<
mrecs[0].rmsd;
647 DbgLv(1) <<
"AC:advanced: get_results";
652 int v_ctype =
mrecs[ 0 ].v_ctype;
653 int nmrecs =
mrecs.size();
654 int nmtsks = (
mrecs[ 0 ].taskx ==
mrecs[ 1 ].taskx )
655 ? ( nmrecs - 1 ) : nmrecs;
656 nmtsks = (
mrecs[ 1 ].taskx ==
mrecs[ 2 ].taskx )
657 ? ( nmrecs - 1 ) : nmrecs;
658 int strec = nmrecs - nmtsks;
663 : qRound( pow( (
double)
nypts, 0.33333 ) );
669 int stype =
mrecs[ 0 ].stype;
670 int attr_x = ( stype >> 6 ) & 7;
671 int attr_y = ( stype >> 3 ) & 7;
675 for (
int ii = strec; ii < nmrecs; ii++ )
677 QVector< US_ZSolute >* isolutes = &
mrecs[ ii ].isolutes;
678 nlpts = isolutes->size();
682 for (
int jj = 0; jj <
nlpts; jj++ )
684 double xval = (*isolutes)[ jj ].x * xscl;
685 double yval = (*isolutes)[ jj ].y * yscl;
706 mainw->analysis_done( 0 );
710 DbgLv(1) <<
"AC:advanced dialog exec() return - CANCELED";
731 if ( (QObject*)
mlnplotd != (QObject*)0 )
751 double limlo = -1.e6;
756 if ( loval < -1.e5 || upval > 1.e5 )
758 if ( loval < -1.e6 || upval > 1.e6 )
760 if ( loval < -1.e7 || upval > 1.e7 )
818 bool regular = (
ct_tralpha->value() != 0.0 );
826 pb_finalmdl->setText( tr(
"Regularize Current Model" ) );
833 pb_finalmdl->setText( tr(
"Recompute Best Model" ) );
855 double rmsd = sqrt( variance );
860 le_minrmsd->setText( QString::number( rmsd ) );
882 qApp->processEvents();
888 DbgLv(1) <<
"AC:cs: prmx nct kcs" <<
b_progress->maximum() << nct << kcs;
895 qApp->processEvents();
902 DbgLv(1) <<
"AC:cp: stage" << stage;
909 double rmsd = mrec.
rmsd;
910 le_minvari->setText( QString::number( vari ) );
911 le_minrmsd->setText( QString::number( rmsd ) );
912 DbgLv(1) <<
"AC:cp: mrec fetched";
934 QStringList modelstats;
949 DbgLv(1) <<
"AC:cp: main done -2";
952 DbgLv(1) <<
"AC:cp: main done 0";
962 DbgLv(1) <<
"(1)pb_plot-Enabled" <<
pb_plot->isEnabled();
967 double vari =
mrecs[ 0 ].variance;
968 double rmsd =
mrecs[ 0 ].rmsd;
969 le_minvari->setText( QString::number( vari ) );
970 le_minrmsd->setText( QString::number( rmsd ) );
977 double parlims[ 12 ];
992 parlims[ 5 ] =
le_z_func->text().section(
" ", 0, 0 ).toDouble();
1021 DbgLv(1) <<
"AC:CM: mrecs0.sol0 x y z c"
1022 <<
mrecs[0].isolutes[0].x <<
mrecs[0].isolutes[0].y
1023 <<
mrecs[0].isolutes[0].z <<
mrecs[0].isolutes[0].c;
1026 tr(
"The number of test models is %1,\n" ).arg( nlmodl );
1029 amsg += tr(
" derived from the cube of %1 variation points,\n" )
1032 else if (
ctype != 8 )
1034 amsg += tr(
" derived from the square of %1 variation points,\n" )
1037 amsg += tr(
" with each curve model consisting of %1 points." )
1068 DbgLv(1) <<
"PL: mlnplotd closed";
1073 connect(
mlnplotd, SIGNAL( destroyed( QObject* ) ),
1074 this, SLOT (
closed ( QObject* ) ) );
1080 DbgLv(1) <<
"PL: mlp: setModel bmndx" <<
bmndx;
1085 DbgLv(1) <<
"PL: mlp: setModel model=0";
1089 DbgLv(1) <<
"PL: mlp: call plot_data";
1091 DbgLv(1) <<
"PL: mlp: rtn fr plot_data";
1097 + QString::number( getpid() ) +
".png";
1098 QPixmap pixmap = QPixmap::grabWidget(
mlnplotd, 0, 0,
1100 DbgLv(0) <<
"PLOTLINE: mlines filepath" << filepath;
1101 DbgLv(0) <<
"PLOTLINE: mlines w h" << pixmap.width() << pixmap.height();
1102 pixmap.save( filepath );
1108 QString oname = o->objectName();
1110 if ( oname.contains(
"MLinesPlot" ) )
1134 DbgLv(1) <<
"AC:sa: nthr klp nlp" << nthr << klpts <<
nlpts;
1136 if ( klpts != nlpts )
1147 DbgLv(1) <<
"AC:sa: RpScan created";
1149 if ( rpscand->exec() == QDialog::Accepted )
1151 DbgLv(1) <<
"AC:sa: alpha fetched" << alpha;
1156 DbgLv(1) <<
"AC:sa: RpScan deleting";
1159 DbgLv(1) <<
"AC:sa: RpScan deleted";
1172 DbgLv(1) <<
"AC:fo: klp nlp" << klpts <<
nlpts;
1174 if ( klpts != nlpts )
1192 int noif = (
ck_tinoise->isChecked() ? 1 : 0 ) +
1196 return QString().sprintf(
"%d %.5e %.5e %.5e %.5e %d %d",
1197 typ, xlo, xup, ylo, yup, nvar, noif );
1205 connect(
bg_x_axis, SIGNAL( buttonReleased(
int ) ),
1207 connect(
bg_y_axis, SIGNAL( buttonReleased(
int ) ),
1209 connect(
cb_curvtype, SIGNAL( activated (
int ) ),
1211 connect(
ct_lolimitx, SIGNAL( valueChanged (
double ) ),
1213 connect(
ct_uplimitx, SIGNAL( valueChanged (
double ) ),
1215 connect(
ct_lolimity, SIGNAL( valueChanged (
double ) ),
1217 connect(
ct_uplimity, SIGNAL( valueChanged (
double ) ),
1219 connect(
cb_z_type, SIGNAL( activated (
int ) ),
1221 connect(
ct_varcount, SIGNAL( valueChanged (
double ) ),
1223 connect(
ct_cresolu, SIGNAL( valueChanged (
double ) ),
1266 double str_y = mrec.
str_y;
1267 double end_y = mrec.
end_y;
1268 double par1 = mrec.
par1;
1269 double par2 = mrec.
par2;
1270 double par3 = mrec.
par3;
1271 double prng = (double)(
nlpts - 1 );
1273 int stype = mrec.
stype;
1274 int attr_x = ( stype >> 6 ) & 7;
1275 int attr_y = ( stype >> 3 ) & 7;
1278 isol.
z =
le_z_func->text().section(
" ", 0, 0 ).toDouble();
1283 double xinc = xrng / prng;
1284 double yval = str_y;
1285 double yinc = ( end_y - str_y ) / prng;
1287 for (
int kk = 0; kk <
nlpts; kk++ )
1289 isol.
x = xval * xscl;
1290 isol.
y = yval * yscl;
1304 double xoinc = 1.0 / prng;
1305 double p1rt = sqrt( 2.0 * par1 );
1307 for (
int kk = 0; kk <
nlpts; kk++ )
1309 double xval = xmin + xoff * xrng;
1310 double efac = 0.5 * erf( ( xoff - par2 ) / p1rt ) + 0.5;
1311 double yval = ystr + ydif * efac;
1312 isol.
x = xval * xscl;
1313 isol.
y = yval * yscl;
1322 double xinc = xrng / prng;
1323 double yval = end_y;
1325 for (
int kk = 0; kk <
nlpts; kk++ )
1327 isol.
x = xval * xscl;
1328 isol.
y = yval * yscl;
1337 double xinc = xrng / prng;
1339 for (
int ll = 0; ll <
nlpts; ll++ )
1341 isol.
x = xval * xscl;
1342 double yval = par1 * pow( xval, par2 ) + par3;
1343 isol.
y = yval * yscl;
1352 DbgLv(1) <<
"AC:RM: NEW mrec0 solsize" << mrec.
isolutes.size()
1362 const double mb_fact = ( 1024. * 1024. );
1363 const double x_fact = 19.25;
1364 const double y_fact = 2.43;
1365 const int pc_ava = 90;
1366 const int nxdata = 4;
1376 int idsize = nscans * npoints *
sizeof( double );
1379 double dsize = (double)idsize * (
double)( nsols + nxdata ) / mb_fact;
1380 double msize = ( x_fact + dsize * y_fact ) * (
double)nthrds;
1381 int memneed = baserss + qRound( msize );
1382 int memtot, memava, memuse;
1384 int memsafe = ( memava * pc_ava ) / 100;
1385 int idsz = qRound(dsize);
1386 int imsz = qRound(msize);
1387 DbgLv(1) <<
"MEMck: memtot,ava,use,safe,need" << memtot << memava << memuse
1388 << memsafe << memneed <<
"dsz msz ns nt" << idsz << imsz << nsols << nthrds;
1390 if ( memneed > memsafe || mempca < 20 )
1392 QString title = tr(
"High Memory Usage" );
1393 QString memp = tr(
"\n\nMemory Profile --\n"
1395 " Available: %2 MB\n"
1397 " Estimated Need: %4 MB\n\n" )
1398 .arg( memtot ).arg( memava ).arg( memuse ).arg( memneed );
1400 if ( memneed > memtot )
1402 QMessageBox::critical(
this, title,
1403 tr(
"Memory needed for this fit exceeds total available." )
1404 + memp + tr(
"This fit will not proceed.\n"
1405 "Re-parameterize the fit with adjusted\n"
1406 "Curve Resolution Points and/or\n"
1407 "Thread Count." ) );
1413 QMessageBox msgBox(
this );
1414 msgBox.setWindowTitle( title );
1415 msgBox.setText( tr(
"Memory needed for this fit is a\n"
1416 "high percentage of the available memory." )
1418 tr(
"You may proceed if you wish (\"Yes\")\n"
1419 "Or you may stop this fit (\"No\")\n"
1420 "then re-parameterize the fit with adjusted\n"
1421 "Curve Resolution Points and/or\n"
1422 "Thread Count.\n\nProceed?" ) );
1423 msgBox.addButton( QMessageBox::No );
1424 msgBox.addButton( QMessageBox::Yes );
1425 msgBox.setDefaultButton( QMessageBox::No );
1427 if ( msgBox.exec() == QMessageBox::No )
1438 qDebug() <<
"SelX: ival" << ival;
1445 attr_y = ( attr_y <
ATTR_D ) ? ( attr_y + 1 ) :
ATTR_S;
1446 qDebug() <<
"SelX: NEW attr_y" <<
attr_y;
1449 rb_y_s ->setChecked(
true );
1450 else if ( attr_y ==
ATTR_K )
1452 else if ( attr_y ==
ATTR_W )
1454 else if ( attr_y ==
ATTR_V )
1456 else if ( attr_y ==
ATTR_D )
1457 rb_y_D ->setChecked(
true );
1499 qDebug() <<
"SelY: ival" << ival;
1546 const double vllos[] = { 1.0, 1.0, 2e+4, 0.60, 1e-8 };
1547 const double vlhis[] = { 10.0, 4.0, 1e+5, 0.80, 1e-7 };
1548 const double vdefs[] = { 5.0, 1.5, 5e+4, 0.72, 5e-8 };
1549 const double vmins[] = { -10000.0, 1.0, 0.0, 0.01, 1e-9 };
1550 const double vmaxs[] = { 10000.0, 50.0, 1e+10, 3.00, 1e-5 };
1551 const double vincs[] = { 0.01, 0.01, 1000.0, 0.01, 1e-9 };
1554 double xlow = vllos[
attr_x ];
1555 double xhigh = vlhis[
attr_x ];
1558 double xinc = vincs[
attr_x ];
1559 double ylow = vllos[
attr_y ];
1560 double yhigh = vlhis[
attr_y ];
1577 else if ( chg_ndx == 2 )
1585 ?
dsets[ 0 ]->vbar20
1587 le_z_func->setText( QString::number( zdef ) );
1608 dsets[ 0 ]->zcoeffs[ 0 ] =
le_z_func->text().section(
" ", 0, 0 )
1610 dsets[ 0 ]->zcoeffs[ 1 ] = 0.0;
1611 dsets[ 0 ]->zcoeffs[ 2 ] = 0.0;
1612 dsets[ 0 ]->zcoeffs[ 3 ] = 0.0;