[Avida-cvs] [avida-svn] r865 - in development: Avida.xcodeproj source/actions source/analyze source/event

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Wed Aug 9 11:21:52 PDT 2006


Author: brysonda
Date: 2006-08-09 14:21:51 -0400 (Wed, 09 Aug 2006)
New Revision: 865

Removed:
   development/source/analyze/cAnalyzeUtil.cc
   development/source/analyze/cAnalyzeUtil.h
Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/actions/PopulationActions.cc
   development/source/actions/PrintActions.cc
   development/source/analyze/CMakeLists.txt
   development/source/analyze/SConscript
   development/source/event/cEventManager.cc
Log:
Convert various events depending upon cAnalyzeUtil backing code into self-contained actions.   Remove empty cAnalyzeUtil class.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-08-08 16:32:25 UTC (rev 864)
+++ development/Avida.xcodeproj/project.pbxproj	2006-08-09 18:21:51 UTC (rev 865)
@@ -42,10 +42,8 @@
 		7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
 		70422A28091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
 		70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
-		70422A32091B141000A5E67F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A26091B141000A5E67F /* cAnalyzeUtil.cc */; };
 		70422A34091B141000A5E67F /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
 		70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
-		70422A3E091B141000A5E67F /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A26091B141000A5E67F /* cAnalyzeUtil.cc */; };
 		7049F2D90A66859700640512 /* cHardwareTransSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7049F2D70A66859300640512 /* cHardwareTransSMT.cc */; };
 		7049F2DA0A66859B00640512 /* cHardwareTransSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7049F2D70A66859300640512 /* cHardwareTransSMT.cc */; };
 		7049F2DB0A66859F00640512 /* cHardwareTransSMT.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7049F2D70A66859300640512 /* cHardwareTransSMT.cc */; };
@@ -338,7 +336,6 @@
 		70DCACF2097AF7CC002F8733 /* cMxCodeArray.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70B0865808F4974300FC65FE /* cMxCodeArray.cc */; };
 		70DCACF3097AF7CC002F8733 /* cAnalyze.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A1C091B141000A5E67F /* cAnalyze.cc */; };
 		70DCACF4097AF7CC002F8733 /* cAnalyzeGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */; };
-		70DCACF5097AF7CC002F8733 /* cAnalyzeUtil.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70422A26091B141000A5E67F /* cAnalyzeUtil.cc */; };
 		70DCACF6097AF7CC002F8733 /* cFitnessMatrix.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB208DB7F8200068AC2 /* cFitnessMatrix.cc */; };
 		70DCACF7097AF7CC002F8733 /* cClassificationManager.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DAF009290468009E311D /* cClassificationManager.cc */; };
 		70DCACF8097AF7CC002F8733 /* cGenotype.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70F7DC9E09293E6F009E311D /* cGenotype.cc */; };
@@ -501,8 +498,6 @@
 		70422A23091B141000A5E67F /* cAnalyzeFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeFunction.h; sourceTree = "<group>"; };
 		70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeGenotype.cc; sourceTree = "<group>"; };
 		70422A25091B141000A5E67F /* cAnalyzeGenotype.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeGenotype.h; sourceTree = "<group>"; };
-		70422A26091B141000A5E67F /* cAnalyzeUtil.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cAnalyzeUtil.cc; sourceTree = "<group>"; };
-		70422A27091B141000A5E67F /* cAnalyzeUtil.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cAnalyzeUtil.h; sourceTree = "<group>"; };
 		70422A44091B1B8500A5E67F /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
 		7049F2D70A66859300640512 /* cHardwareTransSMT.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareTransSMT.cc; sourceTree = "<group>"; };
 		7049F2D80A66859300640512 /* cHardwareTransSMT.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareTransSMT.h; sourceTree = "<group>"; };
@@ -999,8 +994,6 @@
 				70422A23091B141000A5E67F /* cAnalyzeFunction.h */,
 				70422A24091B141000A5E67F /* cAnalyzeGenotype.cc */,
 				70422A25091B141000A5E67F /* cAnalyzeGenotype.h */,
-				70422A26091B141000A5E67F /* cAnalyzeUtil.cc */,
-				70422A27091B141000A5E67F /* cAnalyzeUtil.h */,
 				7054A16E09A8014600038658 /* cAnalyzeJobQueue.h */,
 				7054A16F09A8014600038658 /* cAnalyzeJobQueue.cc */,
 				7054A17909A802BC00038658 /* cAnalyzeJob.h */,
@@ -1901,7 +1894,6 @@
 				7040CF1E0906A52E00AA820F /* cEventManager.cc in Sources */,
 				70422A28091B141000A5E67F /* cAnalyze.cc in Sources */,
 				70422A30091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
-				70422A32091B141000A5E67F /* cAnalyzeUtil.cc in Sources */,
 				70F7DCA009293E76009E311D /* cClassificationManager.cc in Sources */,
 				70F7DCA109293E77009E311D /* cGenotype.cc in Sources */,
 				70533479092A4F4D006BD186 /* cGenotype_BirthData.cc in Sources */,
@@ -2040,7 +2032,6 @@
 				70DCACF2097AF7CC002F8733 /* cMxCodeArray.cc in Sources */,
 				70DCACF3097AF7CC002F8733 /* cAnalyze.cc in Sources */,
 				70DCACF4097AF7CC002F8733 /* cAnalyzeGenotype.cc in Sources */,
-				70DCACF5097AF7CC002F8733 /* cAnalyzeUtil.cc in Sources */,
 				70DCACF6097AF7CC002F8733 /* cFitnessMatrix.cc in Sources */,
 				70DCACF7097AF7CC002F8733 /* cClassificationManager.cc in Sources */,
 				70DCACF8097AF7CC002F8733 /* cGenotype.cc in Sources */,
@@ -2158,7 +2149,6 @@
 				7040D3A6090964D100AA820F /* cMxCodeArray.cc in Sources */,
 				70422A34091B141000A5E67F /* cAnalyze.cc in Sources */,
 				70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
-				70422A3E091B141000A5E67F /* cAnalyzeUtil.cc in Sources */,
 				70F7D8CE09254787009E311D /* cFitnessMatrix.cc in Sources */,
 				70F7DAF409290468009E311D /* cClassificationManager.cc in Sources */,
 				70F7DCA309293E87009E311D /* cGenotype.cc in Sources */,

Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/actions/PopulationActions.cc	2006-08-09 18:21:51 UTC (rev 865)
@@ -665,8 +665,130 @@
   }
 };
 
