28 int ntscan =
data_sets[ 0 ]->run_data.scanCount();
29 for (
int ii = 1; ii <
data_sets.size(); ii++ )
30 ntscan +=
data_sets[ ii ]->run_data.scanCount();
40 QString cmfname =
"../" +
parameters[
"DC_model" ];
44 DbgLv(1) <<
"dmga_master: cmfname" << cmfname;
52 QString attrtype = tr(
"UNKNOWN" );
54 QVector< US_dmGA_Constraints::Constraint > cnsv;
58 int compno = mcompx + 1;
61 DbgLv(0) <<
" Component" << compno <<
":";
65 for (
int cx = 0; cx <
ncompc; cx++ )
67 atype = cnsv[ cx ].atype;
69 bool floats = cnsv[ cx ].floats;
70 bool logscl = cnsv[ cx ].logscl;
71 double vmin = cnsv[ cx ].low;
72 double vmax = cnsv[ cx ].high;
73 attrtype = tr(
"UNKNOWN" );
77 attrtype = tr(
"Segmentation Coefficient" );
79 attrtype = tr(
"Frictional Ratio" );
81 attrtype = tr(
"Molecular Weight" );
83 attrtype = tr(
"Diffusion Coefficient" );
85 attrtype = tr(
"Frictional Coefficient" );
87 attrtype = tr(
"Vbar (Specific Density)" );
89 attrtype = tr(
"Signal Concentration" );
91 attrtype = tr(
"Extinction" );
100 DbgLv(0) <<
" " << attrtype <<
"floats from "
101 << vmin <<
"to" << vmax <<
"(log scale)";
106 DbgLv(0) <<
" " << attrtype <<
"floats from "
107 << vmin <<
"to" << vmax;
113 DbgLv(0) <<
" " << attrtype <<
"is fixed at "
121 int compno = assocx + 1;
125 DbgLv(0) <<
" Reaction" << compno <<
":";
129 DbgLv(0) <<
" Reactant is component"
131 <<
", Product is component"
137 DbgLv(0) <<
" Reactants are components"
140 <<
", Product is component"
144 for (
int rx = 0; rx < nassoc; rx++ )
146 atype = cnsv[ rx ].atype;
147 bool floats = cnsv[ rx ].floats;
148 bool logscl = cnsv[ rx ].logscl;
149 double vmin = cnsv[ rx ].low;
150 double vmax = cnsv[ rx ].high;
151 attrtype = tr(
"UNKNOWN" );
154 attrtype = tr(
"K_Dissociation" );
156 attrtype = tr(
"k_Off Rate" );
162 DbgLv(0) <<
" " << attrtype <<
"floats from "
163 << vmin <<
"to" << vmax <<
"(log scale)";
167 DbgLv(0) <<
" " << attrtype <<
"floats from "
168 << vmin <<
"to" << vmax;
173 DbgLv(0) <<
" " << attrtype <<
"is fixed at "
201 empty_fitness.
index = ii;
205 QDateTime time = QDateTime::currentDateTime();
221 DbgLv(0) <<
"Last generation best RMSD" << sqrt( bfit->
fitness );
231 DbgLv(0) <<
"Post-minimization RMSD" << sqrt( bfit->
fitness );
238 DbgLv(1) <<
"GaMast: EOML: call calc_residuals";
246 DbgLv(1) <<
"GaMast: EOML: CALL write_output";
258 if ( mc_iterations > 1 )
272 DbgLv(1) <<
"GaMast: set_gaMC call";
274 DbgLv(1) <<
"GaMast: set_gaMC return";
287 DbgLv(0) <<
my_rank <<
": Master signalling FINISHED to all Demes";
297 DbgLv(0) <<
"VSUM=" << vsum;
300 DbgLv(0) <<
"SDAT 0-3"
305 DbgLv(0) <<
"SDAT *-n"
310 DbgLv(0) <<
"MDL comp1 s,k,w,D,f"
316 DbgLv(0) <<
"MDL comp2 s,k,w,D,f"
322 DbgLv(0) <<
"MDL asoc1 Kd,koff"
325 DbgLv(0) <<
"DS dens visc manual temp"
331 DbgLv(0) <<
"SIMP simpt mType gType rreso menis"
337 DbgLv(0) <<
"SIMP bott temp rnoise tinoise rinoise"
343 DbgLv(0) <<
"SIMP bform bvol bottpos rcoeffs"
350 DbgLv(0) <<
"STEP0 durmin dlymin w2tf w2tl timf timl"
357 DbgLv(0) <<
"STEP0 speed accel accelf"
363 DbgLv(0) <<
" Final Model Attribute Values --";
365 for (
int mcompx = 0; mcompx < fmodel->
components.size(); mcompx++ )
367 int compno = mcompx + 1;
370 DbgLv(0) <<
" Component" << compno <<
":";
374 for (
int cx = 0; cx <
ncompc; cx++ )
376 atype = cnsv[ cx ].atype;
379 attrtype = tr(
"Segmentation Coefficient" );
381 attrtype = tr(
"Frictional Ratio" );
383 attrtype = tr(
"Molecular Weight" );
385 attrtype = tr(
"Diffusion Coefficient" );
387 attrtype = tr(
"Frictional Coefficient" );
389 attrtype = tr(
"Vbar (Specific Density)" );
391 attrtype = tr(
"Signal Concentration" );
393 attrtype = tr(
"Extinction" );
395 attrtype = tr(
"Unknown" );
399 DbgLv(0) <<
" " << attrtype <<
"has a value of"
404 for (
int assocx = 0; assocx < fmodel->
associations.size(); assocx++ )
406 int compno = assocx + 1;
408 int ncomp = fmodel->
associations[ assocx ].rcomps.size();
410 DbgLv(0) <<
" Reaction" << compno <<
":";
414 DbgLv(0) <<
" Reactant is component"
416 <<
", Product is component"
422 DbgLv(0) <<
" Reactants are components"
424 <<
" and" << fmodel->
associations[ assocx ].rcomps[ 1 ] + 1
425 <<
", Product is component"
429 for (
int rx = 0; rx < nassoc; rx++ )
431 atype = cnsv[ rx ].atype;
434 attrtype = tr(
"K_Dissociation" );
436 attrtype = tr(
"k_Off Rate" );
440 DbgLv(0) <<
" " << attrtype <<
"has a value of"
448 for (
int worker = 1; worker <=
my_workers; worker++ )
461 static const double DIGIT_FIT = 1.0e+4;
462 static const int min_generation = 10;
463 static const int _KS_BASE_ = 6;
464 static const int _KS_STEP_ = 3;
468 int ks_base = s_ksbase.isEmpty() ? _KS_BASE_ : s_ksbase.toInt();
469 int ks_step = s_ksstep.isEmpty() ? _KS_STEP_ : s_ksstep.toInt();
470 ks_base = qMax( 2, ks_base );
471 ks_step = qMax( 1, ks_step );
473 int max_same_count = ( ks_base + (
nfloatc / ks_step ) * ks_step )
475 int avg_generation = 0;
476 bool early_termination =
false;
477 int fitness_same_count = 0;
478 double best_overall_fitness =
LARGE;
482 <<
best_fitness.size() <<
"best_overall" << best_overall_fitness;
483 DbgLv(0) <<
"dmga_master start loop: nfloatc max_same_count"
484 <<
nfloatc << max_same_count <<
"ks_base ks_step" << ks_base << ks_step;
493 QList < DGene > emigres;
494 QVector< int > v_generations( gcores_count, 0 );
498 double fit_power = 5;
499 double fit_digit = 1.0e4;
500 double fitness_round = 1.0e5;
503 while ( workers > 0 )
517 worker = status.MPI_SOURCE;
521 switch ( status.MPI_TAG )
528 sum += v_generations[ i ];
532 if ( avg > avg_generation )
534 avg_generation = avg;
539 "Avg. Generation: " + QString::number( avg_generation );
544 progress +=
"; Dataset: "
548 progress +=
"; Datasets: "
552 progress +=
"; MonteCarlo: " + QString::number( mc_iter );
553 if ( best_overall_fitness !=
LARGE && best_overall_fitness > 0.0 )
554 progress +=
"; RMSD: "
555 + QString::number( sqrt( best_overall_fitness ) );
561 DbgLv(1) <<
" MAST: work" << worker <<
"Recv#2 nfloatc" <<
nfloatc;
570 DbgLv(1) <<
" MAST: work" << worker <<
" dgm size" <<
dgmarker.size()
578 fit_power = (double)qRound( log10( msg.
fitness ) );
579 fit_digit = pow( 10.0, -fit_power ) * DIGIT_FIT;
580 fitness_round = (double)qRound64( msg.
fitness * fit_digit )
583 DbgLv(1) <<
" MAST: work" << worker <<
"fit msg,round,bestw,besto"
585 << best_overall_fitness;
591 if ( ! early_termination )
594 best_overall_fitness ==
LARGE )
596 DbgLv(0) <<
"First Best Fit RMSD" << sqrt( fitness_round );
598 DbgLv(1) <<
" MAST: work" << worker <<
"fit besto,round" << best_overall_fitness << fitness_round
599 <<
"fit_power fit_digit msgfit" << fit_power << fit_digit << msg.
fitness;
601 if ( fitness_round < best_overall_fitness )
603 best_overall_fitness = fitness_round;
604 fitness_same_count = 0;
608 fitness_same_count++;
612 if ( fitness_same_count > max_same_count &&
613 avg_generation > min_generation )
615 DbgLv(0) <<
"Fitness has not improved in the last"
616 << fitness_same_count
617 <<
"deme results - Early Termination.";
618 early_termination =
true;
626 DbgLv(1) << worker <<
": best_overall_fitness" << best_overall_fitness
627 <<
"fitness_same_count" << fitness_same_count
628 <<
" early_term?" << early_termination;
643 DbgLv(1) <<
"dgmast: Recv FINISH msg.size rsstotal" << msg.
size << rsstotal;
644 rsstotal += (long)msg.
size;
651 int gene_count = msg.
size;
652 int doubles_count = gene_count * nfloatc;
653 QVector< double > emmigrants( doubles_count ) ;
654 DbgLv(1) <<
"dgmast: Recv#4 EMMIG: gene_count doubles_count" << gene_count << doubles_count;
656 MPI_Recv( emmigrants.data(),
665 int emgx = emigres.size();
666 DbgLv(1) <<
"dgmast: Recv#4 EMMIG: emgx" << emgx;
668 DbgLv(1) <<
"dgmast: Recv#4 EMMIG: emigres size" << emigres.size();
678 if ( emigres.size() < gene_count * 5 ) doubles_count = 0;
681 QVector< double > immigrants;
684 if ( doubles_count > 0 )
687 for (
int ii = 0; ii < gene_count; ii++ )
698 DbgLv(1) <<
"dgmast: Send#5 IMMIG: count==0 migr data" << immigrants.data();
699 immigrants.resize( 1 );
701 DbgLv(1) <<
"dgmast: Send#5 IMMIG: immigrants size" << immigrants.size() <<
"doubles_count" << doubles_count
702 <<
"migr data" << immigrants.data();
704 MPI_Send( immigrants.data(),
710 DbgLv(1) <<
"dgmast: Send#5 IMMIG: complete";
722 DbgLv(1) <<
"Master maxrss" << maxrss <<
" worker total rss" << rsstotal
723 <<
"rank" << my_rank;
726 if ( early_termination )
728 int mc_iter = mgroup_count < 2 ? ( mc_iteration + 1 ) : mc_iteration;
729 DbgLv(0) <<
"Early termination at average generation" << avg
730 <<
", MC" << mc_iter;
737 double concentration = 0.0;
752 QVector< double >
scaled_data( scan_count * radius_points );
755 for (
int s = 0; s < scan_count; s++ )
757 for (
int r = 0; r < radius_points; r++ )
759 scaled_data[ index++ ] = data->
value( s, r ) / concentration;
765 job.
length = scaled_data.size();
772 for (
int worker = 1; worker <=
my_workers; worker++ )
785 MPI_Bcast( scaled_data.data(),
795 if ( current_dataset >=
data_sets.size() )
809 for (
int ee = 0; ee <
data_sets.size(); ee++ )
811 int nscan =
data_sets[ ee ]->run_data.scanCount();
812 int npoint =
data_sets[ ee ]->run_data.pointCount();
815 for (
int ss = 0; ss < nscan; ss++, ks++ )
817 for (
int rr = 0; rr < npoint; rr++ )
843 for (
int ee = 0; ee <
data_sets.size(); ee++ )
850 for (
int ss = 0; ss < scan_count; ss++ )
852 for (
int rr = 0; rr < radius_points; rr++ )
860 DbgLv(1) <<
"sdMC: mc_data set index" << index
872 for (
int worker = 1; worker <=
my_workers; worker++ )
896 for (
int ii = 0; ii <
nfloatc; ii++ )
910 for (
int ii = 0; ii <
nfloatc; ii++ )
919 QList< DGene >& dgenes,
const int stgx,
const int ngenes )
925 for (
int kg = 0; kg < ngenes; kg++ )
927 wkgene = dgenes[ gx++ ];
929 for (
int ii = 0; ii <
nfloatc; ii++ )
939 QList< DGene >& dgenes,
const int stgx,
const int ngenes )
943 int igsize = dgenes.size();
946 for (
int kg = 0; kg < ngenes; kg++ )
949 for (
int ii = 0; ii <
nfloatc; ii++, gx++ )
961 dgenes[ gx ] = wkgene;
1084 << dgene.components[0].s
1085 << dgene.components[0].f_f0
1086 << dgene.components[0].mw
1087 << dgene.components[0].D
1088 << dgene.components[0].f;
1098 for (
int ii = 0; ii < model.
associations.size(); ii++ )
1102 int nrco = as->
rcomps.size();
1104 int rc1 = as->
rcomps[ 0 ];
1105 int rc2 = nrco == 2 ? rc1 : as->
rcomps[ 1 ];
1106 int rcp = as->
rcomps[ rpx ];
1108 int st2 = qAbs( as->
stoichs[ 1 ] );
1109 int stp = qAbs( as->
stoichs[ rpx ] );
1110 double ff0p = qMax( 1.0, model.
components[ rcp ].f_f0 );
1111 model.
components[ rcp ] = dgene.components[ rcp ];
1113 DbgLv(1) <<
my_rank <<
"MFG: ii" << ii <<
"nrco,rc1,rc2,rcp"
1114 << nrco << rc1 << rc2 << rcp <<
"st1,st2,stp" << st1 << st2 << stp;
1117 double cval = model.
components[ rc1 ].signal_concentration;
1118 model.
components[ rc2 ].signal_concentration = cval;
1120 model.
components[ rcp ].signal_concentration = 0.0;
1122 DbgLv(1) <<
my_rank <<
"MFG: orig cval wval vval" << cval
1126 double wval = model.
components[ rc1 ].mw * (double)st1;
1127 double vsum = model.
components[ rc1 ].vbar20 * wval;
1128 double esum = model.
components[ rc1 ].extinction * (double)st1;
1133 wval = model.
components[ rc2 ].mw * (double)st2;
1134 vsum += model.
components[ rc2 ].vbar20 * wval;
1135 esum += model.
components[ rc2 ].extinction * (double)st2;
1139 model.
components[ rcp ].vbar20 = vsum / wsum;
1150 DbgLv(1) <<
my_rank <<
"MFG: rcp" << rcp <<
"c.s c.k c.mw c.vb"