Prediction for a landscape where n sites are _randomized_.
| 331 | |
| 332 | // Prediction for a landscape where n sites are _randomized_. |
| 333 | void cLandscape::PredictWProcess(cAvidaContext& ctx, Avida::Output::File& df, int update) |
| 334 | { |
| 335 | cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU(ctx); |
| 336 | |
| 337 | distance = 1; |
| 338 | |
| 339 | // Get the info about the base creature. |
| 340 | ProcessBase(ctx, testcpu); |
| 341 | if (base_fitness == 0.0) return; |
| 342 | |
| 343 | BuildFitnessChart(ctx, testcpu); |
| 344 | const int genome_size = fitness_chart.GetNumRows(); |
| 345 | const int inst_size = fitness_chart.GetNumCols(); |
| 346 | const double min_neut_fitness = 0.99; |
| 347 | const double max_neut_fitness = 1.01; |
| 348 | |
| 349 | // Loop through the entries printing them and doing additional |
| 350 | // calculations. |
| 351 | int total_pos_found = 0; |
| 352 | int total_neut_found = 0; |
| 353 | int total_neg_found = 0; |
| 354 | int total_dead_found = 0; |
| 355 | double max_fitness = 1.0; |
| 356 | double total_fitness = 0.0; |
| 357 | double total_sqr_fitness = 0.0; |
| 358 | |
| 359 | for (int row = 0; row < genome_size; row++) { |
| 360 | double max_line_fitness = 1.0; |
| 361 | for (int col = 0; col < inst_size; col++) { |
| 362 | double & cur_fitness = fitness_chart(row, col); |
| 363 | cur_fitness /= base_fitness; |
| 364 | total_fitness += cur_fitness; |
| 365 | total_sqr_fitness += cur_fitness * cur_fitness; |
| 366 | if (cur_fitness > max_neut_fitness) total_pos_found++; |
| 367 | else if (cur_fitness > min_neut_fitness) total_neut_found++; |
| 368 | else if (cur_fitness > 0.0) total_neg_found++; |
| 369 | |
| 370 | if (cur_fitness > max_line_fitness) max_line_fitness = cur_fitness; |
| 371 | } |
| 372 | max_fitness *= max_line_fitness; |
| 373 | } |
| 374 | |
| 375 | const int total_tests = genome_size * inst_size; |
| 376 | total_dead_found = total_tests - total_pos_found - total_neut_found - total_neg_found; |
| 377 | df.Write(update, "Update"); |
| 378 | df.Write(1, "Number of Mutations"); |
| 379 | df.Write((static_cast<double>(total_dead_found) / static_cast<double>(total_tests)), "Probability Lethal"); |
| 380 | df.Write((static_cast<double>(total_neg_found) / static_cast<double>(total_tests)), "Probability Deleterious"); |
| 381 | df.Write((static_cast<double>(total_neut_found) / static_cast<double>(total_tests)), "Probability Neutral"); |
| 382 | df.Write((static_cast<double>(total_pos_found) / static_cast<double>(total_tests)), "Probability Beneficial"); |
| 383 | df.Write(total_tests, "Total Tests"); |
| 384 | df.Write(total_neut_found + total_pos_found, "Total Neutral and Beneficial"); |
| 385 | df.Write(total_fitness / static_cast<double>(total_tests), "Average Fitness"); |
| 386 | df.Write(total_sqr_fitness / static_cast<double>(total_tests), "Average Square Fitness"); |
| 387 | df.Endl(); |
| 388 | |
| 389 | // Sample the table out to 10 mutations |
| 390 | const int max_muts = 10; |
no test coverage detected