+class cActionModMutProb : public cAction
+{
+private:
+  enum { POINT, COPY, INS, DEL, DIV, DIVIDE, D_INS, D_DEL, PARENT, INJECT, I_INS, I_DEL } m_mut_type;
+  double m_prob;
+  int m_start;
+  int m_end;
+  bool m_setconf;
+  
+public:
+  cActionModMutProb(cWorld* world, const cString& args) : cAction(world, args), m_prob(0.0), m_start(-1), m_end(-1), m_setconf(false)
+  {
+      cString mutstr("COPY");
+      
+      cString largs(args);
+      if (largs.GetSize()) mutstr = largs.PopWord().ToUpper();
+      if (largs.GetSize()) m_prob = largs.PopWord().AsDouble();
+      if (largs.GetSize()) m_start = largs.PopWord().AsInt();
+      if (largs.GetSize()) m_end = largs.PopWord().AsInt();
+      
+      if (mutstr == "POINT") m_mut_type = POINT;
+      else if (mutstr == "COPY") m_mut_type = COPY;
+      else if (mutstr == "INS" || mutstr == "INSERT") m_mut_type = INS;
+      else if (mutstr == "DEL" || mutstr == "DELETE") m_mut_type = DEL;
+      else if (mutstr == "DIV") m_mut_type = DIV;
+      else if (mutstr == "DIVIDE") m_mut_type = DIVIDE;
+      else if (mutstr == "DIVIDE_INS") m_mut_type = D_INS;
+      else if (mutstr == "DIVIDE_DEL") m_mut_type = D_DEL;
+      else if (mutstr == "PARENT") m_mut_type = PARENT;
+      else if (mutstr == "INJECT") m_mut_type = INJECT;
+      else if (mutstr == "INJECT_INS") m_mut_type = I_INS;
+      else if (mutstr == "INJECT_DEL") m_mut_type = I_DEL;
+      
+      if (m_start < 0) { // start == -1  -->  all
+        m_setconf = true;
+        m_start = 0;
+        m_end = m_world->GetPopulation().GetSize();
+      }
+      if (m_end < 0)  m_end = m_start + 1; // end == -1 --> Only one cell!
+      if (m_end < m_start) { // swap order
+        int temp = m_start;
+        m_start = m_end;
+        m_end = temp;
+      }
+      if (m_end > m_world->GetPopulation().GetSize()) m_end = m_world->GetPopulation().GetSize();
+  }
+  
+  const cString GetDescription() { return "ModMutProb [string mut_type='copy'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    double prob = m_prob;
 
+    switch (m_mut_type) {
+      case POINT: prob += m_world->GetConfig().POINT_MUT_PROB.Get(); break;
+      case COPY: prob += m_world->GetConfig().COPY_MUT_PROB.Get(); break;
+      case INS: prob += m_world->GetConfig().INS_MUT_PROB.Get(); break;
+      case DEL: prob += m_world->GetConfig().DEL_MUT_PROB.Get(); break;
+      case DIV: prob += m_world->GetConfig().DIV_MUT_PROB.Get(); break;
+      case DIVIDE: prob += m_world->GetConfig().DIVIDE_MUT_PROB.Get(); break;
+      case D_INS: prob += m_world->GetConfig().DIVIDE_INS_PROB.Get(); break;
+      case D_DEL: prob += m_world->GetConfig().DIVIDE_DEL_PROB.Get(); break;
+      case PARENT: prob += m_world->GetConfig().PARENT_MUT_PROB.Get(); break;
+      case INJECT: prob += m_world->GetConfig().INJECT_MUT_PROB.Get(); break;
+      case I_INS: prob += m_world->GetConfig().INJECT_INS_PROB.Get(); break;
+      case I_DEL: prob += m_world->GetConfig().INJECT_DEL_PROB.Get(); break;
+      default:
+        return;
+    }
+    
+    if (m_setconf) {
+      switch (m_mut_type) {
+        case POINT: m_world->GetConfig().POINT_MUT_PROB.Set(prob); break;
+        case COPY: m_world->GetConfig().COPY_MUT_PROB.Set(prob); break;
+        case INS: m_world->GetConfig().INS_MUT_PROB.Set(prob); break;
+        case DEL: m_world->GetConfig().DEL_MUT_PROB.Set(prob); break;
+        case DIV: m_world->GetConfig().DIV_MUT_PROB.Set(prob); break;
+        case DIVIDE: m_world->GetConfig().DIVIDE_MUT_PROB.Set(prob); break;
+        case D_INS: m_world->GetConfig().DIVIDE_INS_PROB.Set(prob); break;
+        case D_DEL: m_world->GetConfig().DIVIDE_DEL_PROB.Set(prob); break;
+        case PARENT: m_world->GetConfig().PARENT_MUT_PROB.Set(prob); break;
+        case INJECT: m_world->GetConfig().INJECT_MUT_PROB.Set(prob); break;
+        case I_INS: m_world->GetConfig().INJECT_INS_PROB.Set(prob); break;
+        case I_DEL: m_world->GetConfig().INJECT_DEL_PROB.Set(prob); break;
+        default:
+          return;
+      }
+    }
+    
+    switch (m_mut_type) {
+      case POINT: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetPointMutProb(prob); break;
+      case COPY: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetCopyMutProb(prob); break;
+      case INS: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetInsMutProb(prob); break;
+      case DEL: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetDelMutProb(prob); break;
+      case DIV: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetDivMutProb(prob); break;
+      case DIVIDE: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetDivideMutProb(prob); break;
+      case D_INS: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetDivideInsProb(prob); break;
+      case D_DEL: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetDivideDelProb(prob); break;
+      case PARENT: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetParentMutProb(prob); break;
+      case INJECT: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetInjectMutProb(prob); break;
+      case I_INS: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetInjectInsProb(prob); break;
+      case I_DEL: for (int i = m_start; i < m_end; i++) m_world->GetPopulation().GetCell(i).MutationRates().SetInjectDelProb(prob); break;
+      default:
+        return;
+    }
+  }
+};
 
+
+class cActionZeroMuts : public cAction
+{
+public:
+  cActionZeroMuts(cWorld* world, const cString& args) : cAction(world, args) { ; }
+  const cString GetDescription() { return "ZeroMuts"; }
+  void Process(cAvidaContext& ctx)
+  {
+    for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
+      m_world->GetPopulation().GetCell(i).MutationRates().Clear();
+    }
+  }
+};
+
+
+
 void RegisterPopulationActions(cActionLibrary* action_lib)
 {
   action_lib->Register<cActionInject>("Inject");
@@ -684,6 +806,8 @@
   action_lib->Register<cActionSerialTransfer>("SerialTransfer");
 
   action_lib->Register<cActionSetMutProb>("SetMutProb");
+  action_lib->Register<cActionModMutProb>("ModMutProb");
+  action_lib->Register<cActionZeroMuts>("ZeroMuts");
 
 
   // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
@@ -697,4 +821,6 @@
   action_lib->Register<cActionKillRate>("rate_kill");
   action_lib->Register<cActionKillRectangle>("kill_rectangle");
   action_lib->Register<cActionSerialTransfer>("serial_transfer");
+
+  action_lib->Register<cActionZeroMuts>("zero_muts");
 }

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/actions/PrintActions.cc	2006-08-09 18:21:51 UTC (rev 865)
@@ -18,6 +18,7 @@
 #include "cGenotype.h"
 #include "cHardwareBase.h"
 #include "cHardwareManager.h"
+#include "cHistogram.h"
 #include "cInjectGenotype.h"
 #include "cInstSet.h"
 #include "cInstUtil.h"
@@ -827,6 +828,372 @@
 };
 
 
