[Avida-SVN] r2882 - in development/source: analyze tools

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat Oct 25 15:57:35 PDT 2008


Author: brysonda
Date: 2008-10-25 18:57:34 -0400 (Sat, 25 Oct 2008)
New Revision: 2882

Modified:
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyzeGenotype.cc
   development/source/analyze/cAnalyzeGenotype.h
   development/source/tools/cFlexVar.h
   development/source/tools/cStringList.h
   development/source/tools/tDataEntry.h
   development/source/tools/tDataEntryCommand.h
   development/source/tools/tDataManager.h
Log:
More tDataEntry changes to lessen world knowledge needed to create list.

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/analyze/cAnalyze.cc	2008-10-25 22:57:34 UTC (rev 2882)
@@ -974,7 +974,6 @@
     output_it.Reset();
     tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
     while ((data_command = output_it.Next()) != NULL) {
-      //        genotype->SetSpecialArgs(data_command->GetArgs());
       data_command->SetValue(genotype, cur_line.PopWord());
     }
     
@@ -2033,16 +2032,18 @@
 
 
 void cAnalyze::CommandDetail_Header(ostream& fp, int format_type,
-                                    tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it,
+                                    tListIterator< tDataEntryCommand<cAnalyzeGenotype> >& output_it,
                                     int time_step)
 {
+  cAnalyzeGenotype* cur_genotype = batch[cur_batch].List().GetFirst();
+
   // Write out the header on the file
   if (format_type == FILE_TYPE_TEXT) {
     fp << "#filetype genotype_data" << endl;
     fp << "#format ";
     if (time_step > 0) fp << "update ";
     while (output_it.Next() != NULL) {
-      const cString & entry_name = output_it.Get()->GetName();
+      const cString& entry_name = output_it.Get()->GetName();
       fp << entry_name << " ";
     }
     fp << endl << endl;
@@ -2052,7 +2053,7 @@
     int count = 0;
     if (time_step > 0) fp << "# " << ++count << ": Update" << endl;
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString& entry_desc = output_it.Get()->GetDesc(cur_genotype);
       fp << "# " << ++count << ": " << entry_desc << endl;
     }
     fp << endl;
@@ -2071,7 +2072,7 @@
     
     if (time_step > 0) fp << "<th bgcolor=\"#AAAAFF\">Update ";
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString& entry_desc = output_it.Get()->GetDesc(cur_genotype);
       fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
     }
     fp << "</tr>" << endl;
