36 empty_fitness.
index = i;
40 QDateTime time = QDateTime::currentDateTime();
50 DbgLv(1) <<
"GaMast: sols size" << nisols <<
"buck size" <<
buckets.size()
62 DbgLv(1) <<
"GaMast: calc_resids return - calcsize vari"
74 bool have_s = ( attrxs.indexOf(
ATTR_S ) >= 0 );
75 bool have_k = ( attrxs.indexOf(
ATTR_K ) >= 0 );
76 bool have_w = ( attrxs.indexOf(
ATTR_W ) >= 0 );
77 bool have_d = ( attrxs.indexOf(
ATTR_D ) >= 0 );
78 bool have_f = ( attrxs.indexOf(
ATTR_F ) >= 0 );
79 bool vary_v = ( attr_z !=
ATTR_V );
85 mcomp.
s = have_s ? solu->
s : 0.0;
86 mcomp.
f_f0 = have_k ? solu->
k : 0.0;
87 mcomp.
mw = have_w ? solu->
d : 0.0;
88 mcomp.
vbar20 = vary_v ? solu->
v : vbar20;
89 mcomp.
D = have_d ? solu->
d : 0.0;
90 mcomp.
f = have_f ? solu->
d : 0.0;
113 if ( mc_iterations > 1 )
127 DbgLv(1) <<
"GaMast: set_gaMC call";
129 DbgLv(1) <<
"GaMast: set_gaMC return";
141 <<
" : model output.";
142 send_udp(
"Dataset " + QString::number( current_dataset + 1 )
143 +
" : analysis complete." );
157 DbgLv(0) <<
my_rank <<
": Master signalling FINISHED to all Demes";
162 for (
int worker = 1; worker <=
my_workers; worker++ )
177 static const double DIGIT_FIT = 1.0e+4;
178 static const int max_same_count =
my_workers * 5;
179 static const int min_generation = 10;
180 int avg_generation = 0;
181 bool early_termination =
false;
182 int fitness_same_count = 0;
183 double best_overall_fitness =
LARGE;
187 <<
best_fitness.size() <<
"best_overall" << best_overall_fitness;
196 QList < Gene > emigres;
197 QVector< int > v_generations( gcores_count, 0 );
201 double fit_power = 5;
202 double fit_digit = 1.0e4;
203 double fitness_round = 1.0e5;
206 while ( workers > 0 )
220 worker = status.MPI_SOURCE;
227 switch ( status.MPI_TAG )
234 sum += v_generations[ i ];
238 if ( avg > avg_generation )
240 avg_generation = avg;
245 "Avg. Generation: " + QString::number( avg_generation );
250 progress +=
"; Dataset: "
254 progress +=
"; Datasets: "
258 progress +=
"; MonteCarlo: " + QString::number( mc_iter );
276 fit_power = (double)qRound( log10( msg.
fitness ) );
277 fit_digit = pow( 10.0, -fit_power ) * DIGIT_FIT;
278 fitness_round = (double)qRound64( msg.
fitness * fit_digit )
281 DbgLv(1) <<
" MAST: work" << worker <<
"fit msg,round,bestw,besto"
283 << best_overall_fitness;
288 for (
int i = 0; i <
buckets.size(); i++ )
290 DbgLv(1) <<
"master: worker/fitness/best gene" << worker << msg.
fitness << g;
292 if ( ! early_termination )
295 best_overall_fitness ==
LARGE )
297 DbgLv(0) <<
"First Best Fit RMSD" << sqrt( fitness_round );
299 DbgLv(1) <<
" MAST: work" << worker <<
"fit besto,round" << best_overall_fitness << fitness_round
300 <<
"fit_power fit_digit msgfit" << fit_power << fit_digit << msg.
fitness;
302 if ( fitness_round < best_overall_fitness )
304 best_overall_fitness = fitness_round;
305 fitness_same_count = 0;
309 fitness_same_count++;
313 if ( fitness_same_count > max_same_count &&
314 avg_generation > min_generation )
316 DbgLv(0) <<
"Fitness has not improved in the last"
317 << fitness_same_count
318 <<
"deme results - Early Termination.";
319 early_termination =
true;
323 DbgLv(1) <<
" best_overall_fitness" << best_overall_fitness
324 <<
"fitness_same_count" << fitness_same_count
325 <<
" early_term?" << early_termination;
339 rsstotal += (long)msg.
size;
346 int gene_count = msg.
size;
347 int doubles_count = gene_count *
buckets.size() *
349 QVector< double > emmigrants( doubles_count ) ;
351 MPI_Recv( emmigrants.data(),
363 for (
int i = 0; i < gene_count; i++ )
367 for (
int b = 0; b <
buckets.size(); b++ )
369 double s = emmigrants[ solute++ ];
370 double k = emmigrants[ solute++ ];
385 if ( emigres.size() < gene_count * 5 ) doubles_count = 0;
388 QVector< US_Solute > immigrants;
390 if ( doubles_count > 0 )
393 for (
int i = 0; i < gene_count; i++ )
394 immigrants += emigres.takeAt(
u_random( emigres.size() ) );
397 MPI_Send( immigrants.data(),
414 DbgLv(1) <<
"Master maxrss" << maxrss <<
" worker total rss" << rsstotal
415 <<
"rank" << my_rank;
418 if ( early_termination )
420 int mc_iter = mgroup_count < 2 ? ( mc_iteration + 1 ) : mc_iteration;
421 DbgLv(0) <<
"Early termination at average generation" << avg
422 <<
", MC" << mc_iter;
429 double concentration = 0.0;
444 QVector< double >
scaled_data( scan_count * radius_points );
447 for (
int s = 0; s < scan_count; s++ )
449 for (
int r = 0; r < radius_points; r++ )
451 scaled_data[ index++ ] = data->
value( s, r ) / concentration;
457 job.
length = scaled_data.size();
464 for (
int worker = 1; worker <=
my_workers; worker++ )
477 MPI_Bcast( scaled_data.data(),
505 DbgLv(1) <<
"sgMC: bfgenes stored" << ncsols;
511 DbgLv(1) <<
"sgMC: gaussians set";
526 for (
int s = 0; s < scan_count; s++ )
528 for (
int r = 0; r < radius_points; r++ )
536 DbgLv(1) <<
"sgMC: mc_data set index" << index;
548 for (
int worker = 1; worker <=
my_workers; worker++ )
559 DbgLv(1) <<
"sgMC: MPI Barrier";
562 DbgLv(1) <<
"sgMC: MPI Bcast";