+class cActionTestDominant : public cAction
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionTestDominant(cWorld* world, const cString& args) : cAction(world, args), m_filename("dom-test.dat")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();  
+  }
+  const cString GetDescription() { return "TestDominant [string fname='dom-test.dat']"; }
+  void Process(cAvidaContext& ctx)
+  {
+    cGenome& genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
+
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    cCPUTestInfo test_info;
+    testcpu->TestGenome(ctx, test_info, genome);
+    delete testcpu;
+    
+    cPhenotype& colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
+
+    cDataFile& df = m_world->GetDataFile(m_filename);
+    df.Write(m_world->GetStats().GetUpdate(), "Update");
+    df.Write(colony_phenotype.GetMerit().GetDouble(), "Merit");
+    df.Write(colony_phenotype.GetGestationTime(), "Gestation Time");
+    df.Write(colony_phenotype.GetFitness(), "Fitness");
+    df.Write(1.0 / (0.1 + colony_phenotype.GetGestationTime()), "Reproduction Rate");
+    df.Write(genome.GetSize(), "Genome Length");
+    df.Write(colony_phenotype.GetCopiedSize(), "Copied Size");
+    df.Write(colony_phenotype.GetExecutedSize(), "Executed Size");
+    df.Endl();
+  }
+};
+
+
+class cActionPrintTaskSnapshot : public cAction
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionPrintTaskSnapshot(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();  
+  }
+  const cString GetDescription() { return "PrintTaskSnapshot [string fname='']"; }
+  void Process(cAvidaContext& ctx)
+  {
+    cString filename(m_filename);
+    if (filename == "") filename.Set("tasks_%d.dat", m_world->GetStats().GetUpdate());
+    cDataFile& df = m_world->GetDataFile(filename);
+    
+    cPopulation& pop = m_world->GetPopulation();
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    
+    for (int i = 0; i < pop.GetSize(); i++) {
+      if (pop.GetCell(i).IsOccupied() == false) continue;
+      cOrganism* organism = pop.GetCell(i).GetOrganism();
+      
+      // create a test-cpu for the current creature
+      cCPUTestInfo test_info;
+      testcpu->TestGenome(ctx, test_info, organism->GetGenome());
+      cPhenotype& test_phenotype = test_info.GetTestPhenotype();
+      cPhenotype& phenotype = organism->GetPhenotype();
+      
+      int num_tasks = m_world->GetNumTasks();
+      int sum_tasks_all = 0;
+      int sum_tasks_rewarded = 0;
+      int divide_sum_tasks_all = 0;
+      int divide_sum_tasks_rewarded = 0;
+      int parent_sum_tasks_all = 0;
+      int parent_sum_tasks_rewarded = 0;
+      
+      for (int j = 0; j < num_tasks; j++) {
+        // get the number of bonuses for this task
+        int bonuses = 1; //phenotype.GetTaskLib().GetTaskNumBonus(j);
+        int task_count = ( phenotype.GetCurTaskCount()[j] == 0 ) ? 0 : 1;
+        int divide_tasks_count = (test_phenotype.GetLastTaskCount()[j] == 0)?0:1;
+        int parent_task_count = (phenotype.GetLastTaskCount()[j] == 0) ? 0 : 1;
+        
+        // If only one bonus, this task is not rewarded, as last bonus is + 0.
+        if (bonuses > 1) {
+          sum_tasks_rewarded += task_count;
+          divide_sum_tasks_rewarded += divide_tasks_count;
+          parent_sum_tasks_rewarded += parent_task_count;
+        }
+        sum_tasks_all += task_count;
+        divide_sum_tasks_all += divide_tasks_count;
+        parent_sum_tasks_all += parent_task_count;
+      }
+      
+      df.Write(i, "Cell Number");
+      df.Write(sum_tasks_rewarded, "Number of Tasks Rewarded");
+      df.Write(sum_tasks_all, "Total Number of Tasks Done");
+      df.Write(divide_sum_tasks_rewarded, "Number of Rewarded Tasks on Divide");
+      df.Write(divide_sum_tasks_all, "Number of Total Tasks on Divide");
+      df.Write(parent_sum_tasks_rewarded, "Parent Number of Tasks Rewared");
+      df.Write(parent_sum_tasks_all, "Parent Total Number of Tasks Done");
+      df.Write(test_info.GetColonyFitness(), "Genotype Fitness");
+      df.Write(organism->GetGenotype()->GetName(), "Genotype Name");
+      df.Endl();
+    }
+    
+    m_world->GetDataFileManager().Remove(filename);
+    delete testcpu;
+  }
+};
+
+
+class cActionPrintViableTasksData : public cAction
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionPrintViableTasksData(cWorld* world, const cString& args) : cAction(world, args), m_filename("viable_tasks.dat")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();  
+  }
+  const cString GetDescription() { return "PrintViableTasksData [string fname='viable_tasks.dat']"; }
+  void Process(cAvidaContext& ctx)
+  {
+    cDataFile& df = m_world->GetDataFile(m_filename);
+    cPopulation& pop = m_world->GetPopulation();
+    const int num_tasks = m_world->GetNumTasks();
+    
+    tArray<int> tasks(num_tasks);
+    tasks.SetAll(0);
+    
+    for (int i = 0; i < pop.GetSize(); i++) {
+      if (!pop.GetCell(i).IsOccupied()) continue;
+      if (pop.GetCell(i).GetOrganism()->GetGenotype()->GetTestFitness(ctx) > 0.0) {
+        cPhenotype& phenotype = pop.GetCell(i).GetOrganism()->GetPhenotype();
+        for (int j = 0; j < num_tasks; j++) if (phenotype.GetCurTaskCount()[j] > 0) tasks[j]++;
+      }
+    }
+
+    df.WriteComment("Avida viable tasks data");
+    df.WriteTimeStamp();
+    df.WriteComment("First column gives the current update, next columns give the number");
+    df.WriteComment("of organisms that have the particular task as a component of their merit");
+    
+    df.Write(m_world->GetStats().GetUpdate(), "Update");
+    for(int i = 0; i < tasks.GetSize(); i++) {
+      df.Write(tasks[i], "");
+    }
+    df.Endl();
+  }
+};
+
+
+class cActionPrintTreeDepths : public cAction
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionPrintTreeDepths(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();  
+  }
+  const cString GetDescription() { return "PrintTreeDepths [string fname='']"; }
+  void Process(cAvidaContext& ctx)
+  {
+    cString filename(m_filename);
+    if (filename == "") filename.Set("tree_depth.%d.dat", m_world->GetStats().GetUpdate());
+    cDataFile& df = m_world->GetDataFile(filename);
+    
+    cPopulation& pop = m_world->GetPopulation();
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    
+    cGenotype* genotype = m_world->GetClassificationManager().GetBestGenotype();
+    for (int i = 0; i < m_world->GetClassificationManager().GetGenotypeCount(); i++) {
+      df.Write(genotype->GetID(), "Genotype ID");
+      df.Write(genotype->GetTestFitness(ctx), "Fitness");
+      df.Write(genotype->GetNumOrganisms(), "Abundance");
+      df.Write(genotype->GetDepth(), "Tree Depth");
+      df.Endl();
+      
+      // ...and advance to the next genotype...
+      genotype = genotype->GetNext();
+    }
+    
+    m_world->GetDataFileManager().Remove(filename);
+    delete testcpu;
+  }
+};
+
+
+class cActionCalcConsensus : public cAction
+{
+private:
+  int m_lines_saved;
+  
+public:
+  cActionCalcConsensus(cWorld* world, const cString& args) : cAction(world, args), m_lines_saved(0)
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_lines_saved = largs.PopWord().AsInt();  
+  }
+  const cString GetDescription() { return "CalcConsensus [int lines_saved=0]"; }
+  void Process(cAvidaContext& ctx)
+  {
+    const int num_inst = m_world->GetHardwareManager().GetInstSet().GetSize();
+    const int update = m_world->GetStats().GetUpdate();
+    cClassificationManager& classmgr = m_world->GetClassificationManager();
+    
+    // Setup the histogtams...
+    tArray<cHistogram> inst_hist(MAX_CREATURE_SIZE);
+    for (int i = 0; i < MAX_CREATURE_SIZE; i++) inst_hist[i].Resize(num_inst,-1);
+    
+    // Loop through all of the genotypes adding them to the histograms.
+    cGenotype* cur_genotype = classmgr.GetBestGenotype();
+    for (int i = 0; i < classmgr.GetGenotypeCount(); i++) {
+      const int num_organisms = cur_genotype->GetNumOrganisms();
+      const int length = cur_genotype->GetLength();
+      const cGenome& genome = cur_genotype->GetGenome();
+      
+      // Place this genotype into the histograms.
+      for (int j = 0; j < length; j++) {
+        assert(genome[j].GetOp() < num_inst);
+        inst_hist[j].Insert(genome[j].GetOp(), num_organisms);
+      }
+      
+      // Mark all instructions beyond the length as -1 in histogram...
+      for (int j = length; j < MAX_CREATURE_SIZE; j++) {
+        inst_hist[j].Insert(-1, num_organisms);
+      }
+      
+      // ...and advance to the next genotype...
+      cur_genotype = cur_genotype->GetNext();
+    }
+    
+    // Now, lets print something!
+    cDataFile& df = m_world->GetDataFile("consensus.dat");
+    cDataFile& df_abundance = m_world->GetDataFile("consensus-abundance.dat");
+    cDataFile& df_var = m_world->GetDataFile("consensus-var.dat");
+    cDataFile& df_entropy = m_world->GetDataFile("consensus-entropy.dat");
+    
+    // Determine the length of the concensus genome
+    int con_length;
+    for (con_length = 0; con_length < MAX_CREATURE_SIZE; con_length++) {
+      if (inst_hist[con_length].GetMode() == -1) break;
+    }
+    
+    // Build the concensus genotype...
+    cGenome con_genome(con_length);
+    double total_entropy = 0.0;
+    for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
+      const int mode = inst_hist[i].GetMode();
+      const int count = inst_hist[i].GetCount(mode);
+      const int total = inst_hist[i].GetCount();
+      const double entropy = inst_hist[i].GetNormEntropy();
+      if (i < con_length) total_entropy += entropy;
+      
+      // Break out if ALL creatures have a -1 in this area, and we've
+      // finished printing all of the files.
+      if (mode == -1 && count == total) break;
+      
+      if ( i < con_length )
+        con_genome[i].SetOp(mode);
+      
+      // Print all needed files.
+      if (i < m_lines_saved) {
+        df_abundance.Write(count, "");
+        df_var.Write(inst_hist[i].GetCountVariance(), "");
+        df_entropy.Write(entropy, "");
+      }
+    }
+    
+    // Put end-of-lines on the files.
+    if (m_lines_saved > 0) {
+      df_abundance.Endl();
+      df_var.Endl();
+      df_entropy.Endl();
+    }
+    
+    // --- Study the consensus genome ---
+    
+    // Loop through genotypes again, and determine the average genetic distance.
+    cur_genotype = classmgr.GetBestGenotype();
+    cDoubleSum distance_sum;
+    for (int i = 0; i < classmgr.GetGenotypeCount(); i++) {
+      const int num_organisms = cur_genotype->GetNumOrganisms();
+      const int cur_dist = cGenomeUtil::FindEditDistance(con_genome, cur_genotype->GetGenome());
+      distance_sum.Add(cur_dist, num_organisms);
+      
+      // ...and advance to the next genotype...
+      cur_genotype = cur_genotype->GetNext();
+    }
+    
+    // Finally, gather last bits of data and print the results.
+    cGenotype* con_genotype = classmgr.FindGenotype(con_genome, -1);
+    const int best_dist = cGenomeUtil::FindEditDistance(con_genome, classmgr.GetBestGenotype()->GetGenome());
+    
+    const double ave_dist = distance_sum.Average();
+    const double var_dist = distance_sum.Variance();
+    const double complexity_base = static_cast<double>(con_genome.GetSize()) - total_entropy;
+    
+    cString con_name;
+    con_name.Set("archive/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
+    cTestUtil::PrintGenome(m_world, con_genome, con_name);
+    
+    
+    if (con_genotype) {
+      df.Write(update, "Update");
+      df.Write(con_genotype->GetMerit(), "Merit");
+      df.Write(con_genotype->GetGestationTime(), "Gestation Time");
+      df.Write(con_genotype->GetFitness(), "Fitness");
+      df.Write(con_genotype->GetReproRate(), "Reproduction Rate");
+      df.Write(con_genotype->GetLength(), "Length");
+      df.Write(con_genotype->GetCopiedSize(), "Copied Size");
+      df.Write(con_genotype->GetExecutedSize(), "Executed Size");
+      df.Write(con_genotype->GetBirths(), "Get Births");
+      df.Write(con_genotype->GetBreedTrue(), "Breed True");
+      df.Write(con_genotype->GetBreedIn(), "Breed In");
+      df.Write(con_genotype->GetNumOrganisms(), "Abundance");
+      df.Write(con_genotype->GetDepth(), "Tree Depth");
+      df.Write(con_genotype->GetID(), "Genotype ID");
+      df.Write(update - con_genotype->GetUpdateBorn(), "Age (in updates)");
+      df.Write(best_dist, "Best Distance");
+      df.Write(ave_dist, "Average Distance");
+      df.Write(var_dist, "Var Distance");
+      df.Write(total_entropy, "Total Entropy");
+      df.Write(complexity_base, "Complexity");
+      df.Endl();
+    } else {
+      cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+      
+      cCPUTestInfo test_info;
+      testcpu->TestGenome(ctx, test_info, con_genome);
+      delete testcpu;
+      
+      cPhenotype& colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
+      
+      df.Write(update, "Update");
+      df.Write(colony_phenotype.GetMerit().GetDouble(), "Merit");
+      df.Write(colony_phenotype.GetGestationTime(), "Gestation Time");
+      df.Write(colony_phenotype.GetFitness(), "Fitness");
+      df.Write(1.0 / (0.1  + colony_phenotype.GetGestationTime()), "Reproduction Rate");
+      df.Write(con_genome.GetSize(), "Length");
+      df.Write(colony_phenotype.GetCopiedSize(), "Copied Size");
+      df.Write(colony_phenotype.GetExecutedSize(), "Executed Size");
+      df.Write(0, "Get Births");
+      df.Write(0, "Breed True");
+      df.Write(0, "Breed In");
+      df.Write(0, "Abundance");
+      df.Write(-1, "Tree Depth");
+      df.Write(-1, "Genotype ID");
+      df.Write(0, "Age (in updates)");
+      df.Write(best_dist, "Best Distance");
+      df.Write(ave_dist, "Average Distance");
+      df.Write(var_dist, "Var Distance");
+      df.Write(total_entropy, "Total Entropy");
+      df.Write(complexity_base, "Complexity");
+      df.Endl();
+    }
+  }
+};
+
+
 void RegisterPrintActions(cActionLibrary* action_lib)
 {
   // Stats Out Files
@@ -872,6 +1239,11 @@
   action_lib->Register<cActionPrintGenotypes>("PrintGenotypes");
   action_lib->Register<cActionDumpMemory>("DumpMemory");
 
+  action_lib->Register<cActionTestDominant>("TestDominant");
+  action_lib->Register<cActionPrintTaskSnapshot>("PrintTaskSnapshot");
+  action_lib->Register<cActionPrintViableTasksData>("PrintViableTasksData");
+  action_lib->Register<cActionPrintTreeDepths>("PrintTreeDepths");
+  
 
   // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
   action_lib->Register<cActionPrintAverageData>("print_average_data");
@@ -912,4 +1284,9 @@
   
   action_lib->Register<cActionPrintGenotypes>("print_genotypes");
   action_lib->Register<cActionDumpMemory>("dump_memory");
+
+  action_lib->Register<cActionTestDominant>("test_dom");
+  action_lib->Register<cActionPrintTaskSnapshot>("task_snapshot");
+  action_lib->Register<cActionPrintViableTasksData>("print_viable_tasks_data");
+  action_lib->Register<cActionPrintTreeDepths>("print_tree_depths");
 }

