[Avida-SVN] r1853 - in development: Avida.xcodeproj source/analyze

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Jul 27 09:25:10 PDT 2007


Author: brysonda
Date: 2007-07-27 12:25:10 -0400 (Fri, 27 Jul 2007)
New Revision: 1853

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/analyze/cMutationalNeighborhood.cc
   development/source/analyze/cMutationalNeighborhood.h
Log:
MutationalNeighborhood - Add tracking of fitness effects for various mutation pathway classes.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2007-07-27 01:30:38 UTC (rev 1852)
+++ development/Avida.xcodeproj/project.pbxproj	2007-07-27 16:25:10 UTC (rev 1853)
@@ -831,7 +831,7 @@
 		DCC315CE076253A5008F7A48 /* environment.rotate */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = environment.rotate; sourceTree = "<group>"; };
 		DCC315D0076253A5008F7A48 /* task_event_gen.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.cc; sourceTree = "<group>"; };
 		DCC315D1076253A5008F7A48 /* task_event_gen.old.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = task_event_gen.old.cc; sourceTree = "<group>"; };
-		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
+		DCC3164D07626CF3008F7A48 /* avida */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = avida; sourceTree = BUILT_PRODUCTS_DIR; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */

Modified: development/source/analyze/cMutationalNeighborhood.cc
===================================================================
--- development/source/analyze/cMutationalNeighborhood.cc	2007-07-27 01:30:38 UTC (rev 1852)
+++ development/source/analyze/cMutationalNeighborhood.cc	2007-07-27 16:25:10 UTC (rev 1853)
@@ -67,7 +67,7 @@
       tdata.site_count.Resize(m_base_genome.GetSize(), 0);
 
       // Do the processing, starting with One Step
-      ProcessOneStep(ctx, testcpu, test_info, cur_site);
+      ProcessOneStepPoint(ctx, testcpu, test_info, cur_site);
 
       // Cleanup
       delete testcpu;
@@ -126,7 +126,7 @@
 }
 
 
-void cMutationalNeighborhood::ProcessOneStep(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site)
+void cMutationalNeighborhood::ProcessOneStepPoint(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site)
 {
   const int inst_size = m_inst_set.GetSize();
   sStep& odata = m_onestep[cur_site];
@@ -179,16 +179,26 @@
         if (m_base_tasks[i] && !cur_tasks[i]) knockout = true;
         else if (!m_base_tasks[i] && cur_tasks[i]) anytask = true;
       }
-      if (knockout) odata.task_knockout++;
-      if (anytask) odata.task_total++;
-      if (m_base_tasks.GetSize() && !m_base_tasks[m_target] && cur_tasks[m_target]) odata.task_target++;
+      if (knockout) {
+        odata.task_knockout++;
+        odata.task_size_knockout += test_fitness;
+      }
+      if (anytask) {
+        odata.task_total++;
+        odata.task_size_total += test_fitness;
+      }
+      if (m_base_tasks.GetSize() && !m_base_tasks[m_target] && cur_tasks[m_target]) {
+        odata.task_target++;
+        odata.task_size_target += test_fitness;
+      }
     }
 
-    ProcessTwoStep(ctx, testcpu, test_info, cur_site, mod_genome);
+    ProcessTwoStepPoint(ctx, testcpu, test_info, cur_site, mod_genome);
   }
 }
 
-void cMutationalNeighborhood::ProcessTwoStep(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome)
+void cMutationalNeighborhood::ProcessTwoStepPoint(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info,
+                                                  int cur_site, cGenome& mod_genome)
 {
   const int inst_size = m_inst_set.GetSize();
   sStep& tdata = m_twostep[cur_site];
@@ -235,11 +245,19 @@
           if (m_base_tasks[i] && !cur_tasks[i]) knockout = true;
           else if (!m_base_tasks[i] && cur_tasks[i]) anytask = true;
         }