@@ -2109,12 +2110,10 @@
     
     tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
     while ((data_command = output_it.Next()) != NULL) {
-      cur_genotype->SetSpecialArgs(data_command->GetArgs());
       cFlexVar cur_value = data_command->GetValue(cur_genotype);
       if (format_type == FILE_TYPE_HTML) {
         int compare = 0;
         if (prev_genotype) {
-          prev_genotype->SetSpecialArgs(data_command->GetArgs());
           cFlexVar prev_value = data_command->GetValue(prev_genotype);
           int compare_type = data_command->GetCompareType();
           compare = CompareFlexStat(cur_value, prev_value, compare_type);
@@ -2169,7 +2168,6 @@
     output_it.Reset();
     tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
     while ((data_command = output_it.Next()) != NULL) {
-      cur_genotype->SetSpecialArgs(data_command->GetArgs());
       for (int j = 0; j < cur_genotype->GetNumCPUs(); j++) { 
         output_counts[count].Add( data_command->GetValue(cur_genotype).AsDouble() );
       } 	
@@ -2242,6 +2240,7 @@
   if (file_extension == "html") file_type = FILE_TYPE_HTML;
   
   ofstream& fp = m_world->GetDataFileOFStream(filename);
+  cAnalyzeGenotype* first_genotype = batch[cur_batch].List().GetFirst();
   
   // Write out the header on the file
   if (file_type == FILE_TYPE_TEXT) {
@@ -2252,7 +2251,7 @@
     // Give the more human-readable legend.
     fp << "# Legend:" << endl
       << "#  Column 1 = Batch ID" << endl
-      << "#  Remaining entries: " << cur_command->GetDesc() << endl
+      << "#  Remaining entries: " << cur_command->GetDesc(first_genotype) << endl
       << endl;
     
   } else { // if (file_type == FILE_TYPE_HTML) {
@@ -2263,11 +2262,11 @@
     << " alink=\"#0000FF\"" << endl
     << " vlink=\"#000044\">" << endl
     << endl
-    << "<h1 align=center> Distribution of " << cur_command->GetDesc()
+    << "<h1 align=center> Distribution of " << cur_command->GetDesc(first_genotype)
     << endl << endl
     << "<center>" << endl
     << "<table border=1 cellpadding=2>" << endl
-    << "<tr><th bgcolor=\"#AAAAFF\">" << cur_command->GetDesc() << "</tr>"
+    << "<tr><th bgcolor=\"#AAAAFF\">" << cur_command->GetDesc(first_genotype) << "</tr>"
     << endl;
   }
   
@@ -2284,7 +2283,6 @@
     while ((genotype = batch_it.Next()) != NULL) {
       if (file_type == FILE_TYPE_HTML) fp << "<td>";
       
-      genotype->SetSpecialArgs(cur_command->GetArgs());
       if (file_type == FILE_TYPE_HTML) {
         HTMLPrintStat(cur_command->GetValue(genotype), fp, 0, cur_command->GetHtmlCellFlags(), cur_command->GetNull());
       }
@@ -2336,6 +2334,7 @@
   
   // Setup the file...
   ofstream& fp = m_world->GetDataFileOFStream(filename);
+  cAnalyzeGenotype* first_genotype = batch[cur_batch].List().GetFirst();
   
   // Determine the file type...
   int file_type = FILE_TYPE_TEXT;
@@ -2357,7 +2356,7 @@
     fp << "# 1: Batch Name" << endl;
     int count = 1;
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString& entry_desc = output_it.Get()->GetDesc(first_genotype);
       fp << "# " << ++count << ": " << entry_desc << endl;
     }
     fp << endl;
@@ -2376,7 +2375,7 @@
     
     fp << "<th bgcolor=\"#AAAAFF\">Batch ";
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString& entry_desc = output_it.Get()->GetDesc(first_genotype);
       fp << "<th bgcolor=\"#AAAAFF\">" << entry_desc << " ";
     }
     fp << "</tr>" << endl;
@@ -2454,6 +2453,8 @@
 void cAnalyze::CommandHistogram_Header(ostream& fp, int format_type,
                                        tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
 {
+  cAnalyzeGenotype* first_genotype = batch[cur_batch].List().GetFirst();
+
   // Write out the header on the file
   if (format_type == FILE_TYPE_TEXT) {
     fp << "#filetype histogram_data" << endl;
@@ -2468,7 +2469,7 @@
     fp << "# Histograms:" << endl;
     int count = 0;
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString & entry_desc = output_it.Get()->GetDesc(first_genotype);
       fp << "# " << ++count << ": " << entry_desc << endl;
     }
     fp << endl;
@@ -2487,7 +2488,7 @@
     << "<table border=1 cellpadding=2><tr>" << endl;
     
     while (output_it.Next() != NULL) {
-      const cString & entry_desc = output_it.Get()->GetDesc();
+      const cString & entry_desc = output_it.Get()->GetDesc(first_genotype);
       const cString & entry_name = output_it.Get()->GetName();
       fp << "<tr><th bgcolor=\"#AAAAFF\"><a href=\"#"
         << entry_name << "\">"
@@ -2499,18 +2500,19 @@
 
 
 void cAnalyze::CommandHistogram_Body(ostream& fp, int format_type,
-                                     tListIterator< tDataEntryCommand<cAnalyzeGenotype> > & output_it)
+                                     tListIterator< tDataEntryCommand<cAnalyzeGenotype> >& output_it)
 {
   output_it.Reset();
   tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
+  cAnalyzeGenotype* first_genotype = batch[cur_batch].List().GetFirst();
   
   while ((data_command = output_it.Next()) != NULL) {
     if (format_type == FILE_TYPE_TEXT) {
-      fp << "# --- " << data_command->GetDesc() << " ---" << endl;
+      fp << "# --- " << data_command->GetDesc(first_genotype) << " ---" << endl;
     } else {
       fp << "<table cellpadding=3>" << endl
       << "<tr><th colspan=3><a name=\"" << data_command->GetName() << "\">"
-      << data_command->GetDesc() << "</th></tr>" << endl;
+      << data_command->GetDesc(first_genotype) << "</th></tr>" << endl;
     }
     
     tDictionary<int> count_dict;
@@ -4820,7 +4822,7 @@
       fp << "<tr><td colspan=3> ";
       output_it.Reset();
       while (output_it.Next() != NULL) {
-        fp << "<th>" << output_it.Get()->GetDesc() << " ";
+        fp << "<th>" << output_it.Get()->GetDesc(genotype) << " ";
       }
       fp << "</tr>" << endl;
       
@@ -4829,7 +4831,6 @@
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
       cAnalyzeGenotype null_genotype(m_world, "a", inst_set);
       while ((data_command = output_it.Next()) != NULL) {
-        genotype->SetSpecialArgs(data_command->GetArgs());
         const cFlexVar cur_value = data_command->GetValue(genotype);
         const cFlexVar null_value = data_command->GetValue(&null_genotype);
         int compare = CompareFlexStat(cur_value, null_value, data_command->GetCompareType()); 
@@ -4888,7 +4889,6 @@
       tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
       int cur_col = 0;
       while ((data_command = output_it.Next()) != NULL) {
-        test_genotype.SetSpecialArgs(data_command->GetArgs());
         const cFlexVar test_value = data_command->GetValue(&test_genotype);
         int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), data_command->GetCompareType());
         
@@ -5119,13 +5119,11 @@
         tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
         int cur_col = 0;
         while ((data_command = output_it.Next()) != NULL) {
-          test_genotype.SetSpecialArgs(data_command->GetArgs());
           const cFlexVar test_value = data_command->GetValue(&test_genotype);
           
           // This is done so that under 'binary' option it marks
           // the task as being influenced by the mutation iff
           // it is completely knocked out, not just decreased
-          genotype->SetSpecialArgs(data_command->GetArgs());
           
           int compare_type = data_command->GetCompareType();
           int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), compare_type);
@@ -5343,7 +5341,6 @@
       tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
       int cur_trait = 0;
       while ((data_command = output_it.Next()) != NULL) {
-        test_genotype.SetSpecialArgs(data_command->GetArgs());
         const cFlexVar test_value = data_command->GetValue(&test_genotype);
         
         int compare_type = data_command->GetCompareType();

Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/analyze/cAnalyzeGenotype.cc	2008-10-25 22:57:34 UTC (rev 2882)
@@ -225,92 +225,81 @@
   //   FLEX_COMPARE_MAX2   = 5  -- Same as FLEX_COMPARE_MAX, and 0 indicates trait is off.
   //   FLEX_COMPARE_MIN2   = 6  -- Same as FLEX_COMPARE_MIN, BUT 0 still indicates off.
   
-  ADD_GDATA(const cString&, "name", "Genotype Name",                 GetName,           SetName,       0, 0, 0);
-  ADD_GDATA(bool,   "viable",       "Is Viable (0/1)",               GetViable,         SetViable,     5, 0, 0);
-  ADD_GDATA(int,    "id",           "Genotype ID",                   GetID,             SetID,         0, 0, 0);
-  ADD_GDATA(const cString &, "tag", "Genotype Tag",                  GetTag,            SetTag,        0, "(none)","");
-  ADD_GDATA(int,    "parent_id",    "Parent ID",                     GetParentID,       SetParentID,   0, 0, 0);
-  ADD_GDATA(int,    "parent2_id",   "Second Parent ID (sexual orgs)",GetParent2ID,      SetParent2ID,  0, 0, 0);
-  ADD_GDATA(int,    "parent_dist",  "Parent Distance",               GetParentDist,     SetParentDist, 0, 0, 0);
-  ADD_GDATA(int,    "ancestor_dist","Ancestor Distance",             GetAncestorDist,   SetAncestorDist, 0, 0, 0);
-  ADD_GDATA(int,    "lineage",      "Unique Lineage Label",          GetLineageLabel,   SetLineageLabel, 0, 0, 0);
-  ADD_GDATA(int,    "num_cpus",     "Number of CPUs",                GetNumCPUs,        SetNumCPUs,    0, 0, 0);
-  ADD_GDATA(int,    "total_cpus",   "Total CPUs Ever",               GetTotalCPUs,      SetTotalCPUs,  0, 0, 0);
-  ADD_GDATA(int,    "length",       "Genome Length",                 GetLength,         SetLength,     4, 0, 0);
-  ADD_GDATA(int,    "copy_length",  "Copied Length",                 GetCopyLength,     SetCopyLength, 0, 0, 0);
-  ADD_GDATA(int,    "exe_length",   "Executed Length",               GetExeLength,      SetExeLength,  0, 0, 0);
-  ADD_GDATA(double, "merit",        "Merit",                         GetMerit,          SetMerit,      5, 0, 0);
-  ADD_GDATA(double, "comp_merit",   "Computational Merit",           GetCompMerit,      SetNULL,       5, 0, 0);
-  ADD_GDATA(double, "comp_merit_ratio", "Computational Merit Ratio", GetCompMeritRatio, SetNULL,       5, 0, 0);
-  ADD_GDATA(int,    "gest_time",    "Gestation Time",                GetGestTime,       SetGestTime,   6, "Inf", 0);
-  ADD_GDATA(double, "efficiency",   "Rep. Efficiency",               GetEfficiency,     SetNULL,       5, 0, 0);
-  ADD_GDATA(double, "efficiency_ratio", "Rep. Efficiency Ratio",     GetEfficiencyRatio,SetNULL,       5, 0, 0);
-  ADD_GDATA(double, "fitness",      "Fitness",                       GetFitness,        SetFitness,    5, 0, 0);
-  ADD_GDATA(double, "div_type",     "Divide Type",                   GetDivType,        SetDivType,    0, 0, 0);
-  ADD_GDATA(int,    "mate_id",      "Mate Selection ID Number",      GetMateID,         SetMateID,     0, 0, 0);
-  ADD_GDATA(double, "fitness_ratio","Fitness Ratio",                 GetFitnessRatio,   SetNULL,       5, 0, 0);
-  ADD_GDATA(int,    "update_born",  "Update Born",                   GetUpdateBorn,     SetUpdateBorn, 0, 0, 0);
-  ADD_GDATA(int,    "update_dead",  "Update Dead",                   GetUpdateDead,     SetUpdateDead, 0, 0, 0);
-  ADD_GDATA(int,    "depth",        "Tree Depth",                    GetDepth,          SetDepth,      0, 0, 0);
-  ADD_GDATA(double, "frac_dead",    "Fraction Mutations Lethal",     GetFracDead,       SetNULL,       0, 0, 0);
-  ADD_GDATA(double, "frac_neg",     "Fraction Mutations Detrimental",GetFracNeg,        SetNULL,       0, 0, 0);
-  ADD_GDATA(double, "frac_neut",    "Fraction Mutations Neutral",    GetFracNeut,       SetNULL,       0, 0, 0);
-  ADD_GDATA(double, "frac_pos",     "Fraction Mutations Beneficial", GetFracPos,        SetNULL,       0, 0, 0);
-  ADD_GDATA(double, "complexity",   "Basic Complexity (beneficial muts are neutral)", GetComplexity, SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "land_fitness", "Average Lanscape Fitness",      GetLandscapeFitness, SetNULL,     0, 0, 0);
+  ADD_GDATA(const cString& (), "name",         "Genotype Name",                 GetName,           SetName,       0, 0, 0);
+  ADD_GDATA(bool (),           "viable",       "Is Viable (0/1)",               GetViable,         SetViable,     5, 0, 0);
+  ADD_GDATA(int (),            "id",           "Genotype ID",                   GetID,             SetID,         0, 0, 0);
+  ADD_GDATA(const cString& (), "tag",          "Genotype Tag",                  GetTag,            SetTag,        0, "(none)","");
+  ADD_GDATA(int (),            "parent_id",    "Parent ID",                     GetParentID,       SetParentID,   0, 0, 0);
+  ADD_GDATA(int (),            "parent2_id",   "Second Parent ID (sexual orgs)",GetParent2ID,      SetParent2ID,  0, 0, 0);
+  ADD_GDATA(int (),            "parent_dist",  "Parent Distance",               GetParentDist,     SetParentDist, 0, 0, 0);
+  ADD_GDATA(int (),            "ancestor_dist","Ancestor Distance",             GetAncestorDist,   SetAncestorDist, 0, 0, 0);
+  ADD_GDATA(int (),            "lineage",      "Unique Lineage Label",          GetLineageLabel,   SetLineageLabel, 0, 0, 0);
+  ADD_GDATA(int (),            "num_cpus",     "Number of CPUs",                GetNumCPUs,        SetNumCPUs,    0, 0, 0);
+  ADD_GDATA(int (),            "total_cpus",   "Total CPUs Ever",               GetTotalCPUs,      SetTotalCPUs,  0, 0, 0);
+  ADD_GDATA(int (),            "length",       "Genome Length",                 GetLength,         SetLength,     4, 0, 0);
+  ADD_GDATA(int (),            "copy_length",  "Copied Length",                 GetCopyLength,     SetCopyLength, 0, 0, 0);
+  ADD_GDATA(int (),            "exe_length",   "Executed Length",               GetExeLength,      SetExeLength,  0, 0, 0);
+  ADD_GDATA(double (),         "merit",        "Merit",                         GetMerit,          SetMerit,      5, 0, 0);
+  ADD_GDATA(double (),         "comp_merit",   "Computational Merit",           GetCompMerit,      SetNULL,       5, 0, 0);
+  ADD_GDATA(double (),         "comp_merit_ratio", "Computational Merit Ratio", GetCompMeritRatio, SetNULL,       5, 0, 0);
+  ADD_GDATA(int (),            "gest_time",    "Gestation Time",                GetGestTime,       SetGestTime,   6, "Inf", 0);
+  ADD_GDATA(double (),         "efficiency",   "Rep. Efficiency",               GetEfficiency,     SetNULL,       5, 0, 0);
+  ADD_GDATA(double (),         "efficiency_ratio", "Rep. Efficiency Ratio",     GetEfficiencyRatio,SetNULL,       5, 0, 0);
+  ADD_GDATA(double (),         "fitness",      "Fitness",                       GetFitness,        SetFitness,    5, 0, 0);
+  ADD_GDATA(double (),         "div_type",     "Divide Type",                   GetDivType,        SetDivType,    0, 0, 0);
+  ADD_GDATA(int (),            "mate_id",      "Mate Selection ID Number",      GetMateID,         SetMateID,     0, 0, 0);
+  ADD_GDATA(double (),         "fitness_ratio","Fitness Ratio",                 GetFitnessRatio,   SetNULL,       5, 0, 0);
+  ADD_GDATA(int (),            "update_born",  "Update Born",                   GetUpdateBorn,     SetUpdateBorn, 0, 0, 0);
+  ADD_GDATA(int (),            "update_dead",  "Update Dead",                   GetUpdateDead,     SetUpdateDead, 0, 0, 0);
+  ADD_GDATA(int (),            "depth",        "Tree Depth",                    GetDepth,          SetDepth,      0, 0, 0);
+  ADD_GDATA(double (),         "frac_dead",    "Fraction Mutations Lethal",     GetFracDead,       SetNULL,       0, 0, 0);
+  ADD_GDATA(double (),         "frac_neg",     "Fraction Mutations Detrimental",GetFracNeg,        SetNULL,       0, 0, 0);
+  ADD_GDATA(double (),         "frac_neut",    "Fraction Mutations Neutral",    GetFracNeut,       SetNULL,       0, 0, 0);
+  ADD_GDATA(double (),         "frac_pos",     "Fraction Mutations Beneficial", GetFracPos,        SetNULL,       0, 0, 0);
+  ADD_GDATA(double (),         "complexity",   "Basic Complexity (beneficial muts are neutral)", GetComplexity, SetNULL, 0, 0, 0);
+  ADD_GDATA(double (),         "land_fitness", "Average Lanscape Fitness",      GetLandscapeFitness, SetNULL,     0, 0, 0);
   
-  ADD_GDATA(int,    "num_phen",           "Number of Plastic Phenotypes",          GetNumPhenotypes,          SetNULL, 0, 0, 0);
-  ADD_GDATA(int,    "num_trials",         "Number of Recalculation Trials",        GetNumTrials,              SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_entropy",       "Phenotpyic Entropy",                    GetPhenotypicEntropy,      SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_max_fitness",   "Phen Plast Maximum Fitness",            GetMaximumFitness,         SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_max_fit_freq",  "Phen Plast Maximum Fitness Frequency",  GetMaximumFitnessFrequency,SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_min_fitness",   "Phen Plast Minimum Fitness",            GetMinimumFitness,         SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_min_freq",      "Phen Plast Minimum Fitness Frequency",  GetMinimumFitnessFrequency,SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_avg_fitness",   "Phen Plast Wtd Avg Fitness",            GetAverageFitness,         SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_likely_freq",   "Freq of Most Likely Phenotype",         GetLikelyFrequency,        SetNULL, 0, 0, 0);
-  ADD_GDATA(double, "phen_likely_fitness","Fitness of Most Likely Phenotype",      GetLikelyFitness,          SetNULL, 0, 0, 0);
+  ADD_GDATA(int (),    "num_phen",           "Number of Plastic Phenotypes",          GetNumPhenotypes,          SetNULL, 0, 0, 0);
+  ADD_GDATA(int (),    "num_trials",         "Number of Recalculation Trials",        GetNumTrials,              SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_entropy",       "Phenotpyic Entropy",                    GetPhenotypicEntropy,      SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_max_fitness",   "Phen Plast Maximum Fitness",            GetMaximumFitness,         SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_max_fit_freq",  "Phen Plast Maximum Fitness Frequency",  GetMaximumFitnessFrequency,SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_min_fitness",   "Phen Plast Minimum Fitness",            GetMinimumFitness,         SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_min_freq",      "Phen Plast Minimum Fitness Frequency",  GetMinimumFitnessFrequency,SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_avg_fitness",   "Phen Plast Wtd Avg Fitness",            GetAverageFitness,         SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_likely_freq",   "Freq of Most Likely Phenotype",         GetLikelyFrequency,        SetNULL, 0, 0, 0);
+  ADD_GDATA(double (), "phen_likely_fitness","Fitness of Most Likely Phenotype",      GetLikelyFitness,          SetNULL, 0, 0, 0);
   
-  ADD_GDATA(const cString &, "parent_muts", "Mutations from Parent", GetParentMuts,   SetParentMuts, 0, "(none)", "");
-  ADD_GDATA(const cString &, "task_order", "Task Performance Order", GetTaskOrder,    SetTaskOrder,  0, "(none)", "");
-  ADD_GDATA(cString, "sequence",    "Genome Sequence",               GetSequence,     SetSequence,   0, "(N/A)", "");
-  ADD_GDATA(const cString &, "alignment", "Aligned Sequence",        GetAlignedSequence, SetAlignedSequence, 0, "(N/A)", "");
+  ADD_GDATA(const cString& (), "parent_muts", "Mutations from Parent", GetParentMuts,   SetParentMuts, 0, "(none)", "");
+  ADD_GDATA(const cString& (), "task_order", "Task Performance Order", GetTaskOrder,    SetTaskOrder,  0, "(none)", "");
+  ADD_GDATA(cString (),        "sequence",    "Genome Sequence",               GetSequence,     SetSequence,   0, "(N/A)", "");
+  ADD_GDATA(const cString& (), "alignment", "Aligned Sequence",        GetAlignedSequence, SetAlignedSequence, 0, "(N/A)", "");
   
-  ADD_GDATA(cString, "executed_flags", "Executed Flags",             GetExecutedFlags, SetNULL, 0, "(N/A)", "");
-  ADD_GDATA(cString, "alignment_executed_flags", "Alignment Executed Flags", GetAlignmentExecutedFlags, SetNULL, 0, "(N/A)", "");
-  ADD_GDATA(cString, "task_list", "List of all tasks performed",     GetTaskList,     SetNULL, 0, "(N/A)", "");
-  ADD_GDATA(cString, "link.tasksites", "Phenotype Map",              GetMapLink,      SetNULL, 0, 0,       0);
-  ADD_GDATA(cString, "html.sequence",  "Genome Sequence",            GetHTMLSequence, SetNULL, 0, "(N/A)", "");
+  ADD_GDATA(cString (), "executed_flags", "Executed Flags",             GetExecutedFlags, SetNULL, 0, "(N/A)", "");
+  ADD_GDATA(cString (), "alignment_executed_flags", "Alignment Executed Flags", GetAlignmentExecutedFlags, SetNULL, 0, "(N/A)", "");
+  ADD_GDATA(cString (), "task_list", "List of all tasks performed",     GetTaskList,     SetNULL, 0, "(N/A)", "");
+  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);
+  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 = world->GetEnvironment();
-  for (int i = 0; i < environment.GetNumTasks(); i++) {
-    cString t_name, t_desc;
-    t_name.Set("task.%d", i);
-    t_desc = environment.GetTask(i).GetDesc();
-    dedict->Add(t_name,
-      new tDataEntryWithArg<cAnalyzeGenotype, int, int>(t_name, t_desc, &cAnalyzeGenotype::GetTaskCount, i, 5));
-  }
   
-  for (int i = 0; i < environment.GetInputSize(); i++){
-    cString t_name, t_desc;
-    t_name.Set("env_input.%d", i);
-    t_desc.Set("env_input.%d", i);
-    dedict->Add(t_name,
-      new tDataEntryWithArg<cAnalyzeGenotype, int, int>(t_name, t_desc, &cAnalyzeGenotype::GetEnvInput, i, 0));
-  }
-  
+  dedict->Add("task", new tDataEntryOfType<cAnalyzeGenotype, int (int, const cStringList&)>
+              ("task", &cAnalyzeGenotype::DescTask, &cAnalyzeGenotype::GetTaskCount, 5));
+  dedict->Add("env_input", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
+              ("env_input", &cAnalyzeGenotype::DescEnvInput, &cAnalyzeGenotype::GetEnvInput));
+    
   // The remaining values should actually go in a seperate list called
   // "population_data_list", but for the moment we're going to put them
   // here so that we only need to worry about a single system to load and
   // save genotype information.
-  ADD_GDATA(int, "update",       "Update Output",                   GetUpdateDead, SetUpdateDead, 0, 0, 0);
-  ADD_GDATA(int, "dom_num_cpus", "Number of Dominant Organisms",    GetNumCPUs,    SetNumCPUs,    0, 0, 0);
-  ADD_GDATA(int, "dom_depth",    "Tree Depth of Dominant Genotype", GetDepth,      SetDepth,      0, 0, 0);
-  ADD_GDATA(int, "dom_id",       "Dominant Genotype ID",            GetID,         SetID,         0, 0, 0);
-  ADD_GDATA(cString, "dom_sequence", "Dominant Genotype Sequence",  GetSequence,   SetSequence,   0, "(N/A)", "");
+  ADD_GDATA(int (),     "update",       "Update Output",                   GetUpdateDead, SetUpdateDead, 0, 0, 0);
+  ADD_GDATA(int (),     "dom_num_cpus", "Number of Dominant Organisms",    GetNumCPUs,    SetNumCPUs,    0, 0, 0);
+  ADD_GDATA(int (),     "dom_depth",    "Tree Depth of Dominant Genotype", GetDepth,      SetDepth,      0, 0, 0);
+  ADD_GDATA(int (),     "dom_id",       "Dominant Genotype ID",            GetID,         SetID,         0, 0, 0);
+  ADD_GDATA(cString (), "dom_sequence", "Dominant Genotype Sequence",      GetSequence,   SetSequence,   0, "(N/A)", "");
   
   return dedict;
   
@@ -331,11 +320,12 @@
 tDataEntryCommand<cAnalyzeGenotype>* cAnalyzeGenotype::GetDataCommand(cWorld* world, const cString& cmd) 
 {
   cString arg_list = cmd;
-  cString entry_name = arg_list.Pop(':');
+  cString idx = arg_list.Pop(':');
+  cString entry_name = idx.Pop('.');
   
   tDataEntry<cAnalyzeGenotype>* data_entry;
   if (world->GetGenotypeDEDict().Find(entry_name, data_entry)) {
-    return new tDataEntryCommand<cAnalyzeGenotype>(data_entry, arg_list);
+    return new tDataEntryCommand<cAnalyzeGenotype>(data_entry, idx, arg_list);
   }
   
   cDriverManager::Status().NotifyWarning(cStringUtil::Stringf("data entry '%s' not found, best match is '%s'", *entry_name,
@@ -351,10 +341,12 @@
 {
   if (arg_list.GetSize() == 0) {
     // If no args were given, load all of the stats.
+    // @TODO - handle indexed items...  under this scheme only the first task and env_input value will be output    
+
     tArray<tDataEntry<cAnalyzeGenotype>*> data_entries;
     world->GetGenotypeDEDict().GetValues(data_entries);
     for (int i = 0; i < data_entries.GetSize(); i++)
-      output_list.PushRear(new tDataEntryCommand<cAnalyzeGenotype>(data_entries[i], ""));
+      output_list.PushRear(new tDataEntryCommand<cAnalyzeGenotype>(data_entries[i]));
   } else {
     while (arg_list.GetSize() != 0) {
       tDataEntryCommand<cAnalyzeGenotype>* cur_command = GetDataCommand(world, arg_list.Pop());
@@ -364,6 +356,11 @@
 }
 
 
+cString cAnalyzeGenotype::DescTask(int task_id) const
+{
+  if (task_id > task_counts.GetSize()) return "";
+  return m_world->GetEnvironment().GetTask(task_id).GetDesc();
+}
 
 
 

Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/analyze/cAnalyzeGenotype.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -211,8 +211,6 @@
   };
   mutable cAnalyzePhenPlast* m_phenplast_stats;
   
-  cStringList special_args; // These are args placed after a ':' in details...
-
   int NumCompare(double new_val, double old_val) const {
     if (new_val == old_val) return  0;
     else if (new_val == 0)       return -2;
@@ -242,9 +240,6 @@
   static tDataEntryCommand<cAnalyzeGenotype>* GetDataCommand(cWorld* world, const cString& cmd);
   static void LoadDataCommandList(cWorld* world, cStringList arg_list, tList<tDataEntryCommand<cAnalyzeGenotype> >& output_list);
 
-  const cStringList & GetSpecialArgs() { return special_args; }
-  void SetSpecialArgs(const cStringList & _args) { special_args = _args; }
-
   void Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info = NULL, cAnalyzeGenotype* parent_genotype = NULL, int num_trials = 1);
   void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);
   void PrintTasksQuality(std::ofstream& fp, int min_task = 0, int max_task = -1);
@@ -289,6 +284,7 @@
 //    void SetFracPos(double in_frac);
 
   // A set of NULL accessors to simplyfy automated accesses.
+  void SetNULL(int idx, int dummy) { (void) dummy; }
   void SetNULL(int dummy) { (void) dummy; }
   void SetNULL(char dummy) { (void) dummy; }
   void SetNULL(double dummy) { (void) dummy; }
@@ -384,12 +380,17 @@
   int GetNumTasks() const { return task_counts.GetSize(); }
   int GetTaskCount(int task_id) const {
     if (task_id >= task_counts.GetSize()) return 0;
-    if (special_args.HasString("binary")) return (task_counts[task_id] > 0);
     return task_counts[task_id];
   }
-  const tArray<int> & GetTaskCounts() const {
+  int GetTaskCount(int task_id, const cStringList& args) const {
+    if (task_id >= task_counts.GetSize()) return 0;
+    if (args.HasString("binary")) return (task_counts[task_id] > 0);
+    return task_counts[task_id];
+  }
+  const tArray<int>& GetTaskCounts() const {
     return task_counts;
   }
+  cString DescTask(int task_id) const;
   
   double GetTaskQuality(int task_id) const {
 	  if (task_id >= task_counts.GetSize()) return 0;
@@ -422,6 +423,7 @@
   const tArray<int>& GetEnvInputs() const{
     return m_env_inputs;
   }
+  cString DescEnvInput(int input_id) const { return cStringUtil::Stringf("task.%d", input_id); }
 
   // Comparisons...  Compares a genotype to the "previous" one, which is
   // passed in, in one specified phenotype.

Modified: development/source/tools/cFlexVar.h
===================================================================
--- development/source/tools/cFlexVar.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/tools/cFlexVar.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -228,6 +228,8 @@
   double AsDouble() const { return m_var->AsDouble(); }
   cString AsString() const { return m_var->AsString(); }
   void SetString(cString & in_str) const { m_var->SetString(in_str); }
+  
+  template<class Type> Type As() const;
 
   // Setup a way to convert the native types
   int MakeInt() { int val = AsInt(); delete m_var; m_var = new cFlexVar_Int(val); return val; }
@@ -273,6 +275,12 @@
   
 };
 
+template<> inline int cFlexVar::As<int>() const { return m_var->AsInt(); }
+template<> inline char cFlexVar::As<char>() const { return m_var->AsChar(); }
+template<> inline double cFlexVar::As<double>() const { return m_var->AsDouble(); }
+template<> inline cString cFlexVar::As<cString>() const { return m_var->AsString(); }
+
+
 inline std::ostream& operator << (std::ostream& out, const cFlexVar & entry)
 {
   entry.Print(out);

Modified: development/source/tools/cStringList.h
===================================================================
--- development/source/tools/cStringList.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/tools/cStringList.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -48,7 +48,7 @@
 private:
   tList<cString> string_list;
 
-  inline cString ReturnString(cString * out_string)
+  inline cString ReturnString(cString* out_string)
   {
     cString tmp_string(*out_string);
     delete out_string;
@@ -65,15 +65,15 @@
 
   int GetSize() const { return string_list.GetSize(); }
   cString GetLine(int line_num) const { return *(string_list.GetPos(line_num)); }
-  const tList<cString> & GetList() const { return string_list; }
+  const tList<cString>& GetList() const { return string_list; }
 
-  bool HasString(const cString & test_string) const;
-  cString PopString(const cString & test_string);
+  bool HasString(const cString& test_string) const;
+  cString PopString(const cString& test_string);
   cString PopLine(int);
   int LocateString(const cString& test_string) const;
   
-  void Push(const cString & _in) { string_list.Push(new cString(_in));}
-  void PushRear(const cString & _in) { string_list.PushRear(new cString(_in));}
+  void Push(const cString& _in) { string_list.Push(new cString(_in));}
+  void PushRear(const cString& _in) { string_list.PushRear(new cString(_in));}
   cString Pop() { return ReturnString(string_list.Pop()); }
   cString PopRear() { return ReturnString(string_list.PopRear()); }
 

Modified: development/source/tools/tDataEntry.h
===================================================================
--- development/source/tools/tDataEntry.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/tools/tDataEntry.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -31,15 +31,17 @@
 #ifndef cFlexVar_h
 #include "cFlexVar.h"
 #endif
-
 #ifndef cString_h
 #include "cString.h"
 #endif
-
+#ifndef cStringList_h
+#include "cStringList.h"
+#endif
 #ifndef cStringUtil_h
 #include "cStringUtil.h"
 #endif
 
+
 template <class TargetType> class tDataEntry
 {
 private:
@@ -48,6 +50,7 @@
   int m_compare_type;        // ID to indicate how values should be compared.
   cString m_null_value;      // Value when "off", such as "0", "Inf.", or "N/A"
   cString m_html_table_flags; // String to include in <td> entry in html mode.
+  cStringList m_default_args;
   
 public:
   tDataEntry(const cString& name, const cString& desc, int compare_type = 0,
@@ -56,17 +59,20 @@
   virtual ~tDataEntry() { ; }
   
   const cString& GetName() const { return m_name; }
-  const cString& GetDesc() const { return m_desc; }
+  virtual cString GetDesc(const TargetType* target, const cFlexVar& idx) const { return m_desc; }
   int GetCompareType() const { return m_compare_type; }
   const cString& GetNull() const { return m_null_value; }
   const cString& GetHtmlCellFlags() const { return m_html_table_flags; }
   
-  virtual bool Set(TargetType* target, const cString& value) const { (void) value; return false; }
-  virtual cFlexVar Get(const TargetType* target) const = 0;
+  virtual bool Set(TargetType* target, const cFlexVar&, const cStringList&, const cString&) const { return false; }
+  virtual cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const = 0;
+  virtual cFlexVar Get(const TargetType* target) const { return Get(target, 0, m_default_args); }
 };
 
+template <class TargetType, class EntryType> class tDataEntryOfType;
 
-template <class TargetType, class EntryType> class tDataEntryOfType : public tDataEntry<TargetType>
+template <class TargetType, class EntryType>
+  class tDataEntryOfType<TargetType, EntryType ()> : public tDataEntry<TargetType>
 {
 protected:
   EntryType  (TargetType::*DataGet)() const;
@@ -78,7 +84,7 @@
                    int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
   : tDataEntry<TargetType>(name, desc, compare_type, null, html_cell), DataGet(_funR), DataSet(_funS) { ; }
 
-  bool Set(TargetType* target, const cString& value) const
+  bool Set(TargetType* target, const cFlexVar&, const cStringList&, const cString& value) const
   {
     assert(target != NULL);
     EntryType new_value(0);
@@ -87,7 +93,7 @@
     return true;
   }
 
-  cFlexVar Get(const TargetType* target) const
+  cFlexVar Get(const TargetType* target, const cFlexVar&, const cStringList&) const
   {
     assert(target != NULL);
     return cFlexVar((target->*DataGet)());
@@ -95,23 +101,59 @@
 };
 
 
-template <class TargetType, class EntryType, class ArgType> class tDataEntryWithArg : public tDataEntry<TargetType>
+template <class TargetType, class EntryType, class IdxType>
+  class tDataEntryOfType<TargetType, EntryType (IdxType)> : public tDataEntry<TargetType>
 {
 protected:
-  EntryType (TargetType::*DataRetrieval)(ArgType) const;
-  ArgType m_arg;
+  EntryType (TargetType::*DataRetrieval)(IdxType) const;
+  cString (TargetType::*DescFunction)(IdxType) const;
   
 public:
-  tDataEntryWithArg(const cString& name, const cString& desc, EntryType (TargetType::*_funR)(ArgType) const, ArgType arg,
-                    int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
-  : tDataEntry<TargetType>(name, desc, compare_type, null, html_cell), DataRetrieval(_funR), m_arg(arg) { ; }
+  tDataEntryOfType(const cString& name,
+                   cString (TargetType::*_funD)(IdxType) const,
+                   EntryType (TargetType::*_funR)(IdxType) const,
+                   int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
   
-  cFlexVar Get(const TargetType* target) const
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
   {
+    return (target->*DescFunction)(idx.As<IdxType>());
+  }
+  
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList&) const
+  {
     assert(target != NULL);
-    return cFlexVar((target->*DataRetrieval)(m_arg));
+    return cFlexVar((target->*DataRetrieval)(idx.As<IdxType>()));
   }
 };
 
 
+template <class TargetType, class EntryType, class IdxType>
+  class tDataEntryOfType<TargetType, EntryType (IdxType, const cStringList&)> : public tDataEntry<TargetType>
+{
+protected:
+  EntryType (TargetType::*DataRetrieval)(IdxType, const cStringList&) const;
+  cString (TargetType::*DescFunction)(IdxType) const;
+  
+public:
+  tDataEntryOfType(const cString& name,
+                   cString (TargetType::*_funD)(IdxType) const,
+                   EntryType (TargetType::*_funR)(IdxType, const cStringList&) const,
+                   int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
+  
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
+  {
+    return (target->*DescFunction)(idx.As<IdxType>());
+  }
+
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return cFlexVar((target->*DataRetrieval)(idx.As<IdxType>(), args));
+  }
+};
+
+
 #endif

Modified: development/source/tools/tDataEntryCommand.h
===================================================================
--- development/source/tools/tDataEntryCommand.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/tools/tDataEntryCommand.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -47,21 +47,23 @@
 {
 private:
   tDataEntry<T>* m_data_entry;
+  cFlexVar m_idx;
   cStringList m_args;
+  
 public:
-  tDataEntryCommand(tDataEntry<T>* entry, const cString& args = "") : m_data_entry(entry), m_args(args, ':') { ; }
+  tDataEntryCommand(tDataEntry<T>* entry, const cString& idx = "", const cString& args = "")
+    : m_data_entry(entry), m_idx(idx), m_args(args, ':') { ; }
   
-  const cStringList& GetArgs() const { return m_args; }
   bool HasArg(const cString& test_arg) const { return m_args.HasString(test_arg); }
-
+  
   const cString& GetName() const { return m_data_entry->GetName(); }
-  const cString& GetDesc() const { return m_data_entry->GetDesc(); }
+  cString GetDesc(const T* target) const { return m_data_entry->GetDesc(target, m_idx); }
   int GetCompareType() const { return m_data_entry->GetCompareType(); }
   const cString& GetNull() const { return m_data_entry->GetNull(); }
   const cString& GetHtmlCellFlags() const { return m_data_entry->GetHtmlCellFlags(); }
   
-  bool SetValue(T* target, const cString& value) const { return m_data_entry->Set(target, value); }
-  cFlexVar GetValue(const T* target) const { return m_data_entry->Get(target); }
+  bool SetValue(T* target, const cString& value) const { return m_data_entry->Set(target, m_idx, m_args, value); }
+  cFlexVar GetValue(const T* target) const { return m_data_entry->Get(target, m_idx, m_args); }
 };
 
 #endif

Modified: development/source/tools/tDataManager.h
===================================================================
--- development/source/tools/tDataManager.h	2008-10-25 01:27:22 UTC (rev 2881)
+++ development/source/tools/tDataManager.h	2008-10-25 22:57:34 UTC (rev 2882)
@@ -50,8 +50,8 @@
 {
 private:
   TargetType* m_target;
-  tDictionary<tDataEntry<TargetType>*> m_entry_dict;
-
+  tDictionary<tDataEntry<TargetType>*> m_entry_dict;  
+  
 public:
   tDataManager(TargetType* target, const cString& filetype = "unknown") : cDataManager_Base(filetype), m_target(target) { ; }
   ~tDataManager() { ; }
@@ -61,7 +61,7 @@
                                      int compare = 0, const cString& null = "0", const cString& html_cell = "align=center")
   {
     tDataEntry<TargetType>* new_entry =
-      new tDataEntryOfType<TargetType, EntryType>(name, desc, funR, funS, compare, null, html_cell);
+      new tDataEntryOfType<TargetType, EntryType ()>(name, desc, funR, funS, compare, null, html_cell);
     m_entry_dict.Add(name, new_entry);
     return true;
   }
@@ -78,7 +78,7 @@
   {
     tDataEntry<TargetType>* cur_entry = NULL;
     if (m_entry_dict.Find(name, cur_entry) == false) return false;
-    out_desc = cur_entry->GetDesc();
+    out_desc = cur_entry->GetDesc(m_target, 0);
     return true;
   }
   




More information about the Avida-cvs mailing list