Modified: development/source/analyze/CMakeLists.txt
===================================================================
--- development/source/analyze/CMakeLists.txt	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/analyze/CMakeLists.txt	2006-08-09 18:21:51 UTC (rev 865)
@@ -3,7 +3,6 @@
 SET(libanalyze_a_SOURCES
   cAnalyze.cc
   cAnalyzeGenotype.cc
-  cAnalyzeUtil.cc
   cAnalyzeJobQueue.cc
   cAnalyzeJobWorker.cc
   cMutationalNeighborhood.cc

Modified: development/source/analyze/SConscript
===================================================================
--- development/source/analyze/SConscript	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/analyze/SConscript	2006-08-09 18:21:51 UTC (rev 865)
@@ -6,7 +6,6 @@
 srcs = [
   'cAnalyze.cc',
   'cAnalyzeGenotype.cc',
-  'cAnalyzeUtil.cc',
   'cAnalyzeJobQueue.cc',
   'cAnalyzeJobWorker.cc',
   'cMutationalNeighborhood.cc'
@@ -25,7 +24,6 @@
   'cAnalyzeJob.h',
   'cAnalyzeJobQueue.h',
   'cAnalyzeJobWorker.h',
-  'cAnalyzeUtil.h',
   'cGenotypeBatch.h',
   'cMutationalNeighborhood.h',
   'cMutationalNeighborhoodResults.h',

Deleted: development/source/analyze/cAnalyzeUtil.cc
===================================================================
--- development/source/analyze/cAnalyzeUtil.cc	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/analyze/cAnalyzeUtil.cc	2006-08-09 18:21:51 UTC (rev 865)
@@ -1,426 +0,0 @@
-/*
- *  cAnalyzeUtil.cc
- *  Avida
- *
- *  Created by David on 12/2/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1993-2003 California Institute of Technology.
- *
- */
-
-#include "cAnalyzeUtil.h"
-
-#include "cAvidaContext.h"
-#include "defs.h"
-#include "cEnvironment.h"
-#include "cClassificationManager.h"
-#include "cGenome.h"
-#include "cGenomeUtil.h"
-#include "cGenotype.h"
-#include "cHardwareBase.h"
-#include "cHardwareManager.h"
-#include "cHistogram.h"
-#include "cInstSet.h"
-#include "cInstUtil.h"
-#include "cLandscape.h"
-#include "cOrganism.h"
-#include "cPhenotype.h"
-#include "cPopulation.h"
-#include "cPopulationCell.h"
-#include "cSpecies.h"
-#include "cStats.h"
-#include "cTestCPU.h"
-#include "cTestUtil.h"
-#include "cTools.h"
-#include "cWorld.h"
-
-#include <vector>
-
-using namespace std;
-
-
-void cAnalyzeUtil::TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-                              ofstream& fp, int update)
-{
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-  
-  cCPUTestInfo test_info;
-  testcpu->TestGenome(ctx, test_info, genome);
-  delete testcpu;
-  
-  cPhenotype &colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
-  fp << update << " "                                //  1
-    << colony_phenotype.GetMerit().GetDouble() << " "            //  2
-    << colony_phenotype.GetGestationTime() << " "             //  3
-    << colony_phenotype.GetFitness() << " "                      //  4
-    << 1.0 / (0.1  + colony_phenotype.GetGestationTime()) << " " //  5
-    << genome.GetSize() << " "                                   //  6
-    << colony_phenotype.GetCopiedSize() << " "                   //  7
-    << colony_phenotype.GetExecutedSize() << endl;               //  8
-}
-
-
-
-void cAnalyzeUtil::TestInsSizeChangeRobustness(cWorld* world, ofstream& fp,
-                                               const cInstSet & inst_set, const cGenome & in_genome,
-                                               int num_trials, int update)
-{
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  cCPUTestInfo test_info;
-  const cInstruction inst_none = inst_set.GetInst("instruction_none");
-  
-  // Stats
-  int num_viable = 0;
-  int num_new_size = 0;
-  int num_parent_size = 0;
-  
-  for (int i = 0; i < num_trials; i++) {
-    cCPUMemory genome(in_genome);
-    // Should check to only insert infront of an instruction (not a Nop)
-    int ins_pos = -1;
-    while (ins_pos < 0) {
-      ins_pos = world->GetRandom().GetUInt(genome.GetSize());
-      if( inst_set.IsNop(genome[ins_pos]) )  ins_pos = -1;
-    }
-    
-    // Insert some "instruction_none" into the genome
-    const int num_nops = world->GetRandom().GetUInt(5) + 5;
-    for (int j = 0; j < num_nops; j++)  genome.Insert(ins_pos, inst_none);
-    
-    // Test the genome and output stats
-    if (testcpu->TestGenome(ctx, test_info, genome)){ // Daughter viable...
-      num_viable++;
-      const double child_size =
-        test_info.GetColonyOrganism()->GetGenome().GetSize();
-      
-      if (child_size == (double) in_genome.GetSize()) num_parent_size++;
-      else if (child_size == (double) genome.GetSize()) num_new_size++;
-    }
-  } // for num_trials
-  
-  delete testcpu;
-  
-  fp << update << " "
-    << (double) num_viable / num_trials << " "
-    << (double) num_new_size / num_trials << " "
-    << (double) num_parent_size / num_trials << " "
-    << endl;
-}
-
-
-void cAnalyzeUtil::CalcConsensus(cWorld* world, int lines_saved)
-{
-  const int num_inst = world->GetHardwareManager().GetInstSet().GetSize();
-  const int update = world->GetStats().GetUpdate();
-  cClassificationManager& classmgr = world->GetClassificationManager();
-  
-  // Setup the histogtams...
-  cHistogram * inst_hist = new cHistogram[MAX_CREATURE_SIZE];
-  for (int i = 0; i < MAX_CREATURE_SIZE; i++) inst_hist[i].Resize(num_inst,-1);
-  
-  // Loop through all of the genotypes adding them to the histograms.
-  cGenotype * cur_genotype = classmgr.GetBestGenotype();
-  for (int i = 0; i < classmgr.GetGenotypeCount(); i++) {
-    const int num_organisms = cur_genotype->GetNumOrganisms();
-    const int length = cur_genotype->GetLength();
-    const cGenome & genome = cur_genotype->GetGenome();
-    
-    // Place this genotype into the histograms.
-    for (int j = 0; j < length; j++) {
-      assert(genome[j].GetOp() < num_inst);
-      inst_hist[j].Insert(genome[j].GetOp(), num_organisms);
-    }
-    
-    // Mark all instructions beyond the length as -1 in histogram...
-    for (int j = length; j < MAX_CREATURE_SIZE; j++) {
-      inst_hist[j].Insert(-1, num_organisms);
-    }
-    
-    // ...and advance to the next genotype...
-    cur_genotype = cur_genotype->GetNext();
-  }
-  
-  // Now, lets print something!
-  ofstream& fp = world->GetDataFileOFStream("consensus.dat");
-  ofstream& fp_abundance = world->GetDataFileOFStream("con-abundance.dat");
-  ofstream& fp_var = world->GetDataFileOFStream("con-var.dat");
-  ofstream& fp_entropy = world->GetDataFileOFStream("con-entropy.dat");
-  
-  // Determine the length of the concensus genome
-  int con_length;
-  for (con_length = 0; con_length < MAX_CREATURE_SIZE; con_length++) {
-    if (inst_hist[con_length].GetMode() == -1) break;
-  }
-  
-  // Build the concensus genotype...
-  cGenome con_genome(con_length);
-  double total_entropy = 0.0;
-  for (int i = 0; i < MAX_CREATURE_SIZE; i++) {
-    const int mode = inst_hist[i].GetMode();
-    const int count = inst_hist[i].GetCount(mode);
-    const int total = inst_hist[i].GetCount();
-    const double entropy = inst_hist[i].GetNormEntropy();
-    if (i < con_length) total_entropy += entropy;
-    
-    // Break out if ALL creatures have a -1 in this area, and we've
-    // finished printing all of the files.
-    if (mode == -1 && count == total) break;
-    
-    if ( i < con_length )
-      con_genome[i].SetOp(mode);
-    
-    // Print all needed files.
-    if (i < lines_saved) {
-      fp_abundance << count << " ";
-      fp_var << inst_hist[i].GetCountVariance() << " ";
-      fp_entropy << entropy << " ";
-    }
-  }
-  
-  // Put end-of-lines on the files.
-  if (lines_saved > 0) {
-    fp_abundance << endl;
-    fp_var       << endl;
-    fp_entropy   << endl;
-  }
-  
-  // --- Study the consensus genome ---
-  
-  // Loop through genotypes again, and determine the average genetic distance.
-  cur_genotype = classmgr.GetBestGenotype();
-  cDoubleSum distance_sum;
-  for (int i = 0; i < classmgr.GetGenotypeCount(); i++) {
-    const int num_organisms = cur_genotype->GetNumOrganisms();
-    const int cur_dist =
-      cGenomeUtil::FindEditDistance(con_genome, cur_genotype->GetGenome());
-    distance_sum.Add(cur_dist, num_organisms);
-    
-    // ...and advance to the next genotype...
-    cur_genotype = cur_genotype->GetNext();
-  }
-  
-  // Finally, gather last bits of data and print the results.
-  cGenotype * con_genotype = classmgr.FindGenotype(con_genome, -1);
-  const int best_dist = cGenomeUtil::FindEditDistance(con_genome,
-                                                      classmgr.GetBestGenotype()->GetGenome());
-  
-  const double ave_dist = distance_sum.Average();
-  const double var_dist = distance_sum.Variance();
-  const double complexity_base = (double) con_genome.GetSize() - total_entropy;
-  
-  cString con_name;
-  con_name.Set("classmgr/%03d-consensus-u%i.gen", con_genome.GetSize(),update);
-  cTestUtil::PrintGenome(world, con_genome, con_name);
-  
-  
-  if (con_genotype) {
-    fp << update                                 << " " //  1
-    << con_genotype->GetMerit()               << " " //  2
-    << con_genotype->GetGestationTime()       << " " //  3
-    << con_genotype->GetFitness()             << " " //  4
-    << con_genotype->GetReproRate()           << " " //  5
-    << con_genotype->GetLength()              << " " //  6
-    << con_genotype->GetCopiedSize()          << " " //  7
-    << con_genotype->GetExecutedSize()        << " " //  8
-    << con_genotype->GetBirths()              << " " //  9
-    << con_genotype->GetBreedTrue()           << " " // 10
-    << con_genotype->GetBreedIn()             << " " // 11
-    << con_genotype->GetNumOrganisms()        << " " // 12
-    << con_genotype->GetDepth()               << " " // 13
-    << con_genotype->GetID()                  << " " // 14
-    << update - con_genotype->GetUpdateBorn() << " " // 15
-    << best_dist                              << " " // 16
-    << ave_dist                               << " " // 17
-    << var_dist                               << " " // 18
-    << total_entropy                          << " " // 19
-    << complexity_base                        << " " // 20
-    << endl;
-  }
-  else {
-    cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-    cAvidaContext& ctx = world->GetDefaultContext();
-    
-    cCPUTestInfo test_info;
-    testcpu->TestGenome(ctx, test_info, con_genome);
-    delete testcpu;
-    
-    cPhenotype& colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
-
-    fp << update                                             << " "   //  1
-      << colony_phenotype.GetMerit()                        << " "  //  2
-      << colony_phenotype.GetGestationTime()                << " "  //  3
-      << colony_phenotype.GetFitness()                      << " "  //  4
-      << 1.0 / (0.1  + colony_phenotype.GetGestationTime()) << " "  //  5
-      << con_genome.GetSize()                               << " "  //  6
-      << colony_phenotype.GetCopiedSize()                   << " "  //  7
-      << colony_phenotype.GetExecutedSize()                 << " "  //  8
-      << 0                                  << " "  // Births       //  9
-      << 0                                  << " "  // Breed True   // 10
-      << 0                                  << " "  // Breed In     // 11
-      << 0                                  << " "  // Num CPUs     // 12
-      << -1                                 << " "  // Depth        // 13
-      << -1                                 << " "  // ID           // 14
-      << 0                                  << " "  // Age          // 15
-      << best_dist                                          << " "  // 16
-      << ave_dist                                           << " "  // 17
-      << var_dist                                           << " "  // 18
-      << total_entropy                                      << " "  // 19
-      << complexity_base                                    << " "  // 20
-      << endl;
-  }
-  
-  // Flush the file...
-  fp.flush();
-  
-  delete [] inst_hist;
-}
-
-
-/**
-* This function goes through all creatures in the soup, and writes out
- * how many tasks the different creatures have done up to now. It counts
- * every task only once, i.e., if a creature does 'put' three times, that
- * will increase its count only by one.
- *
- * @param fp The file into which the result should be written.
- **/
-
-void cAnalyzeUtil::TaskSnapshot(cWorld* world, ofstream& fp)
-{
-  cPopulation* pop = &world->GetPopulation();
-  fp << "# (1) cell number\n# (2) number of rewarded tasks done so far\n# (3) total number of tasks done so far\n# (4) same as 2, but right before divide\n# (5) same as 3, but right before divide\n# (6) same as 2, but for parent\n# (7) same as 3, but for parent\n# (8) genotype fitness\n# (9) genotype name" << endl;
-  
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;
-    cOrganism * organism = pop->GetCell(i).GetOrganism();
-    
-    // create a test-cpu for the current creature
-    cCPUTestInfo test_info;
-    testcpu->TestGenome(ctx, test_info, organism->GetGenome());
-    cPhenotype & test_phenotype = test_info.GetTestPhenotype();
-    cPhenotype & phenotype = organism->GetPhenotype();
-    
-    int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();
-    int sum_tasks_all = 0;
-    int sum_tasks_rewarded = 0;
-    int divide_sum_tasks_all = 0;
-    int divide_sum_tasks_rewarded = 0;
-    int parent_sum_tasks_all = 0;
-    int parent_sum_tasks_rewarded = 0;
-    
-    for (int j = 0; j < num_tasks; j++) {
-      // get the number of bonuses for this task
-      int bonuses = 1; //phenotype.GetTaskLib().GetTaskNumBonus(j);
-      int task_count = ( phenotype.GetCurTaskCount()[j] == 0 ) ? 0 : 1;
-      int divide_tasks_count = (test_phenotype.GetLastTaskCount()[j] == 0)?0:1;
-      int parent_task_count = (phenotype.GetLastTaskCount()[j] == 0) ? 0 : 1;
-      
-      // If only one bonus, this task is not rewarded, as last bonus is + 0.
-      if (bonuses > 1) {
-        sum_tasks_rewarded += task_count;
-        divide_sum_tasks_rewarded += divide_tasks_count;
-        parent_sum_tasks_rewarded += parent_task_count;
-      }
-      sum_tasks_all += task_count;
-      divide_sum_tasks_all += divide_tasks_count;
-      parent_sum_tasks_all += parent_task_count;
-    }
-    
-    fp << i                          << " " // 1 cell number
-      << sum_tasks_rewarded         << " " // 2 number of tasks rewarded
-      << sum_tasks_all              << " " // 3 total number of tasks done
-      << divide_sum_tasks_rewarded  << " " // 4 num rewarded tasks on divide
-      << divide_sum_tasks_all       << " " // 5 num total tasks on divide
-      << parent_sum_tasks_rewarded  << " " // 6 parent number of tasks rewared
-      << parent_sum_tasks_all       << " " // 7 parent total num tasks done
-      << test_info.GetColonyFitness()         << " " // 8 genotype fitness
-      << organism->GetGenotype()->GetName() << " " // 9 genotype name
-      << endl;
-  }
-  
-  delete testcpu;
-}
-
-void cAnalyzeUtil::TaskGrid(cWorld* world, ofstream& fp)
-{ 
-  cPopulation* pop = &world->GetPopulation();
-  cTestCPU* testcpu = world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  for (int i = 0; i < pop->GetWorldX(); i++) {
-    for (int j = 0; j < pop->GetWorldY(); j++) {
-      int task_sum = 0;
-      int cell_num = i*pop->GetWorldX()+j;
-      if (pop->GetCell(cell_num).IsOccupied() == true) {
-        cOrganism * organism = pop->GetCell(cell_num).GetOrganism();
-        cCPUTestInfo test_info;
-        testcpu->TestGenome(ctx, test_info, organism->GetGenome());
-        cPhenotype& test_phenotype = test_info.GetTestPhenotype();
-        int num_tasks = world->GetEnvironment().GetTaskLib().GetSize();   
-        for (int k = 0; k < num_tasks; k++) {
-          if (test_phenotype.GetLastTaskCount()[k]>0) {
-            task_sum = task_sum + (int) pow(2.0,k); 
-          } 
-        }
-      }
-      fp << task_sum << " ";
-    }
-    fp << endl;
-  }
-  
-  delete testcpu;
-}
-
-/**
-* This function prints all the tasks that viable creatures have performed
- * so far (compare with the event 'print_task_data', which prints all tasks.
-           **/
-
-void cAnalyzeUtil::PrintViableTasksData(cWorld* world, ofstream& fp)
-{
-  const int num_tasks = world->GetNumTasks();
-  cPopulation* pop = &world->GetPopulation();
-  
-  vector<int> tasks(num_tasks);
-  vector<int>::iterator it;
-  
-  // clear task vector
-  for (it = tasks.begin(); it != tasks.end(); it++)  (*it) = 0;
-  
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;
-    if (pop->GetCell(i).GetOrganism()->GetGenotype()->GetTestFitness(world->GetDefaultContext()) > 0.0) {
-      cPhenotype & phenotype = pop->GetCell(i).GetOrganism()->GetPhenotype();
-      for (int j = 0; j < num_tasks; j++) {
-        if (phenotype.GetCurTaskCount()[j] > 0)  tasks[j] += 1;
-      }
-    }
-  }
-  
-  fp << world->GetStats().GetUpdate();
-  for (it = tasks.begin(); it != tasks.end(); it++)  fp << " " << (*it);
-  fp<<endl;
-}
-
-
-void cAnalyzeUtil::PrintTreeDepths(cWorld* world, ofstream& fp)
-{
-  // cycle over all genotypes
-  cGenotype* genotype = world->GetClassificationManager().GetBestGenotype();
-  for (int i = 0; i < world->GetClassificationManager().GetGenotypeCount(); i++) {
-    fp << genotype->GetID() << " "             // 1
-    << genotype->GetTestFitness(world->GetDefaultContext()) << " "    // 2
-    << genotype->GetNumOrganisms() << " "   // 3
-    << genotype->GetDepth() << " "          // 4
-    << endl;
-    
-    // ...and advance to the next genotype...
-    genotype = genotype->GetNext();
-  }
-}

