[Avida-SVN] r3393 - in development/source: actions main

goingssh at myxo.css.msu.edu goingssh at myxo.css.msu.edu
Wed Sep 2 18:34:08 PDT 2009


Author: goingssh
Date: 2009-09-02 21:34:08 -0400 (Wed, 02 Sep 2009)
New Revision: 3393

Modified:
   development/source/actions/PrintActions.cc
   development/source/main/cDeme.cc
   development/source/main/cPhenotype.cc
   development/source/main/cStats.cc
   development/source/main/cStats.h
Log:
Added event "PrintNewTasksData" that prints number of times each task appears in the population, defined as an organism completing the task who's parent did not.
Also fixed a VS compiling issue, where the word "and" was used in an if statement instead of "&&".

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2009-09-02 19:58:53 UTC (rev 3392)
+++ development/source/actions/PrintActions.cc	2009-09-03 01:34:08 UTC (rev 3393)
@@ -80,6 +80,7 @@
 STATS_OUT_FILE(PrintTotalsData,             totals.dat          );
 STATS_OUT_FILE(PrintTasksData,              tasks.dat           );
 STATS_OUT_FILE(PrintTasksExeData,           tasks_exe.dat       );
+STATS_OUT_FILE(PrintNewTasksData,			newtasks.dat		);
 STATS_OUT_FILE(PrintTasksQualData,          tasks_quality.dat   );
 STATS_OUT_FILE(PrintResourceData,           resource.dat        );
 STATS_OUT_FILE(PrintReactionData,           reactions.dat       );
@@ -3022,6 +3023,7 @@
   action_lib->Register<cActionPrintTotalsData>("PrintTotalsData");
   action_lib->Register<cActionPrintTasksData>("PrintTasksData");
   action_lib->Register<cActionPrintTasksExeData>("PrintTasksExeData");
+  action_lib->Register<cActionPrintNewTasksData>("PrintNewTasksData");
   action_lib->Register<cActionPrintTasksQualData>("PrintTasksQualData");
   action_lib->Register<cActionPrintResourceData>("PrintResourceData");
   action_lib->Register<cActionPrintReactionData>("PrintReactionData");

Modified: development/source/main/cDeme.cc
===================================================================
--- development/source/main/cDeme.cc	2009-09-02 19:58:53 UTC (rev 3392)
+++ development/source/main/cDeme.cc	2009-09-03 01:34:08 UTC (rev 3393)
@@ -36,6 +36,7 @@
 #include "cOrgMovementPredicate.h"
 #include "cDemePredicate.h"
 
+
 /*! Constructor
  */
 cDeme::cDeme() : _id(0), width(0), replicateDeme(false), treatable(false), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
@@ -148,7 +149,7 @@
 	
 	for(int pos = 0; pos < demeSize; ++pos) {
 		cPopulationCell& cell = GetCell(pos);
-		if(cell.IsOccupied() and cell.GetOrganism()->HasOpinion())
+		if(cell.IsOccupied() && cell.GetOrganism()->HasOpinion())
 			++count;
 	}
 	return count;

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2009-09-02 19:58:53 UTC (rev 3392)
+++ development/source/main/cPhenotype.cc	2009-09-03 01:34:08 UTC (rev 3393)
@@ -1179,6 +1179,7 @@
       eff_task_count[i]++;
       //cerr << "eff: " << eff_task_count[i] << endl;
       if(result.UsedEnvResource() == false) { cur_internal_task_count[i]++; }
+	  if (last_task_count[i]==0) { m_world->GetStats().AddNewTaskCount(i); }
     }
 
     if (result.TaskQuality(i) > 0) 

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2009-09-02 19:58:53 UTC (rev 3392)
+++ development/source/main/cStats.cc	2009-09-03 01:34:08 UTC (rev 3393)
@@ -151,6 +151,7 @@
   task_cur_max_quality.Resize(num_tasks);
   task_last_max_quality.Resize(num_tasks);
   task_exe_count.Resize(num_tasks);
+  new_task_count.Resize(num_tasks);
   task_cur_count.SetAll(0);
   task_cur_quality.SetAll(0);
   task_cur_max_quality.SetAll(0);
@@ -160,6 +161,7 @@
   task_cur_max_quality.SetAll(0);
   task_last_max_quality.SetAll(0);
   task_exe_count.SetAll(0);
+  new_task_count.SetAll(0);
   
   // Stats for internal resource use
   task_internal_cur_count.Resize(num_tasks);
@@ -960,6 +962,23 @@
   df.Endl();
 }
 
+void cStats::PrintNewTasksData(const cString& filename)
+{
+  cDataFile& df = m_world->GetDataFile(filename);
+
+  df.WriteComment("Avida new tasks data");
+  df.WriteTimeStamp();
+  df.WriteComment("First column gives the current update, all further columns give the number");
+  df.WriteComment("of times the particular task has newly evolved since the last time printed.");
+
+  df.Write(m_update,   "Update");
+  for (int i = 0; i < new_task_count.GetSize(); i++) {
+    df.Write(new_task_count[i], task_names[i]);
+  }
+  df.Endl();
+  new_task_count.SetAll(0);
+}
+
 void cStats::PrintDynamicMaxMinData(const cString& filename)
 {
 	cDataFile& df = m_world->GetDataFile(filename);

Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h	2009-09-02 19:58:53 UTC (rev 3392)
+++ development/source/main/cStats.h	2009-09-03 01:34:08 UTC (rev 3393)
@@ -238,6 +238,7 @@
   tArray<double> task_cur_max_quality;
   tArray<double> task_last_max_quality;
   tArray<int> task_exe_count;
+  tArray<int> new_task_count;
   
   // Stats for internal resource bins and use of internal resources
   tArray<int> task_internal_cur_count;
@@ -577,6 +578,7 @@
 	  task_last_quality[task_num] += quality; 
 	  if (quality > task_last_max_quality[task_num]) task_last_max_quality[task_num] = quality;
   }
+  void AddNewTaskCount(int task_num) {new_task_count[task_num]++; }
   void IncTaskExeCount(int task_num, int task_count) { task_exe_count[task_num] += task_count; }
   void ZeroTasks();
   
@@ -760,6 +762,7 @@
   void PrintTasksExeData(const cString& filename);
   void PrintTasksQualData(const cString& filename);
   void PrintDynamicMaxMinData(const cString& filename);
+  void PrintNewTasksData(const cString& filename);
   void PrintReactionData(const cString& filename);
   void PrintReactionExeData(const cString& filename);
   void PrintCurrentReactionData(const cString& filename);




More information about the Avida-cvs mailing list