[Avida-cvs] [avida-svn] r853 - in development: Avida.xcodeproj source/actions source/analyze source/classification source/cpu source/event source/main

brysonda@myxo.css.msu.edu brysonda at myxo.css.msu.edu
Mon Jul 24 11:45:33 PDT 2006


Author: brysonda
Date: 2006-07-24 14:45:33 -0400 (Mon, 24 Jul 2006)
New Revision: 853

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/actions/LandscapeActions.cc
   development/source/actions/PrintActions.cc
   development/source/analyze/cAnalyzeUtil.cc
   development/source/analyze/cAnalyzeUtil.h
   development/source/classification/cClassificationManager.cc
   development/source/classification/cClassificationManager.h
   development/source/classification/cGenotype.cc
   development/source/classification/cGenotype.h
   development/source/classification/cLineage.cc
   development/source/classification/cLineage.h
   development/source/cpu/cHardwareBase.cc
   development/source/event/cEventManager.cc
   development/source/main/cLandscape.cc
   development/source/main/cLandscape.h
   development/source/main/cOrganism.cc
   development/source/main/cOrganism.h
   development/source/main/cPopulation.cc
Log:
Transition AnalyzePopulation over to actions framework.  Add cDataFile based stats output to cLandscape.

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-07-24 17:35:17 UTC (rev 852)
+++ development/Avida.xcodeproj/project.pbxproj	2006-07-24 18:45:33 UTC (rev 853)
@@ -673,10 +673,8 @@
 		70B0887D08F603C600FC65FE /* cFile.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cFile.h; sourceTree = "<group>"; };
 		70B0887F08F603C600FC65FE /* cFixedBlock.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cFixedBlock.h; sourceTree = "<group>"; };
 		70B0888008F603C600FC65FE /* cFixedCoords.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cFixedCoords.h; sourceTree = "<group>"; };
-		70B0888108F603C600FC65FE /* cGenesis.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cGenesis.h; sourceTree = "<group>"; };
 		70B0888208F603C600FC65FE /* functions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = functions.h; sourceTree = "<group>"; };
 		70B0888308F603D400FC65FE /* cFile.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cFile.cc; sourceTree = "<group>"; };
-		70B0888408F603D400FC65FE /* cGenesis.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cGenesis.cc; sourceTree = "<group>"; };
 		70B088F708F762EA00FC65FE /* cHelpAlias.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHelpAlias.h; sourceTree = "<group>"; };
 		70B088F808F762EA00FC65FE /* cHelpEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHelpEntry.h; sourceTree = "<group>"; };
 		70B088F908F762EA00FC65FE /* cHelpFullEntry.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHelpFullEntry.h; sourceTree = "<group>"; };
@@ -1576,11 +1574,9 @@
 				70B0891408F762EA00FC65FE /* cStringList.h */,
 				70B0891508F762EA00FC65FE /* cStringUtil.h */,
 				70B0888308F603D400FC65FE /* cFile.cc */,
-				70B0888408F603D400FC65FE /* cGenesis.cc */,
 				70B0887D08F603C600FC65FE /* cFile.h */,
 				70B0887F08F603C600FC65FE /* cFixedBlock.h */,
 				70B0888008F603C600FC65FE /* cFixedCoords.h */,
-				70B0888108F603C600FC65FE /* cGenesis.h */,
 				70B0888208F603C600FC65FE /* functions.h */,
 				70B0884F08F5FE5800FC65FE /* cDataFile.cc */,
 				70B0885008F5FE5800FC65FE /* cDataFileManager.cc */,

Modified: development/source/actions/LandscapeActions.cc
===================================================================
--- development/source/actions/LandscapeActions.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/actions/LandscapeActions.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -21,8 +21,13 @@
 #include "cLandscape.h"
 #include "cMutationalNeighborhood.h"
 #include "cMutationalNeighborhoodResults.h"
+#include "cOrganism.h"
+#include "cPhenotype.h"
+#include "cPopulation.h"
+#include "cPopulationCell.h"
 #include "cStats.h"
 #include "cString.h"
+#include "cTestUtil.h"
 #include "cWorld.h"
 #include "cWorldDriver.h"
 #include "tSmartArray.h"
@@ -918,6 +923,121 @@
 };
 
 