-        if (knockout) tdata.task_knockout++;
-        if (anytask) tdata.task_total++;
+        if (knockout) {
+          tdata.task_knockout++;
+          tdata.task_size_knockout += test_fitness;
+        }
+        if (anytask) {
+          tdata.task_total++;
+          tdata.task_size_total += test_fitness;
+        }
         if (m_base_tasks.GetSize() && !m_base_tasks[m_target] && cur_tasks[m_target]) {
           tdata.task_target++;
-          // Push both instructions as possible first mutations, for post determination of relative fitness
+          tdata.task_size_target += test_fitness;
+          
+          // Push both instructions as possible first mutations, for post determination of first step fitness effect
           m_pending.Push(new sPendingTarget(cur_site, mod_genome[cur_site].GetOp()));
           m_pending.Push(new sPendingTarget(line_num, inst_num));
         }
@@ -270,6 +288,9 @@
   m_o_task_target = 0;
   m_o_task_total = 0;
   m_o_task_knockout = 0;
+  m_o_task_size_target = 0.0;
+  m_o_task_size_total = 0.0;
+  m_o_task_size_knockout = 0.0;
 
   for (int i = 0; i < m_onestep.GetSize(); i++) {
     sStep& odata = m_onestep[i];
@@ -296,6 +317,10 @@
     m_o_task_target += odata.task_target;
     m_o_task_total += odata.task_total;
     m_o_task_knockout += odata.task_knockout;
+
+    m_o_task_size_target += odata.task_size_target;
+    m_o_task_size_total += odata.task_size_total;
+    m_o_task_size_knockout += odata.task_size_knockout;
   }
   
   const double max_ent = log(static_cast<double>(m_inst_set.GetSize()));
@@ -327,6 +352,11 @@
   m_t_task_target_dead = 0;
   m_t_task_total = 0;
   m_t_task_knockout = 0;
+  m_t_task_size_target = 0.0;
+  m_t_task_size_target_pos = 0.0;
+  m_t_task_size_target_neg = 0.0;
+  m_t_task_size_total = 0.0;
+  m_t_task_size_knockout = 0.0;
   
   for (int i = 0; i < m_twostep.GetSize(); i++) {
     sStep& tdata = m_twostep[i];
@@ -353,6 +383,10 @@
     m_t_task_target += tdata.task_target;
     m_t_task_total += tdata.task_total;
     m_t_task_knockout += tdata.task_knockout;
+    
+    m_t_task_size_target += tdata.task_size_target;
+    m_t_task_size_total += tdata.task_size_total;
+    m_t_task_size_knockout += tdata.task_size_knockout;
   }
 
   for (int i = 0; i < m_base_genome.GetSize(); i++) {
@@ -362,19 +396,21 @@
   }
   m_t_complexity = m_base_genome.GetSize() - m_t_total_entropy;
 
-  // @TODO - Do post relative fitness determination for target task counts
   sPendingTarget* pend = NULL;
   while ((pend = m_pending.Pop())) {
     double fitness = m_fitness[pend->site][pend->inst];
     
-    if (fitness == 0.0)
+    if (fitness == 0.0) {
       m_t_task_target_dead++;
-    else if (fitness < m_neut_min)
+    } else if (fitness < m_neut_min) {
       m_t_task_target_neg++;
-    else if (fitness <= m_neut_max)
+      m_t_task_size_target_neg += fitness;
+    } else if (fitness <= m_neut_max) {
       m_t_task_target_neut++;
-    else
+    } else {
       m_t_task_target_pos++;
+      m_t_task_size_target_pos += fitness;
+    }
     
     delete pend;
   }
@@ -409,10 +445,13 @@
   df.Write(GetSingleComplexity(), "One Step Total Complexity");
   df.Write(GetSingleTargetTask(), "One Step Confers Target Task");
   df.Write(GetSingleProbTargetTask(), "One Step Probability Confers Target Task");
+  df.Write(GetSingleAverageSizeTargetTask(), "One Step Average Size of Target Task Conferral");
   df.Write(GetSingleTask(), "One Step Confers Any Task");
   df.Write(GetSingleProbTask(), "One Step Probability Confers Any Task");
+  df.Write(GetSingleAverageSizeTask(), "One Step Average Size of Any Task Conferral");
   df.Write(GetSingleKnockout(), "One Step Knockout Task");
   df.Write(GetSingleProbKnockout(), "One Step Probability Knockout Task");
+  df.Write(GetSingleAverageSizeKnockout(), "One Step Average Size of Task Knockout");
 
   df.Write(GetDoubleTotal(), "Total Two Step Mutants");
   df.Write(GetDoubleProbBeneficial(), "Two Step Probability Beneficial");
