MCPcopy Create free account
hub / github.com/devosoft/avida / PredictNuProcess

Method PredictNuProcess

avida-core/source/main/cLandscape.cc:456–599  ·  view source on GitHub ↗

Prediction for a landscape where n sites are _mutated_.

Source from the content-addressed store, hash-verified

454
455// Prediction for a landscape where n sites are _mutated_.
456void cLandscape::PredictNuProcess(cAvidaContext& ctx, Avida::Output::File& df, int update)
457{
458 cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU(ctx);
459
460 distance = 1;
461
462 // Get the info about the base creature.
463 ProcessBase(ctx, testcpu);
464 if (base_fitness == 0.0) return;
465
466 BuildFitnessChart(ctx, testcpu);
467 const int genome_size = fitness_chart.GetNumRows();
468 const int inst_size = fitness_chart.GetNumCols();
469 const double min_neut_fitness = 0.99;
470 const double max_neut_fitness = 1.01;
471
472 // Loop through the entries printing them and doing additional
473 // calculations.
474 int total_pos_found = 0;
475 int total_neut_found = 0;
476 int total_neg_found = 0;
477 int total_dead_found = 0;
478 int total_live_found = 0;
479 double max_fitness = 1.0;
480 double max_found_fitness = 0.0;
481 double total_fitness = 0.0;
482 double total_sqr_fitness = 0.0;
483
484 for (int row = 0; row < genome_size; row++) {
485 double max_line_fitness = 1.0;
486 ConstInstructionSequencePtr base_seq_p;
487 GeneticRepresentationPtr rep_p = base_genome.Representation();
488 base_seq_p.DynamicCastFrom(rep_p);
489 const InstructionSequence& base_seq = *base_seq_p;
490 int base_inst = base_seq[row].GetOp();
491 for (int col = 0; col < inst_size; col++) {
492 if (col == base_inst) continue; // Only consider changes to line!
493 double & cur_fitness = fitness_chart(row, col);
494 cur_fitness /= base_fitness;
495 total_fitness += cur_fitness;
496 total_sqr_fitness += cur_fitness * cur_fitness;
497 if (cur_fitness > max_neut_fitness) total_pos_found++;
498 else if (cur_fitness > min_neut_fitness) total_neut_found++;
499 else if (cur_fitness > 0.0) total_neg_found++;
500
501 if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness;
502 }
503 max_fitness *= max_line_fitness;
504 if (max_line_fitness > max_found_fitness) max_found_fitness = max_line_fitness;
505 }
506
507 const int total_tests = genome_size * inst_size;
508 total_live_found = total_pos_found + total_neut_found + total_neg_found;
509 total_dead_found = total_tests - total_live_found;
510 df.Write(update, "Update");
511 df.Write(1, "Number of Mutations");
512 df.Write((static_cast<double>(total_dead_found) / static_cast<double>(total_tests)), "Probability Lethal");
513 df.Write((static_cast<double>(total_neg_found) / static_cast<double>(total_tests)), "Probability Deleterious");

Callers 1

ProcessMethod · 0.80

Calls 12

CreateTestCPUMethod · 0.80
RepresentationMethod · 0.80
GetOpMethod · 0.80
WriteMethod · 0.80
EndlMethod · 0.80
GetUIntMethod · 0.80
GetInstSetMethod · 0.80
GetNumRowsMethod · 0.45
GetNumColsMethod · 0.45
GetSizeMethod · 0.45
StringValueMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected