[Avida-SVN] r2075 - in development: documentation source/analyze

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Sat Sep 8 11:27:03 PDT 2007


Author: blwalker
Date: 2007-09-08 14:27:03 -0400 (Sat, 08 Sep 2007)
New Revision: 2075

Modified:
   development/documentation/analyze.html
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyzeGenotype.h
Log:

Added DETAIL options for the number of different tasks done and the total number of tasks done by a genotype.  Added these to the documentation.

Added the PRINT_PHENOTYPES command (already existed in the code) to the documentation.  Coded and documented parallel options (number of different tasks, average number of total tasks) per phenotype to those added to genotype output.


Modified: development/documentation/analyze.html
===================================================================
--- development/documentation/analyze.html	2007-09-07 19:42:36 UTC (rev 2074)
+++ development/documentation/analyze.html	2007-09-08 18:27:03 UTC (rev 2075)
@@ -356,6 +356,14 @@
   have been loaded in, or a RECALCULATE (or RECALC) must have been run to collect
   it.
 </dd>
+<dt><strong>
+	PRINT_PHENOTYPES [<span class="cmdargopt">file='phenotype.dat']
+	[<span class="cmdargopt">total_task_count]
+	[<span class="cmdargopt">total_task_performance_count]
+</strong></dt>
+<dd>
+	Prints phenotypes in the current batch as determined by task-signature.  Default statistics for each phenotype are number of organisms, number of genotypes, average genome length, average gestation time, viability, and tasks performed.  Using the total_task_count and/or total_task_performance_count flags will add that statistic to the output.  (In the case of total_task_performance_count, this will be an average over the members of the phenotype.)
+</dd>
 <dt><strong>DETAIL [<span class="cmdargopt">file='detail.dat'</span>] [<span class="cmdargopt">format ...</span>]</strong></dt>
 <dd>
   Print out all of the stats for each genotype, one per line.  The