@@ -428,18 +467,23 @@
   df.Write(GetDoubleComplexity(), "Two Step Total Complexity");
   df.Write(GetDoubleTargetTask(), "Two Step Confers Target Task");
   df.Write(GetDoubleProbTargetTask(), "Two Step Probability Confers Target Task");
+  df.Write(GetDoubleAverageSizeTargetTask(), "Two Step Average Size of Target Task Conferral");
   df.Write(GetDoubleTargetTaskBeneficial(), "Two Step Confers Target - Previous Beneficial");
   df.Write(GetDoubleProbTargetTaskBeneficial(), "Two Step Prob. Confers Target - Previous Beneficial");
+  df.Write(GetDoubleAverageSizeTargetTaskBeneficial(), "Two Step Ave. Size of Previous Beneficial in Target Conferral");
   df.Write(GetDoubleTargetTaskDeleterious(), "Two Step Confers Target - Previous Deleterious");
   df.Write(GetDoubleProbTargetTaskDeleterious(), "Two Step Prob. Confers Target - Previous Deleterious");
+  df.Write(GetDoubleAverageSizeTargetTaskDeleterious(), "Two Step Ave. Size of Previous Deleterious in Target Conferral");
   df.Write(GetDoubleTargetTaskNeutral(), "Two Step Confers Target - Previous Neutral");
   df.Write(GetDoubleProbTargetTaskNeutral(), "Two Step Prob. Confers Target - Previous Neutral");
   df.Write(GetDoubleTargetTaskLethal(), "Two Step Confers Target - Previous Lethal");
   df.Write(GetDoubleProbTargetTaskLethal(), "Two Step Prob. Confers Target - Previous Lethal");
   df.Write(GetDoubleTask(), "Two Step Confers Any Task");
   df.Write(GetDoubleProbTask(), "Two Step Probability Confers Any Task");
+  df.Write(GetDoubleAverageSizeTask(), "Two Step Average Size of Any Task Conferral");
   df.Write(GetDoubleKnockout(), "Two Step Knockout Task");
   df.Write(GetDoubleProbKnockout(), "Two Step Probability Knockout Task");
+  df.Write(GetDoubleAverageSizeKnockout(), "Two Step Average Size of Task Knockout");
   
   df.Endl();
 }

Modified: development/source/analyze/cMutationalNeighborhood.h
===================================================================
--- development/source/analyze/cMutationalNeighborhood.h	2007-07-27 01:30:38 UTC (rev 1852)
+++ development/source/analyze/cMutationalNeighborhood.h	2007-07-27 16:25:10 UTC (rev 1853)
@@ -93,10 +93,15 @@
     int task_target;
     int task_total;
     int task_knockout;
+    
+    double task_size_target;
+    double task_size_total;
+    double task_size_knockout;
 
     
     sStep() : total(0), total_fitness(0.0), total_sqr_fitness(0.0), peak_fitness(0.0), pos(0), neg(0), neut(0), dead(0),
-      size_pos(0.0), size_neg(0.0), task_target(0), task_total(0), task_knockout(0) { ; }
+      size_pos(0.0), size_neg(0.0), task_target(0), task_total(0), task_knockout(0), task_size_target(0.0),
+      task_size_total(0.0), task_size_knockout(0.0) { ; }
   };
   tArray<sStep> m_onestep;
   tArray<sStep> m_twostep;
@@ -149,6 +154,10 @@
   int m_o_task_total;
   int m_o_task_knockout;
   
+  double m_o_task_size_target;
+  double m_o_task_size_total;
+  double m_o_task_size_knockout;
+  
   // Aggregated Two Step Data
   // --------------------------------------------------------------------------
   int m_t_total;
@@ -178,10 +187,21 @@
   int m_t_task_total;
   int m_t_task_knockout;
 
+  double m_t_task_size_target;
+  double m_t_task_size_target_pos;
+  double m_t_task_size_target_neg;
+  double m_t_task_size_total;
+  double m_t_task_size_knockout;
+  
 
   void ProcessInitialize(cAvidaContext& ctx);