Deleted: development/source/analyze/cAnalyzeUtil.h
===================================================================
--- development/source/analyze/cAnalyzeUtil.h	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/analyze/cAnalyzeUtil.h	2006-08-09 18:21:51 UTC (rev 865)
@@ -1,57 +0,0 @@
-/*
- *  cAnalyzeUtil.h
- *  Avida
- *
- *  Created by David on 12/2/05.
- *  Copyright 2005-2006 Michigan State University. All rights reserved.
- *  Copyright 1993-2003 California Institute of Technology.
- *
- */
-
-#ifndef cAnalyzeUtil_h
-#define cAnalyzeUtil_h
-
-#include <fstream>
-
-class cGenome;
-class cInstSet;
-class cPopulation;
-class cWorld;
-class cString;
-
-// This is a static class used to do various forms of complex analysis
-// on genomes.
-
-class cAnalyzeUtil {
-private:
-public:
-  // Generic test-CPU analysis
-  static void TestGenome(cWorld* world, const cGenome & genome, cInstSet & inst_set,
-			 std::ofstream& fp, int update);
-
-  static void TestInsSizeChangeRobustness(cWorld* world, std::ofstream& fp,
-                 const cInstSet & inst_set, const cGenome & in_genome,
-                 int num_trials, int update);
-
-
-  // Population-wide analysis
-  static void CalcConsensus(cWorld* world, int lines_saved);
-
-  static void TaskSnapshot(cWorld* world, std::ofstream& fp);
-  static void TaskGrid(cWorld* world, std::ofstream& fp);
-  static void PrintViableTasksData(cWorld* world, std::ofstream& fp);
-  static void PrintTreeDepths(cWorld* world, std::ofstream& fp);
-};
-
-#ifdef ENABLE_UNIT_TESTS
-namespace nAnalyzeUtil {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
-#endif

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2006-08-08 16:32:25 UTC (rev 864)
+++ development/source/event/cEventManager.cc	2006-08-09 18:21:51 UTC (rev 865)
@@ -42,222 +42,7 @@
 using namespace std;
 
 
-///// zero_muts /////
 
-/**
-* This event will set all mutation rates to zero...
- **/
-
-
-class cEvent_zero_muts : public cEvent {
-private:
-public:
-  const cString GetName() const { return "zero_muts"; }
-  const cString GetDescription() const { return "zero_muts"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-  }
-  ///// zero_muts /////
-  void Process(){
-    for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
-      m_world->GetPopulation().GetCell(i).MutationRates().Clear();
-    }
-  }
-};
-
-///// mod_copy_mut /////
-
-/**
-**/
-
-
-class cEvent_mod_copy_mut : public cEvent {
-private:
-  double cmut_inc;
-  int cell;
-public:
-    const cString GetName() const { return "mod_copy_mut"; }
-  const cString GetDescription() const { return "mod_copy_mut  <double cmut_inc> [int cell=-1]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    cmut_inc = args.PopWord().AsDouble();
-    if (args == "") cell=-1; else cell=args.PopWord().AsInt();
-  }
-  ///// mod_copy_mut /////
-  void Process(){
-    const double new_cmut = m_world->GetConfig().COPY_MUT_PROB.Get() + cmut_inc;
-    if (cell < 0) {   // cell == -1  -->  all
-      for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
-        m_world->GetPopulation().GetCell(i).MutationRates().SetCopyMutProb(new_cmut);
-      }
-      m_world->GetConfig().COPY_MUT_PROB.Set(new_cmut);
-    } else {
-      m_world->GetPopulation().GetCell(cell).MutationRates().SetCopyMutProb(new_cmut);
-    }
-  }
-};
-
-///// mod_div_mut /////
-
-/**
-**/
-
-
-class cEvent_mod_div_mut : public cEvent {
-private:
-  double dmut_inc;
-  int cell;
-public:
-    const cString GetName() const { return "mod_div_mut"; }
-  const cString GetDescription() const { return "mod_div_mut  <double dmut_inc> [int cell=-1]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    dmut_inc = args.PopWord().AsDouble();
-    if (args == "") cell=-1; else cell=args.PopWord().AsInt();
-  }
-  ///// mod_div_mut /////
-  void Process(){
-    const double new_div_mut = m_world->GetConfig().DIV_MUT_PROB.Get() + dmut_inc;
-    if (cell < 0) {   // cell == -1  -->  all
-      for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
-        m_world->GetPopulation().GetCell(i).MutationRates().SetDivMutProb(new_div_mut);
-      }
-      m_world->GetConfig().DIV_MUT_PROB.Set(new_div_mut);
-    } else {
-      m_world->GetPopulation().GetCell(cell).MutationRates().SetDivMutProb(new_div_mut);
-    }
-  }
-};
-
-
-///// mod_point_mut /////
-
-/**
-**/
-
-
-class cEvent_mod_point_mut : public cEvent {
-private:
-  double pmut_inc;
-  int cell;
-public:
-    const cString GetName() const { return "mod_point_mut"; }
-  const cString GetDescription() const { return "mod_point_mut  <double pmut_inc> [int cell=-1]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    pmut_inc = args.PopWord().AsDouble();
-    if (args == "") cell=-1; else cell=args.PopWord().AsInt();
-  }
-  ///// mod_point_mut /////
-  void Process(){
-    const double new_pmut = m_world->GetConfig().POINT_MUT_PROB.Get() + pmut_inc;
-    if (cell < 0) {   // cell == -1   -->  all
-      for (int i = 0; i < m_world->GetPopulation().GetSize(); i++) {
-        m_world->GetPopulation().GetCell(i).MutationRates().SetPointMutProb(new_pmut);
-      }
-      m_world->GetConfig().POINT_MUT_PROB.Set(new_pmut);
-    } else {
-      m_world->GetPopulation().GetCell(cell).MutationRates().SetPointMutProb(new_pmut);
-    }
-  }
-};
-
-///// test_dom /////
-
-/**
-**/
-
-
-class cEvent_test_dom : public cEvent {
-private:
-public:
-  const cString GetName() const { return "test_dom"; }
-  const cString GetDescription() const { return "test_dom"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args; }
-  ///// test_dom /////
-  void Process(){
-    cGenome & genome = m_world->GetClassificationManager().GetBestGenotype()->GetGenome();
-    cAnalyzeUtil::TestGenome(m_world, genome, m_world->GetHardwareManager().GetInstSet(),
-                             m_world->GetDataFileOFStream("dom-test.dat"), m_world->GetStats().GetUpdate());
-  }
-};
-
-
-///// task_snapshot /////
-
-/**
-**/
-
-
-class cEvent_task_snapshot : public cEvent {
-private:
-  cString filename;
-public:
-  const cString GetName() const { return "task_snapshot"; }
-  const cString GetDescription() const { return "task_snapshot  [string filename=\"\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") filename = "";
-    else filename = args.PopWord();
-  }
-  ///// task_snapshot /////
-  void Process(){
-    if (filename == "") filename.Set("tasks_%d.dat",m_world->GetStats().GetUpdate());
-    cAnalyzeUtil::TaskSnapshot(m_world, m_world->GetDataFileOFStream(filename));
-    m_world->GetDataFileManager().Remove(filename);
-  }
-};
-
-///// print_viable_tasks_data /////
-
-/**
-**/
-
-
-class cEvent_print_viable_tasks_data : public cEvent {
-private:
-  cString filename;
-public:
-  const cString GetName() const { return "print_viable_tasks_data"; }
-  const cString GetDescription() const { return "print_viable_tasks_data  [string filename=\"viable_tasks.dat\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") filename="viable_tasks.dat"; else filename=args.PopWord();
-  }
-  ///// print_viable_tasks_data /////
-  void Process(){
-    cAnalyzeUtil::PrintViableTasksData(m_world, m_world->GetDataFileOFStream(filename));
-  }
-};
-
-
 ///// compete_demes /////
 
 /**
@@ -370,69 +155,8 @@
   }
 };
 
-///// calc_consensus /////
 
-/**
-* Calculates the consensus sequence.
- *
- * Parameters:
- * lines saved (integer) default: 0
-   *    ???
-   **/
 