@@ -632,7 +640,11 @@
 <tr>
   <td><strong>task.n</strong> (# of times task number n is done)</td>
   <td><strong>task.n:binary</strong> (is task n done, 0/1)</td>
+  <td><strong>total_task_count</strong> (# of different tasks done)</td>
 </tr>
+<tr>
+	<td><strong>total_task_performance_count</strong> (total # of tasks done)</td>
+</tr>
 </table>
 </div>
 

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2007-09-07 19:42:36 UTC (rev 2074)
+++ development/source/analyze/cAnalyze.cc	2007-09-08 18:27:03 UTC (rev 2075)
@@ -2554,7 +2554,16 @@
   // Load in the variables...
   cString filename("phenotype.dat");
   if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
-  
+
+  cString flag("");
+  bool print_ttc = false;
+  bool print_ttpc = false;
+  while (cur_string.GetSize() != 0) {
+  	flag = cur_string.PopWord();
+  	if (flag == "total_task_count") print_ttc = true;
+  	else if (flag == "total_task_performance_count") print_ttpc = true;
+  }
+
   // Make sure we have at least one genotype...
   if (batch[cur_batch].List().GetSize() == 0) return;
   
@@ -2565,11 +2574,15 @@
   tArray<int> genotype_counts(num_phenotypes);
   tArray<double> total_length(num_phenotypes);
   tArray<double> total_gest(num_phenotypes);
+  tArray<int> total_task_count(num_phenotypes);
+  tArray<int> total_task_performance_count(num_phenotypes);
   
   phenotype_counts.SetAll(0);
   genotype_counts.SetAll(0);
   total_length.SetAll(0.0);
   total_gest.SetAll(0.0);
+  total_task_count.SetAll(0);
+  total_task_performance_count.SetAll(0);
   
   // Loop through all of the genotypes in this batch...
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
@@ -2584,6 +2597,10 @@
     genotype_counts[phen_id]++;
     total_length[phen_id] += genotype->GetNumCPUs() * genotype->GetLength();
     total_gest[phen_id] += genotype->GetNumCPUs() * genotype->GetGestTime();
+    for (int i = 0; i < num_tasks; i++) {
+    		total_task_count[phen_id] += ((genotype->GetTaskCount(i) > 0) ? 1 : 0);
+    		total_task_performance_count[phen_id] += genotype->GetTaskCount(i);
+    }
   }
   
   // Print out the results...
@@ -2594,9 +2611,22 @@
     << "# 2: Number of genotypes of this phenotye" << endl
     << "# 3: Average Genome Length" << endl
     << "# 4: Average Gestation Time" << endl
-    << "# 5: Viability of Phenotype" << endl
-    << "# 6+: Tasks performed in this phenotype" << endl
-    << endl;
+    << "# 5: Viability of Phenotype" << endl;
+  if (print_ttc && print_ttpc) {
+  	fp << "# 6: Total # of different tasks performed by this phenotype" << endl
+    	<< "# 7: Average # of tasks performed by this phenotype" << endl
+    	<< "# 8+: Tasks performed in this phenotype" << endl;
+  }
+  else if (print_ttc) {
+  	fp << "# 6: Total # of different tasks performed by this phenotype" << endl
+    	<< "# 7+: Tasks performed in this phenotype" << endl;
+  }
+  else if (print_ttpc) {
+  	fp << "# 6: Total # of tasks performed by this phenotype" << endl
+  	  << "# 7+: Tasks performed in this phenotype" << endl;
+  }
+  else { fp << "# 6+: Tasks performed in this phenotype" << endl; }
+  fp << endl;
   
   // @CAO Lets do this inefficiently for the moment, but print out the
   // phenotypes in order.
@@ -2619,6 +2649,10 @@
       << total_length[max_position] / phenotype_counts[max_position] << " "
       << total_gest[max_position] / phenotype_counts[max_position] << " "
       << (max_position & 1) << "  ";
+    if (print_ttc) { fp << total_task_count[max_position] / genotype_counts[max_position] << "  "; }
+    if (print_ttpc) { 
+    	fp << total_task_performance_count[max_position] / genotype_counts[max_position] << "  "; 
+    }
     for (int i = 1; i <= num_tasks; i++) {
       if ((max_position >> i) & 1 > 0) fp << "1 ";
       else fp << "0 ";
@@ -8263,6 +8297,10 @@
   ADD_GDATA(cString, "link.tasksites", "Phenotype Map",              GetMapLink,      SetNULL, 0, 0,       0);
   ADD_GDATA(cString, "html.sequence",  "Genome Sequence",            GetHTMLSequence, SetNULL, 0, "(N/A)", "");
   
+  // coarse-grained task stats
+  ADD_GDATA(int, 		"total_task_count","# Different Tasks", 		GetTotalTaskCount, SetNULL, 1, 0, 0);
+  ADD_GDATA(int, 		"total_task_performance_count", "Total Tasks Performed",	GetTotalTaskPerformanceCount, SetNULL, 1, 0, 0);
+  
   const cEnvironment& environment = m_world->GetEnvironment();
   for (int i = 0; i < environment.GetNumTasks(); i++) {
     cString t_name, t_desc;

Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h	2007-09-07 19:42:36 UTC (rev 2074)
+++ development/source/analyze/cAnalyzeGenotype.h	2007-09-08 18:27:03 UTC (rev 2075)
@@ -376,6 +376,31 @@
   const tArray<int> & GetTaskCounts() const {
     return task_counts;
   }
+  
+  double GetTaskQuality(int task_id) const {
+	  if (task_id >= task_counts.GetSize()) return 0;
+	  return task_qualities[task_id];
+  }
+  const tArray<double> & GetTaskQualities() const {
+	  return task_qualities;
+  }
+  
+  // number of different tasks performed
+  int GetTotalTaskCount() const {
+  	int total_task_count = 0;
+  	for(int i = 0; i < task_counts.GetSize(); i++)
+  	{ if (task_counts[i] > 0) total_task_count++; }
+  	return total_task_count;
+  }
+  
+  // total number of tasks performed, including multiple performances
+  int GetTotalTaskPerformanceCount() const {
+  	int total_task_performance_count = 0;
+  	for(int i = 0; i < task_counts.GetSize(); i++)
+  	{ total_task_performance_count += task_counts[i]; }
+  	return total_task_performance_count;
+  }
+  
   int GetEnvInput(int input_id) const{
     if (input_id >= m_env_inputs.GetSize()) return 0;
     return m_env_inputs[input_id];
@@ -384,14 +409,6 @@
     return m_env_inputs;
   }
 
-  double GetTaskQuality(int task_id) const {
-	  if (task_id >= task_counts.GetSize()) return 0;
-	  return task_qualities[task_id];
-  }
-  const tArray<double> & GetTaskQualities() const {
-	  return task_qualities;
-  }
-
   // Comparisons...  Compares a genotype to the "previous" one, which is
   // passed in, in one specified phenotype.
   // Return values are:




More information about the Avida-cvs mailing list