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

goingssh at myxo.css.msu.edu goingssh at myxo.css.msu.edu
Thu Sep 3 09:45:33 PDT 2009


Author: goingssh
Date: 2009-09-03 12:45:32 -0400 (Thu, 03 Sep 2009)
New Revision: 3394

Modified:
   development/source/actions/PrintActions.cc
   development/source/main/cPhenotype.cc
   development/source/main/cStats.cc
   development/source/main/cStats.h
Log:
Added event "PrintNewReactionData" that does same thing as "PrintNewTasksData" except for reactions, prints counts of each new appearance of a reaction in the population.  Note for those using this event, it prints the number of times the task or reaction has newly appeared in the population since the LAST TIME THIS DATA PRINTED, this way no data is lost.  This is in contrast to most of the general data files that print information about only the particular update.  So if you're calling these new events every 100 updates, the numbers shown will be the number of times a new task/reaction has appeared in the last 100 updates.

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2009-09-03 01:34:08 UTC (rev 3393)
+++ development/source/actions/PrintActions.cc	2009-09-03 16:45:32 UTC (rev 3394)
@@ -81,6 +81,7 @@
 STATS_OUT_FILE(PrintTasksData,              tasks.dat           );
 STATS_OUT_FILE(PrintTasksExeData,           tasks_exe.dat       );
 STATS_OUT_FILE(PrintNewTasksData,			newtasks.dat		);
+STATS_OUT_FILE(PrintNewReactionData,		newreactions.dat	);
 STATS_OUT_FILE(PrintTasksQualData,          tasks_quality.dat   );
 STATS_OUT_FILE(PrintResourceData,           resource.dat        );
 STATS_OUT_FILE(PrintReactionData,           reactions.dat       );
@@ -3024,6 +3025,7 @@
   action_lib->Register<cActionPrintTasksData>("PrintTasksData");
   action_lib->Register<cActionPrintTasksExeData>("PrintTasksExeData");
   action_lib->Register<cActionPrintNewTasksData>("PrintNewTasksData");
+  action_lib->Register<cActionPrintNewReactionData>("PrintNewReactionData");
   action_lib->Register<cActionPrintTasksQualData>("PrintTasksQualData");
   action_lib->Register<cActionPrintResourceData>("PrintResourceData");
   action_lib->Register<cActionPrintReactionData>("PrintReactionData");

Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc	2009-09-03 01:34:08 UTC (rev 3393)
+++ development/source/main/cPhenotype.cc	2009-09-03 16:45:32 UTC (rev 3394)
@@ -1194,6 +1194,8 @@
   for (int i = 0; i < num_reactions; i++) {
 //    if (result.ReactionTriggered(i) == true) cur_reaction_count[i]++;  // moved into cEnvironment::TestOutput to allow reaction requisites to be satisified at the time a reaction is completed
     cur_reaction_add_reward[i] += result.GetReactionAddBonus(i);
+	if (result.ReactionTriggered(i) && last_reaction_count[i]==0) 
+		m_world->GetStats().AddNewReactionCount(i); 
   }
 
   // Update the merit bonus

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2009-09-03 01:34:08 UTC (rev 3393)
+++ development/source/main/cStats.cc	2009-09-03 16:45:32 UTC (rev 3394)
@@ -152,6 +152,7 @@
   task_last_max_quality.Resize(num_tasks);
   task_exe_count.Resize(num_tasks);
   new_task_count.Resize(num_tasks);
+  new_reaction_count.Resize(env.GetNumReactions());
   task_cur_count.SetAll(0);
   task_cur_quality.SetAll(0);
   task_cur_max_quality.SetAll(0);
@@ -162,6 +163,7 @@
   task_last_max_quality.SetAll(0);
   task_exe_count.SetAll(0);
   new_task_count.SetAll(0);
+  new_reaction_count.SetAll(0);
   
   // Stats for internal resource use
   task_internal_cur_count.Resize(num_tasks);
@@ -979,6 +981,23 @@
   new_task_count.SetAll(0);
 }
 
+void cStats::PrintNewReactionData(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 reaction has newly evolved since the last time printed.");
+
+  df.Write(m_update,   "Update");
+  for (int i = 0; i < new_reaction_count.GetSize(); i++) {
+    df.Write(new_reaction_count[i], reaction_names[i]);
+  }
+  df.Endl();
+  new_reaction_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-03 01:34:08 UTC (rev 3393)
+++ development/source/main/cStats.h	2009-09-03 16:45:32 UTC (rev 3394)
@@ -239,6 +239,7 @@
   tArray<double> task_last_max_quality;
   tArray<int> task_exe_count;
   tArray<int> new_task_count;
+  tArray<int> new_reaction_count;
   
   // Stats for internal resource bins and use of internal resources
   tArray<int> task_internal_cur_count;
@@ -579,6 +580,7 @@
 	  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 AddNewReactionCount(int reaction_num) {new_reaction_count[reaction_num]++; }
   void IncTaskExeCount(int task_num, int task_count) { task_exe_count[task_num] += task_count; }
   void ZeroTasks();
   
@@ -763,6 +765,7 @@
   void PrintTasksQualData(const cString& filename);
   void PrintDynamicMaxMinData(const cString& filename);
   void PrintNewTasksData(const cString& filename);
+  void PrintNewReactionData(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