+class cActionAnalyzePopulation : public cAction  // @parallelized
+{
+private:
+  double m_sprob;
+  int m_cland;
+  int m_save_genotypes;
+  cString m_filename;
+
+  class cPopOrgData
+  {
+  private:
+    cWorld* m_world;
+    cOrganism* m_org;
+    int m_cell;
+    bool m_cland;
+    cLandscape* m_land;
+
+  public:
+    cPopOrgData(cWorld* world, cOrganism* org, int cell, bool cland)
+      : m_world(world), m_org(org), m_cell(cell), m_cland(cland), m_land(NULL) { ; }
+    ~cPopOrgData() { delete m_land; }
+    
+    inline cOrganism* GetOrganism() { return m_org; }
+    inline int GetCellID() { return m_cell; }
+    inline void PrintLand(cDataFile& df, int update) { if (m_land) m_land->PrintStats(df, update); else df.Endl(); }
+    
+    void Process(cAvidaContext& ctx)
+    {
+      if (m_org->GetTestFitness(ctx) > 0.0 && m_cland) {
+        m_land = new cLandscape(m_world, m_org->GetGenome(), m_world->GetHardwareManager().GetInstSet());
+        m_land->SetDistance(1);
+        m_land->Process(ctx);
+      }
+    }
+  };
+  
+  
+public:
+  cActionAnalyzePopulation(cWorld* world, const cString& args)
+    : cAction(world, args), m_sprob(1.0), m_cland(0), m_save_genotypes(0), m_filename("")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_sprob = largs.PopWord().AsDouble();
+    if (largs.GetSize()) m_cland = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_save_genotypes = largs.PopWord().AsInt();
+    if (largs.GetSize()) m_filename = largs.PopWord();
+  }
+  
+  const cString GetDescription()
+  {
+    return "AnalyzePopulation [double sample_prob=1] [int landscape=0] [int save_genotype=0] [string filename='']";
+  }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    if (ctx.GetAnalyzeMode()) {
+      m_world->GetDriver().NotifyWarning("AnalyzePopulation not currently supported in Analyze Mode.");
+    } else {
+      if (m_world->GetConfig().VERBOSITY.Get() >= VERBOSE_DETAILS)
+        m_world->GetDriver().NotifyComment("Analyzing Population...");
+
+      const int update = m_world->GetStats().GetUpdate();
+
+      cString filename(m_filename);
+      if (filename == "") filename.Set("pop-analysis-%d.dat", update);
+            
+      cPopOrgData* orgdata;
+      tList<cPopOrgData> batch;
+ 
+      cPopulation& pop = m_world->GetPopulation();
+      cAnalyzeJobQueue& jobqueue = m_world->GetAnalyze().GetJobQueue();
+      const double skip_prob = 1.0 - m_sprob;
+      for (int i = 0; i < pop.GetSize(); i++) {
+        if (pop.GetCell(i).IsOccupied() == false) continue;  // No organism...
+        if (ctx.GetRandom().P(skip_prob)) continue;       // Not sampled...
+        
+        orgdata = new cPopOrgData(m_world, pop.GetCell(i).GetOrganism(), i, m_cland);
+        batch.PushRear(orgdata);
+        jobqueue.AddJob(new tAnalyzeJob<cPopOrgData>(orgdata, &cPopOrgData::Process));
+      }
+
+      cDataFile& df = m_world->GetDataFile(filename);
+      while (orgdata = batch.Pop()) {
+        cOrganism* organism = orgdata->GetOrganism();
+        cGenotype* genotype = organism->GetGenotype();
+        cPhenotype& phenotype = organism->GetPhenotype();
+        
+        cString name;
+        if (genotype->GetThreshold()) name = genotype->GetName();
+        else name.Set("%03d-no_name-u%i-c%i", genotype->GetLength(), update, orgdata->GetCellID());
+
+        
+        df.Write(orgdata->GetCellID(), "Cell ID");
+        df.Write(name, "Organism Name");
+        df.Write(genotype->GetLength(),"Genome Length");
+        df.Write(genotype->GetTestFitness(ctx), "Fitness (test-cpu)");
+        df.Write(phenotype.GetFitness(), "Fitness (actual)");
+        df.Write(genotype->GetBreedTrue(), "Breed True");
+        df.Write(organism->GetLineageLabel(), "Lineage Label");
+        df.Write(phenotype.GetNeutralMetric(), "Neutral Metric");
+        orgdata->PrintLand(df, update);
+        
+        // save into archive
+        if (m_save_genotypes) {
+          name.Set("archive/%s.org", static_cast<const char *>(name));
+          cTestUtil::PrintGenome(m_world, organism->GetGenome(), name);
+        }
+      }
+      m_world->GetDataFileManager().Remove(filename);
+    }
+  }
+};
+
+
+
 void RegisterLandscapeActions(cActionLibrary* action_lib)
 {
   action_lib->Register<cActionAnalyzeLandscape>("AnalyzeLandscape");
@@ -933,6 +1053,7 @@
   action_lib->Register<cActionHillClimb>("HillClimbNeut");
   action_lib->Register<cActionHillClimb>("HillClimbRand");
   action_lib->Register<cActionPairTestLandscape>("PairTestLandscape");
+  action_lib->Register<cActionAnalyzeLandscape>("AnalyzePopulation");
 
   action_lib->Register<cActionMutationalNeighborhood>("MutationalNeighborhood");
   

Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/actions/PrintActions.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -11,7 +11,6 @@
 
 #include "cAction.h"
 #include "cActionLibrary.h"
-#include "cAnalyzeUtil.h"
 #include "cClassificationManager.h"
 #include "cCPUTestInfo.h"
 #include "cGenome.h"
@@ -803,11 +802,11 @@
       
       // now output
       
-      sum_fitness += cur_genotype->GetTestFitness() * num_orgs;
+      sum_fitness += cur_genotype->GetTestFitness(ctx) * num_orgs;
       sum_num_organisms += num_orgs;
       
       df.Write(cur_genotype->GetName(), "Genotype Name");
-      df.Write(cur_genotype->GetTestFitness(), "Fitness (test-cpu)");
+      df.Write(cur_genotype->GetTestFitness(ctx), "Fitness (test-cpu)");
       df.Write(num_orgs, "Abundance");
       df.Write(cGenomeUtil::FindHammingDistance(reference_genome, genome), "Hamming distance to reference");
       df.Write(cGenomeUtil::FindEditDistance(reference_genome, genome), "Levenstein distance to reference");

Modified: development/source/analyze/cAnalyzeUtil.cc
===================================================================
--- development/source/analyze/cAnalyzeUtil.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/analyze/cAnalyzeUtil.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -279,75 +279,7 @@
 }
 
 