-  void ProcessOneStep(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site);
-  void ProcessTwoStep(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome);
+  void ProcessOneStepPoint(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site);
+  void ProcessTwoStepPoint(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome);
+//  void ProcessOneStepInsert(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site);
+//  void ProcessTwoStepInsert(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome);
+//  void ProcessOneStepDelete(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site);
+//  void ProcessTwoStepDelete(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome);
+//  void ProcessInDelPointCombo(cAvidaContext& ctx, cTestCPU* testcpu, cCPUTestInfo& test_info, int cur_site, cGenome& mod_genome);
   void ProcessComplete(cAvidaContext& ctx);
   
   cMutationalNeighborhood(); // @not_implemented
@@ -222,10 +242,10 @@
   inline const cGenome& GetSinglePeakGenome() const { return m_o_peak_genome; }
   inline double GetSinglePeakFitness() const { return m_o_peak_fitness; }
   
-  inline double GetSingleProbBeneficial()  const { return static_cast<double>(m_o_pos) / m_o_total; }
-  inline double GetSingleProbDeleterious()  const { return static_cast<double>(m_o_neg) / m_o_total; }
-  inline double GetSingleProbNeutral() const { return static_cast<double>(m_o_neut) / m_o_total; }
-  inline double GetSingleProbLethal() const { return static_cast<double>(m_o_dead) / m_o_total; }
+  inline double GetSingleProbBeneficial()  const { return double(m_o_pos) / m_o_total; }
+  inline double GetSingleProbDeleterious()  const { return double(m_o_neg) / m_o_total; }
+  inline double GetSingleProbNeutral() const { return double(m_o_neut) / m_o_total; }
+  inline double GetSingleProbLethal() const { return double(m_o_dead) / m_o_total; }
   inline double GetSingleAverageSizeBeneficial() const { if (m_o_pos == 0) return 0.0; else return m_o_size_pos / m_o_pos; }
   inline double GetSingleAverageSizeDeleterious() const { if (m_o_neg == 0) return 0.0; else return m_o_size_neg / m_o_neg; }
   
@@ -233,11 +253,23 @@
   inline double GetSingleComplexity() const { return m_o_complexity; }
 
   inline int GetSingleTargetTask() const { return m_o_task_target; }
-  inline double GetSingleProbTargetTask() const { return static_cast<double>(m_o_task_target) / m_o_total; }
+  inline double GetSingleProbTargetTask() const { return double(m_o_task_target) / m_o_total; }
+  inline double GetSingleAverageSizeTargetTask() const
+  {
+    if (m_o_task_target == 0) return 0.0; else return double(m_o_task_size_target) / m_o_task_target;
+  }
   inline int GetSingleTask() const { return m_o_task_total; }
-  inline double GetSingleProbTask() const { return static_cast<double>(m_o_task_total) / m_o_total; }
+  inline double GetSingleProbTask() const { return double(m_o_task_total) / m_o_total; }
+  inline double GetSingleAverageSizeTask() const
+  {
+    if (m_o_task_total == 0) return 0.0; else return double(m_o_task_size_total) / m_o_task_total;
+  }
   inline int GetSingleKnockout() const { return m_o_task_knockout; }
-  inline double GetSingleProbKnockout() const { return static_cast<double>(m_o_task_knockout) / m_o_total; }
+  inline double GetSingleProbKnockout() const { return double(m_o_task_knockout) / m_o_total; }
+  inline double GetSingleAverageSizeKnockout() const
+  {
+    if (m_o_task_knockout == 0) return 0.0; else return double(m_o_task_size_knockout) / m_o_task_knockout;
+  }
   
 
   inline int GetDoubleTotal() const { return m_t_total; }
@@ -247,10 +279,10 @@
   inline const cGenome& GetDoublePeakGenome() const { return m_t_peak_genome; }
   inline double GetDoublePeakFitness() const { return m_t_peak_fitness; }
   
