55 progress +=
"; Datasets: "
58 progress +=
"; Dataset: "
60 +
" (" + tripleID +
") of "
64 progress +=
"; MonteCarlo: "
68 progress +=
"; Meniscus: "
73 progress +=
"; RMSD: "
85 qDebug() <<
" == Refinement Iterations for Dataset"
90 qDebug() <<
" == Refinement Iterations for Datasets 1 to"
94 qDebug() <<
"Iteration:" <<
iterations <<
" Variance:"
104 DbgLv(1) <<
" master loop-BOT: dssize" <<
data_sets.size() <<
"ds_to_p"
111 DbgLv(1) <<
" master loop-BOT: ds" << current_dataset+1 <<
"data l m h"
119 DbgLv(1) <<
" master loop-BOT: GF job_queue empty" <<
job_queue.isEmpty();
147 <<
" Exp-Sim RMSD" << sqrt(
wksim_vals.variance )
164 QString tripleID = QString(
data_sets[ current_dataset ]->model
165 .description ).section(
".", -3, -3 );
174 <<
"(" << tripleID <<
")"
175 <<
" : model was output.";
180 <<
"(" << tripleID <<
")"
181 <<
" : model/noise(s) were output.";
185 if ( current_dataset < count_datasets )
197 double dat_str = edata->
radius( 0 );
199 if ( men_end >= dat_str )
201 men_end = dat_str - men_inc / 2.0;
206 DbgLv(1) <<
" master loop-BOT: menpt" << meniscus_points <<
"mv0 mvn"
221 for (
int ii = 0; ii < calculated_solutes.size(); ii++ )
222 calculated_solutes[ ii ].clear();
244 worker = status.MPI_SOURCE;
247 DbgLv(1) <<
" master loop-BOTTOM: status TAG" << status.MPI_TAG
249 switch( status.MPI_TAG )
261 QString msg =
"Master 2DSA: Received invalid status " +
262 QString::number( status.MPI_TAG );
285 QString model_filename =
data_sets[ 0 ]->model_file;
286 double cnstff0 = 0.0;
288 if ( model_filename.isEmpty() )
291 double s_min =
parameters[
"s_min" ].toDouble() * 1.0e-13;
292 double s_max =
parameters[
"s_max" ].toDouble() * 1.0e-13;
293 double ff0_min =
parameters[
"ff0_min" ].toDouble();
294 double ff0_max =
parameters[
"ff0_max" ].toDouble();
296 int grid_reps = qMax(
parameters[
"uniform_grid" ].toInt(), 1 );
298 double ff0_pts = 60.0;
301 s_pts =
parameters[
"s_grid_points" ].toDouble();
303 else if (
parameters.contains(
"s_resolution" ) )
304 s_pts =
parameters[
"s_resolution" ].toDouble() * grid_reps;
306 if (
parameters.contains(
"ff0_grid_points" ) )
307 ff0_pts =
parameters[
"ff0_grid_points" ].toDouble();
309 else if (
parameters.contains(
"ff0_resolution" ) )
310 ff0_pts =
parameters[
"ff0_resolution" ].toDouble() * grid_reps;
312 int nsstep = (int)( s_pts );
313 int nkstep = (int)( ff0_pts );
316 ff0_min, ff0_max, nkstep,
323 QString fn =
"../" + model_filename;
327 DbgLv(1) <<
"InSol: fn" << fn;
328 DbgLv(1) <<
"Insol: nsubgrid ncomps" << nsubgrid << ncomps;
331 abort(
"Custom grid model file has no subgrids", -1 );
333 if ( ( ncomps / nsubgrid ) > 150 )
335 nsubgrid = ( ncomps / 100 + 1 ) | 1;
337 DbgLv(1) <<
"Insol: nsubgrid sbsize" << nsubgrid << ( ncomps / nsubgrid );
340 QVector< US_Solute > solvec;
342 for (
int ii = 0; ii < nsubgrid; ii++ )
346 for (
int jj = ii; jj < ncomps; jj += nsubgrid )
402 double concentration = 0.0;
411 <<
"Total Concentration" << concentration <<
"==";
417 edata->
ODlimit /= concentration;
421 QVector< double >
scaled_data( scan_count * radius_points + 1 );
426 for (
int ss = 0; ss < scan_count; ss++ )
428 for (
int rr = 0; rr < radius_points; rr++ )
430 double ival=edata->
value(ss,rr);
432 double scaled_value = edata->
value( ss, rr ) / concentration;
433 scaled_data[ index++ ] = scaled_value;
434 edata->
setValue( ss, rr, scaled_value );
439 scaled_data[ index ] = edata->
ODlimit;
440 DbgLv(1) <<
"ScaledData sum" << dsum <<
"iSum" << isum <<
"concen" << concentration;
445 job.
length = scaled_data.size();
453 for (
int worker = 1; worker <=
my_workers; worker++ )
466 MPI_Bcast( scaled_data.data(),
491 for (
int ii = 0; ii < calculated_solutes.size(); ii++ )
492 calculated_solutes[ ii ].clear();
529 qDebug() <<
" MC_Iteration 1 Simulation RMSD"
530 << QString::number( fitrmsd,
'f', 7 );
548 double varrmsd = 0.0;
549 double varisum = 0.0;
550 double varimin = 1.0;
551 double varimax = -1.0;
552 double datasum = 0.0;
556 for (
int ee = ds_start; ee < ds_end; ee++ )
561 int indxh=((scan_count/2)*radius_points)+(radius_points/2);
563 for (
int ss = 0; ss < scan_count; ss++, scnx++ )
565 for (
int rr = 0; rr < radius_points; rr++ )
569 varrmsd +=
sq( variation );
570 varisum += variation;
571 varimin = qMin( varimin, variation );
572 varimax = qMax( varimax, variation );
575 if ( index<5 || index>(
total_points-6) || (index>(indxh-4)&&index<(indxh+3)) )
577 <<
"sigma" <<
sigmas[index] <<
"vari" << variation <<
"mdat" << mcdata;
583 DbgLv(1) <<
"sMC: mcdata sum" << datasum;
585 varrmsd = sqrt( varrmsd / (
double)( ds_points ) );
586 qDebug() <<
" Box_Muller Variation RMSD"
587 << QString::number( varrmsd,
'f', 7 )
588 <<
" for MC_Iteration" << mc_iteration + 1;
590 DbgLv(1) <<
"sMC: variation sum min max" << varisum << varimin << varimax
591 <<
"mcdata sum" << datasum;
597 newdata.
solution = mc_iteration + 1;
605 for (
int worker = 1; worker <=
my_workers; worker++ )
616 DbgLv(1) <<
"sMC: MPI Barrier";
619 DbgLv(1) <<
"sMC: MPI Bcast";
668 for (
int ee = ds_start; ee < ds_end; ee++ )
673 DbgLv(1) <<
"sGA: ee" << ee <<
"scans points" << scan_count << radius_points;
676 for (
int ss = 0; ss < scan_count; ss++, scnx++ )
678 for (
int rr = 0; rr < radius_points; rr++ )
685 DbgLv(1) <<
"sGA: sigmas size" << ssz <<
"sigmas[mm]" <<
sigmas[ssz/2];
705 QVector< US_Solute > solvec;
710 DbgLv(1) <<
"MAST: wrout: mdl_type DMGA";
718 DbgLv(1) <<
"MAST: wrout: mdl_type PCSA mrecs size" <<
mrecs.size();
721 for(
int jj=0;jj<
mrecs.size();jj++)
723 DbgLv(1) <<
"M:wo: jj" << jj <<
"typ tx" <<
mrecs[jj].ctype <<
mrecs[jj].taskx <<
"isz csz"
724 <<
mrecs[jj].isolutes.size() <<
mrecs[jj].csolutes.size() <<
"rmsd" <<
mrecs[jj].rmsd
725 <<
"sy ey" <<
mrecs[jj].str_y <<
mrecs[jj].end_y
726 <<
"p1 p2" <<
mrecs[jj].par1 <<
mrecs[jj].par2;
735 DbgLv(1) <<
"WrO: mxdssz" << mxdssz;
742 DbgLv( 0 ) <<
"*WARNING* Final solutes size" << mxdssz
743 <<
"max_depth" <<
max_depth <<
"Sim and Depth-1 solutes size"
748 DbgLv( 0 ) <<
" SimValues solutes used";
750 else if ( dm1ssz > 0 )
753 DbgLv( 0 ) <<
" CalcValue[mxdepth-1] solutes used";
757 DbgLv( 0 ) <<
" *ERROR* No solutes will be used";
767 DbgLv(1) <<
"WrO: qSort solutes sssz" << sim.
zsolutes.size();
773 DbgLv(1) <<
"WrO: qSort solutes sssz" << sim.
solutes.size();
777 DbgLv(1) <<
"WrO: wr_model mdl_type" << mdl_type;
781 DbgLv(1) <<
"WrO: wr_noise";
782 if (
parameters[
"tinoise_option" ].toInt() > 0 )
785 if (
parameters[
"rinoise_option" ].toInt() > 0 )
788 DbgLv(1) <<
"WrO: wr_mrecs";
791 int tikreg =
parameters[
"tikreg_option" ].toInt();
792 int mc_iters =
parameters[
"mc_iterations" ].toInt();
794 if ( tikreg == 0 && mc_iters < 2 )
810 DbgLv( 0 ) <<
" *ERROR* No solutes available for global model";
816 <<
"simvsols size" << nsolutes;
825 DbgLv(1) <<
"WrGlob: glob recompute nsols" <<
wksim_vals.solutes.size()
826 <<
"globrec A,b sizes" << gl_nnls_a.size() <<
gl_nnls_b.size();
828 for (
int ee = 0; ee <
data_sets.size(); ee++ )
834 DbgLv(1) <<
"WrGlob: currds" << ee <<
"concen" << concentration;
836 for (
int cc = 0; cc < nsolutes; cc++ )
841 DbgLv(1) <<
"WrGlob: call write_model(1)";
850 int narows = kscans * kpoints;
851 int navals = narows * nsolutes;
853 QVector< double > nnls_a( navals, 0.0 );
854 QVector< double > nnls_b( narows, 0.0 );
855 QVector< double > nnls_x( nsolutes, 0.0 );
856 DbgLv(1) <<
"WrGlob: ks kp nar nav" << kscans << kpoints << narows << navals;
860 DbgLv(1) <<
"WrGlob: mats built; calling NNLS";
862 nnls_b.data(), nnls_x.data() );
864 DbgLv(1) <<
"WrGlob: building solutes from nnls_x";
865 for (
int cc = 0; cc < nsolutes; cc++ )
867 double soluval = nnls_x[ cc ];
876 DbgLv(1) <<
"WrGlob: currds" << ee <<
"nsol ksol" << nsolutes << ksolutes;
887 for (
int ee = 0; ee <
data_sets.size(); ee++ )
899 DbgLv(1) <<
"WrGlob: currds" << ee <<
"nsol ksol" << nsolutes << ksolutes;
930 for (
int jj = 0; jj < nsols; jj++ )
962 for (
int s = 0; s < prev_solutes.size(); s++ )
964 if ( ! job.
solutes.contains( prev_solutes[ s ] ) )
966 job.
solutes << prev_solutes[ s ];
974 job.solutes.size() );
994 DbgLv(1) <<
"2dsa master shutdown : master maxrss" <<
maxrss;
1006 DbgLv(1) <<
"2dsa master shutdown : worker" << i <<
" upd. maxrss" <<
maxrss
1021 if (dd==0) {
DbgLv(1) <<
"Mast: submit: worker" << worker <<
" sols"
1023 else {
DbgLv(1) <<
"Mast: submit: worker" << worker <<
" sols"
1025 DbgLv(1) <<
"Mast: submit: len sol offs cnt"
1038 DbgLv(1) <<
"Mast: submit: send #1";
1047 DbgLv(1) <<
"Mast: submit: send #2";
1055 for (
int qq = 0; qq <
job_queue.size(); qq++ )
1057 if ( jdepth <
job_queue[ qq ].mpi_job.depth )
1126 if (depth == 0) {
DbgLv(1) <<
"Mast: process_results: worker" << worker
1127 <<
" solsize" << size[0] <<
"depth" << depth; }
1128 else {
DbgLv(1) <<
"Mast: process_results: worker" << worker
1129 <<
" solsize" << size[0] <<
"depth" << depth; }
1131 result.
depth = depth;
1161 depth = result.
depth;
1170 QVector< US_Solute >& result_solutes )
1172 DbgLv(1) <<
"Mast: process_solutes: worker" << worker
1173 <<
" solsize" << result_solutes.size() <<
"depth" << depth;
1174 int next_depth = depth + 1;
1181 int rsol_size = result_solutes.size();
1182 int new_size = csol_size + rsol_size;
1196 DbgLv(1) <<
"Mast: queue NEW DEPTH sols" << job.
solutes.size() <<
" d="
1202 new_size = rsol_size * 2;
1208 <<
"from new_size rsol_size" << new_size << rsol_size;
1221 if ( depth == 0 &&
max_depth > 0 ) dcheck = 1;
1223 for (
int d = 0; d < dcheck; d++ )
1225 bool queued =
false;
1226 for (
int q = 0; q <
job_queue.size(); q++ )
1228 if (
job_queue[ q ].mpi_job.depth <= d )
1235 bool working =
false;
1247 if ( ! working && ! queued && remainder > 0 )
1258 DbgLv(1) <<
"Mast: queue REMAINDER" << remainder <<
" d=" << d+1;
1265 bool working =
false;
1284 csol_size > rsol_size )
1293 DbgLv(1) <<
"Mast: queue LAST ns=" << job.
solutes.size() <<
" d=" << depth+1
1311 calculated_solutes << QVector< US_Solute >();
1315 DbgLv(1) <<
"Mast: WARNING: LAST depth and no worker ready!";
1323 abort(
"Max Depth is exceeding 20" );
1361 QString runID = edata->
runID;
1370 runID =
"Global-" + runID;
1397 DbgLv(1) <<
"wrMo: tripleID" << tripleID <<
"dates" << dates;
1401 iterID.sprintf(
"mc%04d", mc_iter );
1403 iterID.sprintf(
"i%02d-m%05d",
1409 QString mdlid = tripleID +
"." + iterID;
1410 QString
id = model.
typeText( subtype );
1412 id =
id.replace(
"2DSA",
"2DSA-CG" );
1413 QString analyID = dates +
"_" +
id +
"_" +
requestID +
"_" + iterID;
1417 model.
description = runID +
"." + tripleID +
"." + analyID +
".model";
1425 for (
int ii = 0; ii < sim.
zsolutes.size(); ii++ )
1431 component.
name = QString().sprintf(
"SC%04d", ii + 1 );
1440 for (
int ii = 0; ii < sim.
solutes.size(); ii++ )
1445 component.
s = solute->
s;
1446 component.
f_f0 = solute->
k;
1447 component.
name = QString().sprintf(
"SC%04d", ii + 1 );
1455 DbgLv(1) <<
"wrMo: stype" << stype << QString().sprintf(
"0%o",stype)
1456 <<
"attr_z vbar20 mco0.v" <<
attr_z << vbar20 << model.
components[0].vbar20;
1458 QString fext = model.
monteCarlo ?
".mdl.tmp" :
".model.xml";
1459 QString fileid =
"." +
id +
"." + mdlid + fext;
1460 QString fn = runID + fileid;
1461 int lenfn = fn.length();
1465 int lenri = runID.length() + 99 - lenfn;
1466 fn = runID.left( lenri ) + fileid;
1476 QFile fileo(
"analysis_files.txt" );
1478 if ( ! fileo.open( QIODevice::WriteOnly | QIODevice::Text
1479 | QIODevice::Append ) )
1481 abort(
"Could not open 'analysis_files.txt' for writing" );
1485 QTextStream tsout( &fileo );
1488 QString variance = QString::number( sim.
variance,
'e', 4 );
1497 QString runstring =
"Run: " + QString::number( run ) +
" " + tripleID;
1500 <<
";MC_iteration=" << mc_iter
1502 <<
";run=" << runstring
1509 const QVector< double >& noise_data )
1549 anType = anType.replace(
"2DSA",
"2DSA-CG" );
1563 QString analysID = dates + anType +
requestID +
"_" + iterID;
1566 +
"." + type_name +
"_noise";
1571 noise.
values = noise_data;
1572 noise.
count = noise_data.size();
1581 for (
int j = 0; j < noise_filenames.size(); j++ )
1583 QString fn =
"../" + noise_filenames[ j ];
1584 input_noise.
load( fn );
1585 if ( input_noise.
type == type ) noise.
sum_noise( input_noise );
1588 QString fn = type_name +
".noise." + noise.
noiseGUID +
".xml";
1592 QFile f(
"analysis_files.txt" );
1593 if ( ! f.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append ) )
1595 abort(
"Could not open 'analysis_files.txt' for writing", -1 );
1599 QTextStream out( &f );
1610 worker = ( worker > 0 ) ? worker :
1614 worknext = ( worker > 0 ) ? ( worker + 1 ) : 1;
1616 DbgLv(1) <<
"ready_worker w1 w1n worker worknext" << w1 << w1n << worker <<
worknext;
1618 DbgLv(1) <<
"ready_worker w1234...wmn"
1647 int rdepth = result.
depth;
1653 if ( rdepth < cdepth )
1670 QStringList files = odir.entryList( QStringList(
"*" ), QDir::Files );
1672 <<
"files size" << files.size();
1674 if ( files.size() == 1 && files[ 0 ] ==
"analysis-results.tar" )
1676 DbgLv(0) <<
my_rank <<
": A single output file, the archive, already exists!!!";
1681 files.removeOne(
"analysis-results.tar" );
1692 mfilt <<
"*.mdl.tmp" <<
"*.model.xml";
1693 QStringList mfiles = odir.entryList( mfilt, QDir::Files );
1698 for (
int ii = 0; ii < mfiles.size(); ii++ )
1700 QString mftrip = QString( mfiles[ ii ] ).section(
".", 0, -4 );
1701 if ( ! mtrips.contains( mftrip ) )
1707 QFile filet(
"analysis_files.txt" );
1708 if ( filet.open( QIODevice::ReadOnly | QIODevice::Text ) )
1710 QTextStream tstxt( &filet );
1711 while ( ! tstxt.atEnd() )
1713 QString line = tstxt.readLine();
1714 QString fname = line.section(
";", 0, 0 );
1721 QFile fileo(
"analysis_files.txt" );
1722 if ( ! fileo.open( QIODevice::WriteOnly | QIODevice::Text
1723 | QIODevice::Append ) )
1725 abort(
"Could not open 'analysis_files.txt' for writing" );
1728 QTextStream tsout( &fileo );
1731 for (
int ii = 0; ii < mtrips.size(); ii++ )
1734 QString mftrip = mtrips[ ii ];
1735 QString tripleID = QString( mftrip ).section(
".", -1, -1 );
1737 mfilt << mftrip +
".mc0*";
1738 QStringList mtfiles = odir.entryList( mfilt, QDir::Files );
1742 DbgLv(0) <<
my_rank <<
": ii" << ii <<
"mftrip" << mftrip <<
"cmfname" << cmfname;
1744 if ( cmfname.isEmpty() )
continue;
1747 for (
int jj = 0; jj < mtfiles.size(); jj++ )
1749 if ( mtfiles[ jj ] != cmfname )
1751 files.removeOne( mtfiles[ jj ] );
1752 DbgLv(0) <<
my_rank <<
": ii,jj" << ii << jj <<
"REMOVED from list:" << mtfiles[jj];
1757 if ( ! files.contains( cmfname ) )
1760 DbgLv(0) <<
my_rank <<
": files.size" << files.size() <<
"after cmfname add";
1764 int f_iters = QString( cmfname ).section(
".", -3, -3 )
1766 if ( ! tfiles.contains( cmfname ) &&
1770 DbgLv(0) <<
my_rank <<
": model2.load(" << cmfname <<
")";
1771 model2.
load( cmfname );
1773 QString runstring =
"Run: " + QString::number( ii + 1 )
1776 <<
";meniscus_value=" << model2.
meniscus
1779 <<
";run=" << runstring <<
"\n";
1783 int mrx =
mrecs[ 2 ].taskx ==
mrecs[ 0 ].taskx ? 2 : 1;
1794 tar.
create(
"analysis-results.tar", files );
1795 for(
int jf=0;jf<files.size();jf++)
1796 DbgLv(0) <<
my_rank <<
" tar file" << jf <<
":" << files[jf];
1801 DbgLv(0) <<
my_rank <<
": All output files except the archive are now removed.";
1803 foreach( file, files ) odir.remove( file );
1812 if ( a_type.startsWith(
"GA" ) )
1814 else if ( a_type.startsWith(
"DMGA" ) )
1816 else if ( a_type.startsWith(
"PCSA" ) )