-
 /**
-* This function goes through all creatures in the soup, and saves the
- * basic landscape data (neutrality, fitness, and so on) into a stream.
- *
- * @param fp The stream into which the data should be saved.
- *
- * @param sample_prob The probability with which a particular creature should
- * be analyzed (a value of 1 analyzes all creatures, a value of 0.1 analyzes
-                * 10%, and so on).
- *
- * @param landscape A bool that indicates whether the creatures should be
- * landscaped (calc. neutrality and so on) or not.
- *
- * @param save_genotype A bool that indicates whether the creatures should
- * be saved or not.
- **/
-
-void cAnalyzeUtil::AnalyzePopulation(cWorld* world, ofstream& fp,
-                                     double sample_prob, bool landscape, bool save_genotype)
-{
-  cPopulation* pop = &world->GetPopulation();
-  fp << "# (1) cell number (2) genotype name (3) length (4) fitness [test-cpu] (5) fitness (actual) (6) merit (7) no of breed trues occurred (8) lineage label (9) neutral metric (10) -... landscape data" << endl;
-  
-  cAvidaContext& ctx = world->GetDefaultContext();
-
-  const double skip_prob = 1.0 - sample_prob;
-  for (int i = 0; i < pop->GetSize(); i++) {
-    if (pop->GetCell(i).IsOccupied() == false) continue;  // No organism...
-    if (world->GetRandom().P(skip_prob)) continue;               // Not sampled...
-    
-    cOrganism * organism = pop->GetCell(i).GetOrganism();
-    cGenotype * genotype = organism->GetGenotype();
-    const cGenome & genome = organism->GetGenome();
-    
-    cString creature_name;
-    if ( genotype->GetThreshold() ) creature_name = genotype->GetName();
-    else creature_name.Set("%03d-no_name-u%i-c%i", genotype->GetLength(),
-                           world->GetStats().GetUpdate(), i );
-    
-    fp << i                                     << " "  // 1 cell ID
-      << creature_name                       << " "  // 2 name
-      << genotype->GetLength()                 << " "  // 3 length
-      << genotype->GetTestFitness()            << " "  // 4 fitness (test-cpu)
-      << organism->GetPhenotype().GetFitness() << " "  // 5 fitness (actual)
-      << organism->GetPhenotype().GetMerit()   << " "  // 6 merit
-      << genotype->GetBreedTrue()              << " "  // 7 breed true?
-      << organism->GetLineageLabel()           << " "  // 8 lineage label
-      << organism->GetPhenotype().GetNeutralMetric() << " "; // 9 neut metric
-    
-    // create landscape object for this creature
-    if (landscape &&  genotype->GetTestFitness() > 0) {
-      cLandscape landscape(world, genome, world->GetHardwareManager().GetInstSet());
-      landscape.SetDistance(1);
-      landscape.Process(ctx);
-      landscape.PrintStats(fp);
-    }
-    else fp << endl;
-    if ( save_genotype ){
-      char filename[40];
-      sprintf(filename, "classmgr/%s", static_cast<const char*>(creature_name));
-      cTestUtil::PrintGenome(world, genome, filename);
-    }
-  }
-}
-
-
-
-/**
 * 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
@@ -463,7 +395,7 @@
   
   for (int i = 0; i < pop->GetSize(); i++) {
     if (pop->GetCell(i).IsOccupied() == false) continue;
-    if (pop->GetCell(i).GetOrganism()->GetGenotype()->GetTestFitness() > 0.0) {
+    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;
@@ -483,7 +415,7 @@
   cGenotype* genotype = world->GetClassificationManager().GetBestGenotype();
   for (int i = 0; i < world->GetClassificationManager().GetGenotypeCount(); i++) {
     fp << genotype->GetID() << " "             // 1
-    << genotype->GetTestFitness() << " "    // 2
+    << genotype->GetTestFitness(world->GetDefaultContext()) << " "    // 2
     << genotype->GetNumOrganisms() << " "   // 3
     << genotype->GetDepth() << " "          // 4
     << endl;

Modified: development/source/analyze/cAnalyzeUtil.h
===================================================================
--- development/source/analyze/cAnalyzeUtil.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/analyze/cAnalyzeUtil.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -37,10 +37,6 @@
   // Population-wide analysis
   static void CalcConsensus(cWorld* world, int lines_saved);
 
-  static void AnalyzePopulation(cWorld* world, std::ofstream& fp,
-				double sample_prob=1, bool landscape=false,
-				bool save_genotype=false);
-
   static void TaskSnapshot(cWorld* world, std::ofstream& fp);
   static void TaskGrid(cWorld* world, std::ofstream& fp);
   static void PrintViableTasksData(cWorld* world, std::ofstream& fp);

Modified: development/source/classification/cClassificationManager.cc
===================================================================
--- development/source/classification/cClassificationManager.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cClassificationManager.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -936,8 +936,8 @@
       del = true;
     }
     else { // otherwise it is a candidate for the best/ dominant/... lineage
-      if ( !m_best_lineage ||
-           (*it)->GetAveFitness() > m_best_lineage->GetAveFitness() )
+      cAvidaContext& ctx = m_world->GetDefaultContext();
+      if (!m_best_lineage || (*it)->GetAveFitness(ctx) > m_best_lineage->GetAveFitness(ctx))
         m_best_lineage = (*it);
       
       if ( !m_dominant_lineage ||
@@ -969,7 +969,8 @@
 }
 
 
-cLineage* cClassificationManager::GetLineage(cGenotype* child_genotype, cGenotype* parent_genotype, cLineage* parent_lineage, int parent_lin_id)
+cLineage* cClassificationManager::GetLineage(cAvidaContext& ctx, cGenotype* child_genotype,
+                                             cGenotype* parent_genotype, cLineage* parent_lineage, int parent_lin_id)
 {
   // Collect any information we can about the parent.
   double parent_fitness = 0.0;
@@ -987,9 +988,9 @@
   
   if (parent_genotype != NULL) {
     assert( parent_genotype->GetNumOrganisms() > 0 );
-    parent_fitness = parent_genotype->GetTestColonyFitness();
+    parent_fitness = parent_genotype->GetTestColonyFitness(ctx);
   }
-  double child_fitness = child_genotype->GetTestColonyFitness();
+  double child_fitness = child_genotype->GetTestColonyFitness(ctx);
   cLineage * child_lineage = parent_lineage;
   bool create_lineage = false;
   double lineage_stat1 = child_fitness;
@@ -1043,10 +1044,10 @@
         break;
       case 4: // new lineage whenever a new child exceeds the
               // fitness of the dominant creature (and the fitness of its own lineage)
-        if (child_fitness > m_world->GetClassificationManager().GetBestGenotype()->GetTestColonyFitness()
+        if (child_fitness > m_world->GetClassificationManager().GetBestGenotype()->GetTestColonyFitness(ctx)
             && child_fitness > parent_lineage->GetMaxFitness() ){
           create_lineage = true;
-          lineage_stat1=m_world->GetClassificationManager().GetBestGenotype()->GetTestColonyFitness();
+          lineage_stat1=m_world->GetClassificationManager().GetBestGenotype()->GetTestColonyFitness(ctx);
           lineage_stat2=parent_lineage->GetMaxFitness();
         }
         break;
@@ -1082,7 +1083,7 @@
   }
   
   // add to the lineage
-  child_lineage->AddCreature( child_genotype );
+  child_lineage->AddCreature(ctx, child_genotype);
   
   // This would be nice, but the current Avida code doesn't allow for it.
   // Try to implement it in a new version...
@@ -1091,7 +1092,7 @@
   //  cpu->SetLineageLabel( lineage->GetID() );
   
   // test whether this makes the new lineage the best
-  if (!m_best_lineage || child_lineage->GetAveFitness() > m_best_lineage->GetAveFitness())
+  if (!m_best_lineage || child_lineage->GetAveFitness(ctx) > m_best_lineage->GetAveFitness(ctx))
     m_best_lineage = child_lineage;
   
   // test whether this makes the new lineage the dominant
@@ -1112,7 +1113,7 @@
   
   if (cur_lineage) {
     // remove the creature
-    if ( cur_lineage->RemoveCreature(org->GetGenotype())
+    if ( cur_lineage->RemoveCreature(m_world->GetDefaultContext(), org->GetGenotype())
          || cur_lineage == m_dominant_lineage
          || cur_lineage == m_best_lineage ) {
       // If this lineage no longer exists, tell stats...
@@ -1177,7 +1178,7 @@
     list<cLineage *>::const_iterator it = lineage_list.begin();
     for ( ; it != lineage_list.end(); it++ ){
       num_organisms = (*it)->GetNumCreatures();
-      fitness = (*it)->GetAveFitness();
+      fitness = (*it)->GetAveFitness(m_world->GetDefaultContext());
       fitness_sum += fitness * num_organisms;
       total_num_organisms += num_organisms;
       fp << " "

Modified: development/source/classification/cClassificationManager.h
===================================================================
--- development/source/classification/cClassificationManager.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cClassificationManager.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -35,6 +35,7 @@
 #include "tList.h"
 #endif
 
+class cAvidaContext;
 class cLineage;
 class cOrganism;
 class cWorld;
@@ -166,7 +167,8 @@
 
 
   // Lineage Manipulators
-  cLineage* GetLineage(cGenotype* child_genotype, cGenotype* parent_genotype, cLineage* parent_lineage, int parent_lin_id);
+  cLineage* GetLineage(cAvidaContext& ctx, cGenotype* child_genotype,
+                       cGenotype* parent_genotype, cLineage* parent_lineage, int parent_lin_id);
   void RemoveLineageOrganism(cOrganism* org);  
   cLineage* FindLineage(int lineage_id) const;
   cLineage* GetMaxFitnessLineage() const { return m_max_fitness_lineage; }

Modified: development/source/classification/cGenotype.cc
===================================================================
--- development/source/classification/cGenotype.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cGenotype.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -185,10 +185,9 @@
   name.Set("%03d-no_name", genome.GetSize());
 }
 
-void cGenotype::CalcTestStats() const
+void cGenotype::CalcTestStats(cAvidaContext& ctx) const
 {
   cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
-  cAvidaContext& ctx = m_world->GetDefaultContext();
 
   cCPUTestInfo test_info;
   testcpu->TestGenome(ctx, test_info, genome);

Modified: development/source/classification/cGenotype.h
===================================================================
--- development/source/classification/cGenotype.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cGenotype.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -29,8 +29,9 @@
 #include "cString.h"
 #endif
 
-class cSpecies;
+class cAvidaContext;
 class cMerit;
+class cSpecies;
 class cWorld;
 
 class cGenotype {
@@ -60,8 +61,8 @@
   cSpecies* species;
 
   // Data Structure stuff...
-  cGenotype * next;
-  cGenotype * prev;
+  cGenotype* next;
+  cGenotype* prev;
 
 
   ////// Statistical info //////
@@ -88,7 +89,7 @@
   cDoubleSum tmp_sum_fitness;
 
   
-  void CalcTestStats() const;
+  void CalcTestStats(cAvidaContext& ctx) const;
   
   cGenotype(cWorld* world, int in_update_born, int in_id);
   
@@ -108,19 +109,19 @@
   void SetSpecies(cSpecies * in_species) { species = in_species; }
 
   // Test CPU info -- only used with limited options on.
-  inline bool GetTestViable() const;
-  inline double GetTestFitness() const;
-  inline double GetTestMerit() const;
-  inline int GetTestGestationTime() const;
-  inline int GetTestExecutedSize() const;
-  inline int GetTestCopiedSize() const;
-  inline double GetTestColonyFitness() const;
-  inline int GetTestGenerations() const;
+  inline bool GetTestViable(cAvidaContext& ctx) const;
+  inline double GetTestFitness(cAvidaContext& ctx) const;
+  inline double GetTestMerit(cAvidaContext& ctx) const;
+  inline int GetTestGestationTime(cAvidaContext& ctx) const;
+  inline int GetTestExecutedSize(cAvidaContext& ctx) const;
+  inline int GetTestCopiedSize(cAvidaContext& ctx) const;
+  inline double GetTestColonyFitness(cAvidaContext& ctx) const;
+  inline int GetTestGenerations(cAvidaContext& ctx) const;
 
-  void SetParent(cGenotype * parent, cGenotype * parent2);
+  void SetParent(cGenotype* parent, cGenotype* parent2);
   void SetName(cString in_name)     { name = in_name; }
-  void SetNext(cGenotype * in_next) { next = in_next; }
-  void SetPrev(cGenotype * in_prev) { prev = in_prev; }
+  void SetNext(cGenotype* in_next) { next = in_next; }
+  void SetPrev(cGenotype* in_prev) { prev = in_prev; }
   void SetSymbol(char in_symbol) { symbol = in_symbol; }
   inline void SetThreshold();
   void IncDeferAdjust() { defer_adjust++; }
@@ -128,25 +129,19 @@
   void SetLineageLabel(int in_label) { birth_data.lineage_label = in_label; }
 
   // Setting New Stats
-  void AddCopiedSize      (int in)   { sum_copied_size.Add(in); }
-  void AddExecutedSize         (int in)   { sum_exe_size.Add(in); }
-  void AddGestationTime   (int in)   { sum_gestation_time.Add(in);
+  void AddCopiedSize(int in) { sum_copied_size.Add(in); }
+  void AddExecutedSize(int in) { sum_exe_size.Add(in); }
+  void AddGestationTime(int in) { sum_gestation_time.Add(in);
                                        sum_repro_rate.Add(1/(double)in); }
-  void AddMerit      (const cMerit & in);
-  void RemoveMerit   (const cMerit & in);
-  void AddFitness    (double in){
-    assert(in >= 0.0);
-    sum_fitness.Add(in);
-  }
-  void RemoveFitness (double in){
-    assert(in >= 0.0);
-    sum_fitness.Subtract(in);
-  }
+  void AddMerit(const cMerit& in);
+  void RemoveMerit(const cMerit& in);
+  void AddFitness(double in) { assert(in >= 0.0); sum_fitness.Add(in); }
+  void RemoveFitness(double in) { assert(in >= 0.0); sum_fitness.Subtract(in); }
 
   //// Properties Native to Genotype ////
-  cGenome & GetGenome()             { return genome; }
-  const cGenome & GetGenome() const { return genome; }
-  int GetLength()             const { return genome.GetSize(); }
+  cGenome& GetGenome() { return genome; }
+  const cGenome& GetGenome() const { return genome; }
+  int GetLength() const { return genome.GetSize(); }
 
   int GetBirths()    const { return birth_data.birth_track.GetTotal(); }
   int GetBreedOut()  const { return birth_data.breed_out_track.GetTotal(); }
@@ -201,18 +196,18 @@
   int GetParentDistance() const { return birth_data.parent_distance; }
   int GetDepth() const          { return birth_data.gene_depth; }
   int GetLineageLabel() const   { return birth_data.lineage_label; }
-  cString & GetName()           { return name; }
-  cSpecies * GetSpecies()       { return species; }
-  cSpecies * GetParentSpecies() { return birth_data.parent_species; }
-  cGenotype * GetNext()         { return next; }
-  cGenotype * GetPrev()         { return prev; }
+  cString& GetName()            { return name; }
+  cSpecies* GetSpecies()        { return species; }
+  cSpecies* GetParentSpecies()  { return birth_data.parent_species; }
+  cGenotype* GetNext()          { return next; }
+  cGenotype* GetPrev()          { return prev; }
   bool GetThreshold() const     { return flag_threshold; }
   int GetID() const             { return id_num; }
   char GetSymbol() const        { return symbol; }
 
   // Calculate a crude phylogentic distance based off of tracking parents
   // and grand-parents, including sexual tracking.
-  int GetPhyloDistance(cGenotype * test_genotype);
+  int GetPhyloDistance(cGenotype* test_genotype);
 
   inline int AddOrganism();
   inline int RemoveOrganism();
@@ -265,50 +260,50 @@
   }
 }
 
-inline bool cGenotype::GetTestViable() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline bool cGenotype::GetTestViable(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.is_viable;
 }
 
 
-inline double cGenotype::GetTestFitness() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline double cGenotype::GetTestFitness(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.fitness;
 }
 
 
-inline double cGenotype::GetTestMerit() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline double cGenotype::GetTestMerit(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.merit;
 }
 
 
-inline int cGenotype::GetTestGestationTime() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline int cGenotype::GetTestGestationTime(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.gestation_time;
 }
 
 
-inline int cGenotype::GetTestExecutedSize() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline int cGenotype::GetTestExecutedSize(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.executed_size;
 }
 
 
-inline int cGenotype::GetTestCopiedSize() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline int cGenotype::GetTestCopiedSize(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.copied_size;
 }
 
 
-inline double cGenotype::GetTestColonyFitness() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline double cGenotype::GetTestColonyFitness(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.colony_fitness;
 }
 
 
-inline int cGenotype::GetTestGenerations() const {
-  if (test_data.fitness == -1) CalcTestStats();
+inline int cGenotype::GetTestGenerations(cAvidaContext& ctx) const {
+  if (test_data.fitness == -1) CalcTestStats(ctx);
   return test_data.generations;
 }
 

Modified: development/source/classification/cLineage.cc
===================================================================
--- development/source/classification/cLineage.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cLineage.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -15,13 +15,13 @@
 using namespace std;
 
 
-bool gt_gentype::operator()(const cGenotype * g1, const cGenotype * g2) const
+bool gt_gentype::operator()(const cGenotype* g1, const cGenotype* g2) const
 {
   return g1->GetID() > g2->GetID();
 }
 
 cLineage::cLineage(double start_fitness, int parent_id, int id, int update,
-		   double generation,  double lineage_stat1, double lineage_stat2)
+                   double generation,  double lineage_stat1, double lineage_stat2)
   : m_id(id)
   , m_parent_id(parent_id)
   , m_update_born(update)
@@ -38,16 +38,15 @@
   m_threshold = false;
 }
 
-void cLineage::AddCreature(cGenotype * genotype)
+void cLineage::AddCreature(cAvidaContext& ctx, cGenotype* genotype)
 {
   // add the new genotype to the map if necessary, otherwise
   // find its position
-  pair<map<const cGenotype *, int, gt_gentype>::iterator, bool> p =
-    m_genotype_map.insert( pair<const cGenotype*, int>( genotype, 0 ) );
+  pair<map<const cGenotype*, int, gt_gentype>::iterator, bool> p =
+    m_genotype_map.insert(pair<const cGenotype*, int>(genotype, 0));
 
   // did we add a new genotype?
-  if ( ( p.second ) == true )
-    m_total_genotypes += 1;
+  if ((p.second) == true) m_total_genotypes += 1;
 
   // increase the count for the given genotype by one.
   (*(p.first)).second += 1;
@@ -56,14 +55,14 @@
   //     m_genotype_map[ genotype ] += 1;
   // if we didn't want to count how often we add a new genotype
 
-  double fitness = genotype->GetTestColonyFitness();
+  double fitness = genotype->GetTestColonyFitness(ctx);
 
   // adjust the current maximum fitness
-  if ( fitness > m_max_fitness )
-    m_max_fitness = fitness;
-   // adjust overall maxiumum fitness
-  if ( fitness> m_max_fitness_ever )
-    m_max_fitness_ever = fitness;
+  if (fitness > m_max_fitness) m_max_fitness = fitness;
+  
+  // adjust overall maxiumum fitness
+  if (fitness > m_max_fitness_ever) m_max_fitness_ever = fitness;
+  
   // the average fitness has changed as well
   m_ave_fitness_changed = true;
 
@@ -71,13 +70,13 @@
   m_total_CPUs++;
 }
 
-bool cLineage::RemoveCreature(cGenotype * genotype)
+bool cLineage::RemoveCreature(cAvidaContext& ctx, cGenotype* genotype)
 {
   // we return true if the removal of this creature triggers a
   // recalculation of the best lineage
   bool result = false;
 
-  map<const cGenotype *, int, gt_gentype>::iterator cur = m_genotype_map.find( genotype );
+  map<const cGenotype*, int, gt_gentype>::iterator cur = m_genotype_map.find(genotype);
 
   // is the genotype part of the map?
   if ( cur == m_genotype_map.end() ) {
@@ -90,14 +89,14 @@
   // and adjust the average fitness
   m_ave_fitness_changed = true;
 
-  double fitness = genotype->GetTestColonyFitness();
+  double fitness = genotype->GetTestColonyFitness(ctx);
 
   // did we reach zero?
-  if ( (*cur).second == 0 ){
+  if ((*cur).second == 0) {
     // yes, remove the entry
-    m_genotype_map.erase( cur );
+    m_genotype_map.erase(cur);
     // make sure that the maximum fitness is correct
-    if (fitness == m_max_fitness) CalcCurrentFitness();
+    if (fitness == m_max_fitness) CalcCurrentFitness(ctx);
     // adjust the return value
     result = true;
   }
@@ -112,30 +111,26 @@
 {
   int creature_count = 0;
 
-  map<const cGenotype *, int, gt_gentype>::const_iterator it =
-    m_genotype_map.begin();
+  map<const cGenotype*, int, gt_gentype>::const_iterator it = m_genotype_map.begin();
+  for (; it!=m_genotype_map.end(); it++) creature_count += (*it).second;
 
-  for ( ; it!=m_genotype_map.end(); it++ )
-    creature_count += (*it).second;
-
   return creature_count;
 }
 
-void cLineage::CalcCurrentFitness() const
+void cLineage::CalcCurrentFitness(cAvidaContext& ctx) const
 {
   m_max_fitness = 0.0;
-  map<const cGenotype *, int, gt_gentype>::const_iterator it =
-    m_genotype_map.begin();
+  map<const cGenotype*, int, gt_gentype>::const_iterator it = m_genotype_map.begin();
 
   // we calculate the average fitness as well, since it is so easy.
   m_ave_fitness = 0;
-  for ( ; it!=m_genotype_map.end(); it++ ){
-    double fitness = (*it).first->GetTestColonyFitness();
+  for (; it!=m_genotype_map.end(); it++) {
+    double fitness = (*it).first->GetTestColonyFitness(ctx);
     if (fitness > m_max_fitness) m_max_fitness = fitness;
     if (fitness > m_max_fitness_ever) m_max_fitness_ever = fitness;
     m_ave_fitness += fitness * (*it).second;
   }
-  m_ave_fitness /= (double) m_num_CPUs;
+  m_ave_fitness /= static_cast<double>(m_num_CPUs);
   m_ave_fitness_changed = false;
 }
 

Modified: development/source/classification/cLineage.h
===================================================================
--- development/source/classification/cLineage.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/classification/cLineage.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -13,15 +13,19 @@
 
 #include <map>
 
+class cAvidaContext;
 class cGenotype;
 
+
 // struct to compare to genotypes
 struct gt_gentype
 {
   bool operator()(const cGenotype * g1, const cGenotype * g2) const;
 };
 
-class cLineage {
+
+class cLineage
+{
 private:
   friend class cClassificationManager;
   
@@ -36,14 +40,14 @@
   mutable double m_ave_fitness;
   double m_generation_born;
 
-  std::map<const cGenotype *, int, gt_gentype> m_genotype_map;
+  std::map<const cGenotype*, int, gt_gentype> m_genotype_map;
   bool m_threshold;
   mutable bool m_ave_fitness_changed;
   mutable double m_max_fitness_ever;
   double m_lineage_stat1;
   double m_lineage_stat2;
 
-  void CalcCurrentFitness() const;
+  void CalcCurrentFitness(cAvidaContext& ctx) const;
 
   /**
     * Creates a new lineage with a given start fitness and parent id.
@@ -56,8 +60,7 @@
    * responsibility not to request two identical ones for different lineages
    * (the class @ref cLineageControl does that correctly).
    **/
