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

Method Process

avida-core/source/actions/PrintActions.cc:2909–2967  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2907 }
2908 static const cString GetDescription() { return "Arguments: [string fname='']"; }
2909 void Process(cAvidaContext& ctx)
2910 {
2911 cString filename(m_filename);
2912 if (filename == "") filename.Set("tasks_%d.dat", m_world->GetStats().GetUpdate());
2913 Avida::Output::FilePtr df = Avida::Output::File::CreateWithPath(m_world->GetNewWorld(), (const char*)m_filename);
2914
2915 cPopulation& pop = m_world->GetPopulation();
2916 cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU(ctx);
2917
2918 for (int i = 0; i < pop.GetSize(); i++) {
2919 if (pop.GetCell(i).IsOccupied() == false) continue;
2920 cOrganism* organism = pop.GetCell(i).GetOrganism();
2921
2922 // create a test-cpu for the current creature
2923 cCPUTestInfo test_info;
2924 testcpu->TestGenome(ctx, test_info, organism->GetGenome());
2925 cPhenotype& test_phenotype = test_info.GetTestPhenotype();
2926 cPhenotype& phenotype = organism->GetPhenotype();
2927
2928 int num_tasks = m_world->GetEnvironment().GetNumTasks();
2929 int sum_tasks_all = 0;
2930 int sum_tasks_rewarded = 0;
2931 int divide_sum_tasks_all = 0;
2932 int divide_sum_tasks_rewarded = 0;
2933 int parent_sum_tasks_all = 0;
2934 int parent_sum_tasks_rewarded = 0;
2935
2936 for (int j = 0; j < num_tasks; j++) {
2937 // get the number of bonuses for this task
2938 int bonuses = 1; //phenotype.GetTaskLib().GetTaskNumBonus(j);
2939 int task_count = ( phenotype.GetCurTaskCount()[j] == 0 ) ? 0 : 1;
2940 int divide_tasks_count = (test_phenotype.GetLastTaskCount()[j] == 0)?0:1;
2941 int parent_task_count = (phenotype.GetLastTaskCount()[j] == 0) ? 0 : 1;
2942
2943 // If only one bonus, this task is not rewarded, as last bonus is + 0.
2944 if (bonuses > 1) {
2945 sum_tasks_rewarded += task_count;
2946 divide_sum_tasks_rewarded += divide_tasks_count;
2947 parent_sum_tasks_rewarded += parent_task_count;
2948 }
2949 sum_tasks_all += task_count;
2950 divide_sum_tasks_all += divide_tasks_count;
2951 parent_sum_tasks_all += parent_task_count;
2952 }
2953
2954 df->Write(i, "Cell Number");
2955 df->Write(sum_tasks_rewarded, "Number of Tasks Rewarded");
2956 df->Write(sum_tasks_all, "Total Number of Tasks Done");
2957 df->Write(divide_sum_tasks_rewarded, "Number of Rewarded Tasks on Divide");
2958 df->Write(divide_sum_tasks_all, "Number of Total Tasks on Divide");
2959 df->Write(parent_sum_tasks_rewarded, "Parent Number of Tasks Rewared");
2960 df->Write(parent_sum_tasks_all, "Parent Total Number of Tasks Done");
2961 df->Write(test_info.GetColonyFitness(), "Genotype Fitness");
2962 df->Write(organism->SystematicsGroup("genotype")->ID(), "Genotype ID");
2963 df->Endl();
2964 }
2965
2966 delete testcpu;

Callers

nothing calls this directly

Calls 15

GetUpdateMethod · 0.80
GetNewWorldMethod · 0.80
CreateTestCPUMethod · 0.80
IsOccupiedMethod · 0.80
TestGenomeMethod · 0.80
WriteMethod · 0.80
SystematicsGroupMethod · 0.80
EndlMethod · 0.80
SetMethod · 0.45
GetStatsMethod · 0.45
GetSizeMethod · 0.45
GetCellMethod · 0.45

Tested by

no test coverage detected