-  inline double GetDoubleProbBeneficial()  const { return static_cast<double>(m_t_pos) / m_t_total; }
-  inline double GetDoubleProbDeleterious()  const { return static_cast<double>(m_t_neg) / m_t_total; }
-  inline double GetDoubleProbNeutral() const { return static_cast<double>(m_t_neut) / m_t_total; }
-  inline double GetDoubleProbLethal() const { return static_cast<double>(m_t_dead) / m_t_total; }
+  inline double GetDoubleProbBeneficial()  const { return double(m_t_pos) / m_t_total; }
+  inline double GetDoubleProbDeleterious()  const { return double(m_t_neg) / m_t_total; }
+  inline double GetDoubleProbNeutral() const { return double(m_t_neut) / m_t_total; }
+  inline double GetDoubleProbLethal() const { return double(m_t_dead) / m_t_total; }
   inline double GetDoubleAverageSizeBeneficial() const { if (m_t_pos == 0) return 0.0; else return m_t_size_pos / m_t_pos; }
   inline double GetDoubleAverageSizeDeleterious() const { if (m_t_neg == 0) return 0.0; else return m_t_size_neg / m_t_neg; }
   
@@ -258,31 +290,51 @@
   inline double GetDoubleComplexity() const { return m_t_complexity; }
 
   inline int GetDoubleTargetTask() const { return m_t_task_target; }
-  inline double GetDoubleProbTargetTask() const { return static_cast<double>(m_t_task_target) / m_t_total; }
+  inline double GetDoubleProbTargetTask() const { return double(m_t_task_target) / m_t_total; }
+  inline double GetDoubleAverageSizeTargetTask() const
+  {
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_size_target) / m_t_task_target;
+  }
   inline int GetDoubleTargetTaskBeneficial() const { return m_t_task_target_pos; }
   inline double GetDoubleProbTargetTaskBeneficial() const
   {
-    if (m_t_task_target == 0) return 0.0; else return static_cast<double>(m_t_task_target_pos) / (2 * m_t_task_target);
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_target_pos) / (2 * m_t_task_target);
   }
+  inline double GetDoubleAverageSizeTargetTaskBeneficial() const
+  {
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_size_target_pos) / (2 * m_t_task_target);
+  }
   inline int GetDoubleTargetTaskDeleterious() const { return m_t_task_target_neg; }
   inline double GetDoubleProbTargetTaskDeleterious() const
   {
-    if (m_t_task_target == 0) return 0.0; else return static_cast<double>(m_t_task_target_neg) / (2 * m_t_task_target);
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_target_neg) / (2 * m_t_task_target);
   }
+  inline double GetDoubleAverageSizeTargetTaskDeleterious() const
+  {
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_size_target_neg) / (2 * m_t_task_target);
+  }
   inline int GetDoubleTargetTaskNeutral() const { return m_t_task_target_neut; }
   inline double GetDoubleProbTargetTaskNeutral() const
   {
-    if (m_t_task_target == 0) return 0.0; else return static_cast<double>(m_t_task_target_neut) / (2 * m_t_task_target);
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_target_neut) / (2 * m_t_task_target);
   }
   inline int GetDoubleTargetTaskLethal() const { return m_t_task_target_dead; }
   inline double GetDoubleProbTargetTaskLethal() const
   {
-    if (m_t_task_target == 0) return 0.0; else return static_cast<double>(m_t_task_target_dead) / (2 * m_t_task_target);
+    if (m_t_task_target == 0) return 0.0; else return double(m_t_task_target_dead) / (2 * m_t_task_target);
   }
   inline int GetDoubleTask() const { return m_t_task_total; }
-  inline double GetDoubleProbTask() const { return static_cast<double>(m_t_task_total) / m_t_total; }
+  inline double GetDoubleProbTask() const { return double(m_t_task_total) / m_t_total; }
+  inline double GetDoubleAverageSizeTask() const
+  {
+    if (m_t_task_total == 0) return 0.0; else return double(m_t_task_size_total) / m_t_task_total;
+  }
   inline int GetDoubleKnockout() const { return m_t_task_knockout; }
-  inline double GetDoubleProbKnockout() const { return static_cast<double>(m_t_task_knockout) / m_t_total; }
+  inline double GetDoubleProbKnockout() const { return double(m_t_task_knockout) / m_t_total; }
+  inline double GetDoubleAverageSizeKnockout() const
+  {
+    if (m_t_task_knockout == 0) return 0.0; else return double(m_t_task_size_knockout) / m_t_task_knockout;
+  }
 };
 
 




More information about the Avida-cvs mailing list