-  cLineage(double start_fitness, int parent_id, int id,
-           int update, double generation,
+  cLineage(double start_fitness, int parent_id, int id, int update, double generation,
            double lineage_stat1 = 0.0, double lineage_stat2 = 0.0);
   
   cLineage(); // @not_implemented
@@ -67,10 +70,8 @@
 public:
   ~cLineage() { ; }
 
-  /**
-   * Adds one instance of the given genotype to the lineage.
-   **/
-  void AddCreature( cGenotype * genotype );
+  // Adds one instance of the given genotype to the lineage.
+  void AddCreature(cAvidaContext& ctx, cGenotype* genotype);
 
   /**
    * Removes on instance of the given genotype from the lineage.
@@ -78,55 +79,22 @@
    * @return True if the removal of this creature potentially creates a new
    * best lineage, otherwise false.
    **/
-  bool RemoveCreature( cGenotype * genotype );
+  bool RemoveCreature(cAvidaContext& ctx, cGenotype* genotype);
   void SetThreshold() { m_threshold = true; }
 
-  /**
-   * @return The id of the lineage.
-   **/
   int GetID() const { return m_id; }
-
-  /**
-   * @return The id of the parent lineage.
-   **/
   int GetParentID() const { return m_parent_id; }
-
-  /**
-   * @return The update at which the lineage was created.
-   **/
   int GetUpdateBorn() const { return m_update_born; }
-
-  /**
-   * @return The generation at which the lineage was created.
-   **/
   double GetGenerationBorn() const { return m_generation_born; }
-
-  /**
-   * @return The initial fitness of the lineage.
-   **/
   double GetStartFitness() const { return m_start_fitness; }
-
-  /**
-   * @return The current maximum fitness of the lineage.
-   **/
   double GetMaxFitness() const { return m_max_fitness; }
-  
-  /**
-   * @return The average fitness of the lineage.
-   **/
-  double GetAveFitness() const {
-    if ( m_ave_fitness_changed )
-      CalcCurrentFitness();
-    return m_ave_fitness; }
+  double GetAveFitness(cAvidaContext& ctx) const
+  {
+    if (m_ave_fitness_changed) CalcCurrentFitness(ctx);
+    return m_ave_fitness;
+  }
 
-  /**
-   * @return The current number of genotypes in the lineage.
-   **/
   int GetNumGenotypes() const { return m_genotype_map.size(); }
-
-  /**
-   * @return The current number of creatures in the lineage.
-   **/
   int GetNumCreatures() const { return m_num_CPUs; }
 
   /**

Modified: development/source/cpu/cHardwareBase.cc
===================================================================
--- development/source/cpu/cHardwareBase.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/cpu/cHardwareBase.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -255,7 +255,7 @@
   // this won't be an issue.
   if (phenotype.CopyTrue() == true) return false;
 	
-  const double parent_fitness = organism->GetTestFitness();
+  const double parent_fitness = organism->GetTestFitness(ctx);
   const double neut_min = parent_fitness * (1.0 - organism->GetNeutralMin());//nHardware::FITNESS_NEUTRAL_MIN;
   const double neut_max = parent_fitness * (1.0 + organism->GetNeutralMax());//nHardware::FITNESS_NEUTRAL_MAX;
   

Modified: development/source/event/cEventManager.cc
===================================================================
--- development/source/event/cEventManager.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/event/cEventManager.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -277,42 +277,7 @@
   }
 };
 
-///// analyze_population /////
 
-/**
-**/
-
-
-class cEvent_analyze_population : public cEvent {
-private:
-  double sample_prob;
-  int landscape;
-  int save_genotype;
-  cString filename;
-public:
-    const cString GetName() const { return "analyze_population"; }
-  const cString GetDescription() const { return "analyze_population  [double sample_prob=1] [int landscape=0] [int save_genotype=0] [string filename=\"\"]"; }
-  
-  void Configure(cWorld* world, const cString& in_args)
-  {
-    m_world = world;
-    m_args = in_args;
-    cString args(in_args);
-    if (args == "") sample_prob=1; else sample_prob=args.PopWord().AsDouble();
-    if (args == "") landscape=0; else landscape=args.PopWord().AsInt();
-    if (args == "") save_genotype=0; else save_genotype=args.PopWord().AsInt();
-    if (args == "") filename=""; else filename=args.PopWord();
-  }
-  ///// analyze_population /////
-  void Process(){
-    if (filename == "") filename.Set("population_info_%d.dat",m_world->GetStats().GetUpdate());
-    cAnalyzeUtil::AnalyzePopulation(m_world, m_world->GetDataFileOFStream(filename), sample_prob,
-                                    landscape, save_genotype);
-    m_world->GetDataFileManager().Remove(filename);
-  }
-};
-
-
 ///// task_snapshot /////
 
 /**
@@ -1445,7 +1410,6 @@
   REGISTER(mod_point_mut);
   REGISTER(set_point_mut);
   REGISTER(test_dom);
-  REGISTER(analyze_population);
 
   REGISTER(task_snapshot);
   REGISTER(print_viable_tasks_data);

Modified: development/source/main/cLandscape.cc
===================================================================
--- development/source/main/cLandscape.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/main/cLandscape.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -11,6 +11,7 @@
 #include "cLandscape.h"
 
 #include "cCPUMemory.h"
+#include "cDataFile.h"
 #include "cEnvironment.h"
 #include "cInstSet.h"
 #include "cHardwareManager.h"
@@ -850,6 +851,36 @@
   fp.flush();
 }
 
+void cLandscape::PrintStats(cDataFile& df, int update)
+{
+  df.Write(update, "Update");
+  df.Write(GetProbDead(), "Probability Lethal");
+  df.Write(GetProbNeg(), "Probability Deleterious");
+  df.Write(GetProbNeut(), "Probability Neutral");
+  df.Write(GetProbPos(), "Probability Beneficial");
+  df.Write(GetAvPosSize(), "Average Beneficial Size");
+  df.Write(GetAvNegSize(), "Average Deleterious Size");
+  df.Write(total_count, "Total Mutants");
+  df.Write(distance, "Distance");
+  df.Write(base_fitness, "Base Fitness");
+  df.Write(base_merit, "Base Merit");
+  df.Write(base_gestation, "Base Gestation");
+  df.Write(peak_fitness, "Peak Fitness");
+  df.Write(GetAveFitness(), "Average Fitness");
+  df.Write(GetAveSqrFitness(), "Average Square Fitness");
+  df.Write(total_entropy, "Total Entropy");
+  df.Write(complexity, "Total Complexity");
+  df.Write(GetProbEpiDead(), "Probability Lethal Epistasis");
+  df.Write(GetProbEpiPos(), "Probability Synergistic Epistasis");
+  df.Write(GetProbEpiNeg(), "Probability Antagonistic Epistasis");
+  df.Write(GetProbNoEpi(), "Probability No Epistasis");
+  df.Write(GetAvPosEpiSize(), "Average Synergistic Epistasis Size");
+  df.Write(GetAvNegEpiSize(), "Average Antagonistic Epistasis Size");
+  df.Write(GetAvNoEpiSize(), "Average Size - No Epistasis");
+  df.Write(total_epi_count, "Total Epistasis Count");
+  df.Endl();
+}
+
 void cLandscape::PrintEntropy(ofstream& fp)
 {
   double max_ent = log((double) inst_set.GetSize());

Modified: development/source/main/cLandscape.h
===================================================================
--- development/source/main/cLandscape.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/main/cLandscape.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -27,6 +27,7 @@
 #include <fstream>
 
 class cAvidaContext;
+class cDataFile;
 class cInstSet;
 class cInstruction;
 class cTestCPU;
@@ -131,6 +132,7 @@
   void HillClimb_Rand(cAvidaContext& ctx, std::ofstream& fp);
 
   void PrintStats(std::ofstream& fp, int update = -1);
+  void PrintStats(cDataFile& df, int update = -1);
   void PrintEntropy(std::ofstream& fp);
   void PrintSiteCount(std::ofstream& fp);
   void PrintBase(cString filename);

Modified: development/source/main/cOrganism.cc
===================================================================
--- development/source/main/cOrganism.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/main/cOrganism.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -99,10 +99,10 @@
 }
 
 
-double cOrganism::GetTestFitness()
+double cOrganism::GetTestFitness(cAvidaContext& ctx)
 {
   assert(m_interface);
-  return genotype->GetTestFitness();
+  return genotype->GetTestFitness(ctx);
 }
   
 int cOrganism::ReceiveValue()

Modified: development/source/main/cOrganism.h
===================================================================
--- development/source/main/cOrganism.h	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/main/cOrganism.h	2006-07-24 18:45:33 UTC (rev 853)
@@ -179,7 +179,7 @@
 		      
   int OK();
 
-  double GetTestFitness();
+  double GetTestFitness(cAvidaContext& ctx);
   double CalcMeritRatio();
 
   cCPUMemory& ChildGenome() { return child_genome; }

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2006-07-24 17:35:17 UTC (rev 852)
+++ development/source/main/cPopulation.cc	2006-07-24 18:45:33 UTC (rev 853)
@@ -880,7 +880,7 @@
 {
   // If we have some kind of lineage control, adjust the default values passed in.
   if (m_world->GetConfig().LOG_LINEAGES.Get()){
-    lin = m_world->GetClassificationManager().GetLineage(organism->GetGenotype(), parent_genotype, lin, lin_label);
+    lin = m_world->GetClassificationManager().GetLineage(m_world->GetDefaultContext(), organism->GetGenotype(), parent_genotype, lin, lin_label);
     lin_label = lin->GetID();
   }
   
@@ -1769,12 +1769,12 @@
   // Setup the phenotype...
   cPhenotype & phenotype = new_organism->GetPhenotype();
   phenotype.SetupInject(new_genotype->GetLength());
-  phenotype.SetMerit( cMerit(new_genotype->GetTestMerit()) );
+  phenotype.SetMerit( cMerit(new_genotype->GetTestMerit(ctx)) );
   
   // @CAO are these really needed?
-  phenotype.SetLinesCopied( new_genotype->GetTestCopiedSize() );
-  phenotype.SetLinesExecuted( new_genotype->GetTestExecutedSize() );
-  phenotype.SetGestationTime( new_genotype->GetTestGestationTime() );
+  phenotype.SetLinesCopied( new_genotype->GetTestCopiedSize(ctx) );
+  phenotype.SetLinesExecuted( new_genotype->GetTestExecutedSize(ctx) );
+  phenotype.SetGestationTime( new_genotype->GetTestGestationTime(ctx) );
   
   // Prep the cell..
   if (m_world->GetConfig().BIRTH_METHOD.Get() == POSITION_CHILD_FULL_SOUP_ELDEST &&
@@ -1843,7 +1843,7 @@
   if (ignore_deads == true) {
     for (int i = 0; i < GetSize(); i++) {
       cPopulationCell & cell = cell_array[i];
-      if (cell.IsOccupied() && cell.GetOrganism()->GetTestFitness() == 0.0) {
+      if (cell.IsOccupied() && cell.GetOrganism()->GetTestFitness(m_world->GetDefaultContext()) == 0.0) {
         KillOrganism(cell);
       }
     }




More information about the Avida-cvs mailing list