-
-class cEvent_calc_consensus : public cEvent {
-private:
-  int lines_saved;
-public:
-  const cString GetName() const { return "calc_consensus"; }
-  const cString GetDescription() const { return "calc_consensus  [int lines_saved=0]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") lines_saved=0; else lines_saved=args.PopWord().AsInt();
-  }
-  ///// calc_consensus /////
-  void Process(){
-    cAnalyzeUtil::CalcConsensus(m_world, lines_saved);
-  }
-};
-
-///// test_size_change_robustness /////
-
-/**
-**/
-
-
-class cEvent_test_size_change_robustness : public cEvent {
-private:
-  int num_trials;
-  cString filename;
-public:
-    const cString GetName() const { return "test_size_change_robustness"; }
-  const cString GetDescription() const { return "test_size_change_robustness  [int num_trials=100] [string filename=\"size_change.dat\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") num_trials=100; else num_trials=args.PopWord().AsInt();
-    if (args == "") filename="size_change.dat"; else filename=args.PopWord();
-  }
-  ///// test_size_change_robustness /////
-  void Process(){
-    ofstream& fp = m_world->GetDataFileOFStream(filename);
-    cAnalyzeUtil::TestInsSizeChangeRobustness(m_world, fp,
-                                              m_world->GetHardwareManager().GetInstSet(),
-                                              m_world->GetClassificationManager().GetBestGenotype()->GetGenome(),
-                                              num_trials, m_world->GetStats().GetUpdate());
-  }
-};
-
 ///// test_threads /////
 
 /**
@@ -592,7 +316,34 @@
   void Process(){
     cString filename;
     filename.Set("task_grid_%d.dat", m_world->GetStats().GetUpdate());
-    cAnalyzeUtil::TaskGrid(m_world, m_world->GetDataFileOFStream(filename));
+    ofstream& fp = m_world->GetDataFileOFStream(filename);
+    
+    cPopulation* pop = &m_world->GetPopulation();
+    cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
+    cAvidaContext& ctx = m_world->GetDefaultContext();
+    
+    for (int i = 0; i < pop->GetWorldX(); i++) {
+      for (int j = 0; j < pop->GetWorldY(); j++) {
+        int task_sum = 0;
+        int cell_num = i * pop->GetWorldX()+j;
+        if (pop->GetCell(cell_num).IsOccupied() == true) {
+          cOrganism* organism = pop->GetCell(cell_num).GetOrganism();
+          cCPUTestInfo test_info;
+          testcpu->TestGenome(ctx, test_info, organism->GetGenome());
+          cPhenotype& test_phenotype = test_info.GetTestPhenotype();
+          int num_tasks = m_world->GetEnvironment().GetTaskLib().GetSize();   
+          for (int k = 0; k < num_tasks; k++) {
+            if (test_phenotype.GetLastTaskCount()[k] > 0) {
+              task_sum = task_sum + static_cast<int>(pow(2.0, k)); 
+            } 
+          }
+        }
+        fp << task_sum << " ";
+      }
+      fp << endl;
+    }
+    
+    delete testcpu;    
     m_world->GetDataFileManager().Remove(filename);
   }
 };
@@ -676,35 +427,6 @@
   }
 };
 
-///// print_tree_depths /////
-
-/**
-* Reconstruction of phylogenetic trees.
- **/
-
-
-class cEvent_print_tree_depths : public cEvent {
-private:
-  cString filename;
-public:
-  const cString GetName() const { return "print_tree_depths"; }
-  const cString GetDescription() const { return "print_tree_depths  [string filename=\"\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") filename=""; else filename=args.PopWord();
-  }
-  ///// print_tree_depths /////
-  void Process(){
-    if (filename == "") filename.Set("tree_depth.%d.dat", m_world->GetStats().GetUpdate());
-    cAnalyzeUtil::PrintTreeDepths(m_world, m_world->GetDataFileOFStream(filename));
-    m_world->GetDataFileManager().Remove(filename);
-  }
-};
-
 ///// sever_grid_col /////
 
 /**
@@ -1327,22 +1049,11 @@
 
 cEventManager::cEventManager(cWorld* world) : m_world(world)
 {
-  REGISTER(zero_muts);
-  REGISTER(mod_copy_mut);
-  REGISTER(mod_div_mut);
-  REGISTER(mod_point_mut);
-  REGISTER(test_dom);
-
-  REGISTER(task_snapshot);
-  REGISTER(print_viable_tasks_data);
-  
   REGISTER(compete_demes);
   REGISTER(reset_demes);
   REGISTER(print_deme_stats);
   REGISTER(copy_deme);
   
-  REGISTER(calc_consensus);
-  REGISTER(test_size_change_robustness);
   REGISTER(test_threads);
   REGISTER(print_threads);
   REGISTER(dump_fitness_grid);
@@ -1350,7 +1061,6 @@
   REGISTER(dump_task_grid);
   REGISTER(dump_donor_grid);
   REGISTER(dump_receiver_grid);
-  REGISTER(print_tree_depths);
   REGISTER(sever_grid_col);
   REGISTER(sever_grid_row);
   REGISTER(join_grid_col);




More information about the Avida-cvs mailing list