[Avida-SVN] r3134 - in branches/interrupt: . Avida.xcodeproj documentation source/actions source/analyze source/classification source/cpu source/main source/platform source/tools tests/energy_asex_1000u/config tests/energy_deme_level_res/config

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Jan 23 07:26:05 PST 2009


Author: beckma24
Date: 2009-01-23 10:26:04 -0500 (Fri, 23 Jan 2009)
New Revision: 3134

Added:
   branches/interrupt/source/analyze/cModularityAnalysis.cc
   branches/interrupt/source/analyze/cModularityAnalysis.h
   branches/interrupt/source/classification/cMutationSteps.cc
   branches/interrupt/source/classification/cMutationSteps.h
   branches/interrupt/source/platform/tRLockPtr.h
Modified:
   branches/interrupt/Avida.vcproj
   branches/interrupt/Avida.xcodeproj/project.pbxproj
   branches/interrupt/CMakeLists.txt
   branches/interrupt/build_avida
   branches/interrupt/documentation/actions.html
   branches/interrupt/source/actions/EnvironmentActions.cc
   branches/interrupt/source/actions/PopulationActions.cc
   branches/interrupt/source/actions/SaveLoadActions.cc
   branches/interrupt/source/analyze/cAnalyze.cc
   branches/interrupt/source/analyze/cAnalyze.h
   branches/interrupt/source/analyze/cAnalyzeGenotype.cc
   branches/interrupt/source/analyze/cAnalyzeGenotype.h
   branches/interrupt/source/classification/cClassificationManager.cc
   branches/interrupt/source/classification/cClassificationManager.h
   branches/interrupt/source/cpu/cCPUMemory.h
   branches/interrupt/source/cpu/cHardwareBase.cc
   branches/interrupt/source/cpu/cHardwareBase.h
   branches/interrupt/source/cpu/cHardwareCPU.cc
   branches/interrupt/source/cpu/cHardwareCPU.h
   branches/interrupt/source/cpu/cHardwareManager.cc
   branches/interrupt/source/main/cAvidaConfig.h
   branches/interrupt/source/main/cDeme.cc
   branches/interrupt/source/main/cDeme.h
   branches/interrupt/source/main/cEventList.cc
   branches/interrupt/source/main/cGenome.cc
   branches/interrupt/source/main/cGenome.h
   branches/interrupt/source/main/cPhenotype.cc
   branches/interrupt/source/main/cPopulation.cc
   branches/interrupt/source/main/cReactionRequisite.h
   branches/interrupt/source/main/cWorld.cc
   branches/interrupt/source/tools/cMerit.cc
   branches/interrupt/source/tools/cStringUtil.cc
   branches/interrupt/source/tools/cStringUtil.h
   branches/interrupt/source/tools/tArrayMap.h
   branches/interrupt/source/tools/tDataEntry.h
   branches/interrupt/source/tools/tKVPair.h
   branches/interrupt/source/tools/tRCPtr.h
   branches/interrupt/tests/energy_asex_1000u/config/avida.cfg
   branches/interrupt/tests/energy_deme_level_res/config/avida.cfg
Log:
Merged development

Modified: branches/interrupt/Avida.vcproj
===================================================================
--- branches/interrupt/Avida.vcproj	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/Avida.vcproj	2009-01-23 15:26:04 UTC (rev 3134)
@@ -457,6 +457,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\source\analyze\cGenotypeData.h"
+				>
+			</File>
+			<File
 				RelativePath=".\source\cpu\cHardwareBase.h"
 				>
 			</File>
@@ -613,6 +617,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\source\analyze\cModularityAnalysis.h"
+				>
+			</File>
+			<File
 				RelativePath=".\source\main\cMutation.h"
 				>
 			</File>
@@ -1289,6 +1297,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\source\analyze\cGenotypeData.cc"
+				>
+			</File>
+			<File
 				RelativePath=".\source\cpu\cHardwareBase.cc"
 				>
 			</File>
@@ -1405,6 +1417,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\source\analyze\cModularityAnalysis.cc"
+				>
+			</File>
+			<File
 				RelativePath=".\source\analyze\cMutationalNeighborhood.cc"
 				>
 			</File>

Modified: branches/interrupt/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/interrupt/Avida.xcodeproj/project.pbxproj	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/Avida.xcodeproj/project.pbxproj	2009-01-23 15:26:04 UTC (rev 3134)
@@ -23,6 +23,7 @@
 /* End PBXAggregateTarget section */
 
 /* Begin PBXBuildFile section */
+		10479F2E0F1BC54B00AF9F6A /* cMutationSteps.cc in Sources */ = {isa = PBXBuildFile; fileRef = 10479F2C0F1BC54B00AF9F6A /* cMutationSteps.cc */; };
 		2A57A3FF0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2A57A3FD0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc */; };
 		2A57A4000D6B954D00FC54C7 /* cProbDemeProbSchedule.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A57A3FE0D6B954D00FC54C7 /* cProbDemeProbSchedule.h */; };
 		5629D8110C3EE14800C5F152 /* cTextWindow.cc in Sources */ = {isa = PBXBuildFile; fileRef = 5629D80D0C3EE13500C5F152 /* cTextWindow.cc */; };
@@ -215,6 +216,7 @@
 		BB11B3150F1AD49D0056DDB9 /* cDriverStatusConduit.cc in Sources */ = {isa = PBXBuildFile; fileRef = BB11B3140F1AD49D0056DDB9 /* cDriverStatusConduit.cc */; };
 		BB723EEE0E7B4DE9004461EB /* cOrganismThread.h in Headers */ = {isa = PBXBuildFile; fileRef = BB723EEC0E7B4DE9004461EB /* cOrganismThread.h */; };
 		BB723EEF0E7B4DE9004461EB /* cOrganismThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BB723EED0E7B4DE9004461EB /* cOrganismThread.cpp */; };
+		BBCDD1E40F2A146C005F5AF7 /* cModularityAnalysis.cc in Sources */ = {isa = PBXBuildFile; fileRef = BBCDD1E30F2A146C005F5AF7 /* cModularityAnalysis.cc */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXBuildRule section */
@@ -368,6 +370,8 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		10479F2C0F1BC54B00AF9F6A /* cMutationSteps.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cMutationSteps.cc; sourceTree = "<group>"; };
+		10479F2D0F1BC54B00AF9F6A /* cMutationSteps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cMutationSteps.h; sourceTree = "<group>"; };
 		1097463D0AE9606E00929ED6 /* cDeme.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDeme.cc; sourceTree = "<group>"; };
 		1097463E0AE9606E00929ED6 /* cDeme.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDeme.h; sourceTree = "<group>"; };
 		2A57A3FD0D6B954D00FC54C7 /* cProbDemeProbSchedule.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cProbDemeProbSchedule.cc; sourceTree = "<group>"; };
@@ -393,6 +397,7 @@
 		7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPUInterface.cc; sourceTree = "<group>"; };
 		7005A70909BA0FBE0007E16E /* cOrgInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cOrgInterface.h; sourceTree = "<group>"; };
 		700AE91B09DB65F200A073FD /* cTaskContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTaskContext.h; sourceTree = "<group>"; };
+		700D9CB20F1C55EB002CC711 /* tRLockPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tRLockPtr.h; sourceTree = "<group>"; };
 		700E11BC0A0815B600B604CD /* cDataEntry.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDataEntry.cc; sourceTree = "<group>"; };
 		700E28CF0859FFD700CF158A /* tObjectFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tObjectFactory.h; sourceTree = "<group>"; };
 		700E2B83085DE50C00CF158A /* avida-viewer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "avida-viewer"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -882,6 +887,8 @@
 		BB11B3140F1AD49D0056DDB9 /* cDriverStatusConduit.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cDriverStatusConduit.cc; sourceTree = "<group>"; };
 		BB723EEC0E7B4DE9004461EB /* cOrganismThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cOrganismThread.h; sourceTree = "<group>"; };
 		BB723EED0E7B4DE9004461EB /* cOrganismThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cOrganismThread.cpp; sourceTree = "<group>"; };
+		BBCDD1E30F2A146C005F5AF7 /* cModularityAnalysis.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cModularityAnalysis.cc; sourceTree = "<group>"; };
+		BBCDD1E50F2A147D005F5AF7 /* cModularityAnalysis.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cModularityAnalysis.h; sourceTree = "<group>"; };
 		DCC30FCF0762539D008F7A48 /* Doxyfile */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = Doxyfile; sourceTree = "<group>"; };
 		DCC3109C0762539E008F7A48 /* avida.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = avida.cc; sourceTree = "<group>"; };
 		DCC31547076253A4008F7A48 /* cCycleCheck.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cCycleCheck.cc; sourceTree = "<group>"; };
@@ -1022,6 +1029,8 @@
 		70422A1B091B141000A5E67F /* analyze */ = {
 			isa = PBXGroup;
 			children = (
+				BBCDD1E50F2A147D005F5AF7 /* cModularityAnalysis.h */,
+				BBCDD1E30F2A146C005F5AF7 /* cModularityAnalysis.cc */,
 				BB11B2DD0F1AD3690056DDB9 /* cGenotypeData.h */,
 				BB11B2DE0F1AD3690056DDB9 /* tAnalyzeJobBatch.h */,
 				BB11B2D90F1AD35B0056DDB9 /* cGenotypeBatch.cc */,
@@ -1306,6 +1315,7 @@
 				70436B250C36C64000A05ABA /* platform.h */,
 				70436B260C36C64000A05ABA /* PlatformExpert.cc */,
 				70436B270C36C64000A05ABA /* PlatformExpert.h */,
+				700D9CB20F1C55EB002CC711 /* tRLockPtr.h */,
 			);
 			path = platform;
 			sourceTree = "<group>";
@@ -1357,6 +1367,8 @@
 				70F7DC9F09293E6F009E311D /* cGenotype.h */,
 				70F7DAEF09290468009E311D /* cClassificationManager.h */,
 				70F7DAF009290468009E311D /* cClassificationManager.cc */,
+				10479F2D0F1BC54B00AF9F6A /* cMutationSteps.h */,
+				10479F2C0F1BC54B00AF9F6A /* cMutationSteps.cc */,
 			);
 			path = classification;
 			sourceTree = "<group>";
@@ -2094,6 +2106,8 @@
 				BB11B2E40F1AD3AC0056DDB9 /* cRCObject.cc in Sources */,
 				BB11B2E50F1AD3AC0056DDB9 /* cUnitTestDemo.cc in Sources */,
 				BB11B3150F1AD49D0056DDB9 /* cDriverStatusConduit.cc in Sources */,
+				10479F2E0F1BC54B00AF9F6A /* cMutationSteps.cc in Sources */,
+				BBCDD1E40F2A146C005F5AF7 /* cModularityAnalysis.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: branches/interrupt/CMakeLists.txt
===================================================================
--- branches/interrupt/CMakeLists.txt	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/CMakeLists.txt	2009-01-23 15:26:04 UTC (rev 3134)
@@ -152,6 +152,7 @@
   ${CLASSIFICATION_DIR}/cInjectGenotypeControl.cc
   ${CLASSIFICATION_DIR}/cInjectGenotypeQueue.cc
   ${CLASSIFICATION_DIR}/cLineage.cc
+  ${CLASSIFICATION_DIR}/cMutationSteps.cc
   ${CLASSIFICATION_DIR}/cSpecies.cc
   ${CLASSIFICATION_DIR}/cSpeciesControl.cc
   ${CLASSIFICATION_DIR}/cSpeciesQueue.cc

Modified: branches/interrupt/build_avida
===================================================================
--- branches/interrupt/build_avida	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/build_avida	2009-01-23 15:26:04 UTC (rev 3134)
@@ -3,6 +3,6 @@
 mkdir -p cbuild
 cd cbuild
 cmake "$@" ../
-make -j
+make -j 10
 make install
 

Modified: branches/interrupt/documentation/actions.html
===================================================================
--- branches/interrupt/documentation/actions.html	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/documentation/actions.html	2009-01-23 15:26:04 UTC (rev 3134)
@@ -1224,8 +1224,9 @@
 </li>
 <li><p>
   <strong><a name="ModMutProb">ModMutProb</a></strong>
-  <i>[string mut_type="copy"] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]</i>
+  <i>[string mut_type="COPY_MUT"] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]</i>
   </p>
+    For a list of values for mut_type, see <a href="#SetMutProb">SetMutProb<a/>.
   <p>
   
   </p>
@@ -1322,8 +1323,15 @@
 </li>
 <li><p>
   <strong><a name="SetMutProb">SetMutProb</a></strong>
-  <i>[string mut_type="copy"] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]</i>
+  <i>[string mut_type="COPY_MUT"] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]</i>
   </p>
+    Values for mut_type are POINT, COPY_MUT, COPY_INS, COPY_DEL, COPY_UNIFORM, 
+  COPY_SLIP, DIV_MUT, DIV_INS, DIV_DEL, DIV_UNIFORM, DIV_SLIP, DIVIDE_MUT, 
+  DIVIDE_INS, DIVIDE_DEL, DIVIDE_UNIFORM, DIVIDE_SLIP, PARENT, INJECT_MUT, 
+  INJECT_INS, and INJECT_DEL.  These correspond to their counterparts in avida.cfg.
+  <br>
+  <br>
+  To turn off all mutations, use <a href="#ZeroMuts">ZeroMuts</a>.
   <p>
   
   </p>
@@ -1411,7 +1419,9 @@
   <i>No Arguments</i>
   </p>
   <p>
-    This event will set all mutation rates to zero.
+    This event will set all mutation rates to zero.  That is, it will set all
+    cell mutation rates to zero, so that new organisms born will have zero mutation
+    rates.  Current organsims will not be affected, and may still mutate.
 
   </p>
 </li>

Modified: branches/interrupt/source/actions/EnvironmentActions.cc
===================================================================
--- branches/interrupt/source/actions/EnvironmentActions.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/actions/EnvironmentActions.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -683,7 +683,7 @@
   
   void Process(cAvidaContext& ctx)
   {
-    m_world->GetConfig().NUM_INST_EXC_BEFORE_0_ENERGY.Set(newValue);
+    m_world->GetConfig().NUM_CYCLES_EXC_BEFORE_0_ENERGY.Set(newValue);
   }
 };
 

Modified: branches/interrupt/source/actions/PopulationActions.cc
===================================================================
--- branches/interrupt/source/actions/PopulationActions.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/actions/PopulationActions.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -1062,7 +1062,7 @@
     if (m_end > m_world->GetPopulation().GetSize()) m_end = m_world->GetPopulation().GetSize();
   }
   
-  static const cString GetDescription() { return "Arguments: [string mut_type='copy'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]"; }
+  static const cString GetDescription() { return "Arguments: [string mut_type='COPY_MUT'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]"; }
   
   void Process(cAvidaContext& ctx)
   {
@@ -1194,7 +1194,7 @@
       if (m_end > m_world->GetPopulation().GetSize()) m_end = m_world->GetPopulation().GetSize();
   }
   
-  static const cString GetDescription() { return "Arguments: [string mut_type='copy'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]"; }
+  static const cString GetDescription() { return "Arguments: [string mut_type='COPY_MUT'] [double prob=0.0] [int start_cell=-1] [int end_cell=-1]"; }
   
   void Process(cAvidaContext& ctx)
   {
@@ -1658,7 +1658,7 @@
 	}
 
 	virtual double Fitness(const cDeme& deme) {
-		double fitness = deme.GetCurTaskExeCount()[_task_num]^2;///deme.GetInjectedCount());
+		double fitness = pow(deme.GetCurTaskExeCount()[_task_num], 2.0);///deme.GetInjectedCount());
     if (fitness == 0.0) fitness = 0.1;
     return fitness;
 	}
@@ -1708,6 +1708,58 @@
 };
 
 
+class cActionCompeteDemesByEnergyDistribution : public cAbstractCompeteDemes {
+private:
+
+public:
+	cActionCompeteDemesByEnergyDistribution(cWorld* world, const cString& args) : cAbstractCompeteDemes(world, args) {}
+	~cActionCompeteDemesByEnergyDistribution() {}
+	
+	static const cString GetDescription() { 
+		return "Competes demes according to the distribution of energy among the organisms"; 
+	}
+	
+	virtual double Fitness(const cDeme& deme) {
+		const int numcells = deme.GetSize();
+		
+		double min_energy = -1;
+		double max_energy = -1;
+		double current_energy;
+		double fitness;
+		
+		cOrganism *org;
+		
+		for(int cellid = 0; cellid < numcells; cellid++) {
+			org = deme.GetOrganism(cellid);
+			fitness = 0.0001;
+			
+			if (org != 0) {
+				current_energy = org->GetPhenotype().GetStoredEnergy();
+				
+				if((min_energy == -1) || (current_energy < min_energy)) {
+					min_energy = current_energy;
+				}
+				
+				if((max_energy == -1) || (current_energy > max_energy)) {
+					max_energy = current_energy;
+				}
+			}
+		}
+		
+		if((min_energy == -1) || (max_energy == -1)) {
+			fitness = 0.0001;
+		} else if (min_energy == max_energy) {
+			fitness = 100 * max_energy;
+		} else {
+			fitness = 100 * (max_energy/pow((max_energy - min_energy),2));
+		}
+				
+		return fitness;
+	}
+};
+
+
+
 /*! Send an artificial flash to a single organism in each deme in the population
  at a specified period.
  
@@ -2641,6 +2693,7 @@
 
   action_lib->Register<cActionCompeteDemesByTaskCount>("CompeteDemesByTaskCount");
   action_lib->Register<cActionCompeteDemesByTaskCountAndEfficiency>("CompeteDemesByTaskCountAndEfficiency");
+  action_lib->Register<cActionCompeteDemesByEnergyDistribution>("CompeteDemesByEnergyDistribution");	
 
   // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
   action_lib->Register<cActionInject>("inject");

Modified: branches/interrupt/source/actions/SaveLoadActions.cc
===================================================================
--- branches/interrupt/source/actions/SaveLoadActions.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/actions/SaveLoadActions.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -171,13 +171,19 @@
 class cActionSavePopulation : public cAction
 {
 private:
+  bool m_print_mut_steps;
   cString m_filename;
   
 public:
-  cActionSavePopulation(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+  cActionSavePopulation(cWorld* world, const cString& args) : cAction(world, args), m_print_mut_steps(0), m_filename("")
   {
     cString largs(args);
     if (largs.GetSize()) m_filename = largs.PopWord();
+    if (m_filename == "mut_steps") {
+      m_print_mut_steps = 1;
+      m_filename = "";    
+      if (largs.GetSize()) m_filename = largs.PopWord();
+    }
   }
   
   static const cString GetDescription() { return "Arguments: [string fname='']"; }
@@ -186,7 +192,7 @@
   {
     cString filename(m_filename);
     if (filename == "") filename.Set("detail-%d.pop", m_world->GetStats().GetUpdate());
-    m_world->GetClassificationManager().DumpDetailedSummary(m_world->GetDataFileOFStream(filename));
+    m_world->GetClassificationManager().DumpDetailedSummary(m_world->GetDataFileOFStream(filename), m_print_mut_steps);
     m_world->GetDataFileManager().Remove(filename);
   }
 };
@@ -264,15 +270,23 @@
 {
 private:
   int m_backdist;
+  bool m_print_mut_steps;
   cString m_filename;
   
+  
 public:
   cActionSaveHistoricPopulation(cWorld* world, const cString& args)
-    : cAction(world, args), m_backdist(-1), m_filename("")
+    : cAction(world, args), m_backdist(-1), m_print_mut_steps(0), m_filename("")
   {
     cString largs(args);
     if (largs.GetSize()) m_backdist = largs.PopWord().AsInt();
     if (largs.GetSize()) m_filename = largs.PopWord();
+    if (m_filename == "mut_steps") {
+      m_print_mut_steps = 1;    
+      m_filename = "";    
+      if (largs.GetSize()) m_filename = largs.PopWord();
+    }
+
   }
   
   static const cString GetDescription() { return "Arguments: [int back_dist=-1] [string fname='']"; }
@@ -281,7 +295,7 @@
   {
     cString filename(m_filename);
     if (filename == "") filename.Set("historic-%d.pop", m_world->GetStats().GetUpdate());
-    m_world->GetClassificationManager().DumpHistoricSummary(m_world->GetDataFileOFStream(filename), m_backdist);
+    m_world->GetClassificationManager().DumpHistoricSummary(m_world->GetDataFileOFStream(filename), m_backdist, m_print_mut_steps);
     m_world->GetDataFileManager().Remove(filename);
   }
 };

Modified: branches/interrupt/source/analyze/cAnalyze.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyze.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/analyze/cAnalyze.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -55,6 +55,7 @@
 #include "cInitFile.h"
 #include "cInstSet.h"
 #include "cLandscape.h"
+#include "cModularityAnalysis.h"
 #include "cPhenotype.h"
 #include "cPhenPlastGenotype.h"
 #include "cPlasticPhenotype.h"
@@ -70,6 +71,7 @@
 #include "cWorld.h"
 #include "cWorldDriver.h"
 #include "tAnalyzeJob.h"
+#include "tAnalyzeJobBatch.h"
 #include "tDataCommandManager.h"
 #include "tDataEntry.h"
 #include "tDataEntryCommand.h"
@@ -899,7 +901,7 @@
   }
   
   const cString filetype = input_file.GetFiletype();
-  if (filetype != "population_data" &&  // Depricated
+  if (filetype != "population_data" &&  // Deprecated
       filetype != "genotype_data") {
     cerr << "Error: Cannot load files of type \"" << filetype << "\"." << endl;
     if (exit_on_error) exit(1);
@@ -4922,6 +4924,23 @@
   }
 }
 
+void cAnalyze::CommandCalcFunctionalModularity(cString cur_string)
+{
+  cout << "Calculating Functional Modularity..." << endl;
+
+  tList<cModularityAnalysis> mod_list;
+  tAnalyzeJobBatch<cModularityAnalysis> jobbatch(m_jobqueue);
+  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+  for (cAnalyzeGenotype* cur_genotype = batch_it.Next(); cur_genotype; cur_genotype = batch_it.Next()) {
+    cModularityAnalysis* mod = new cModularityAnalysis(cur_genotype);
+    mod_list.Push(mod);
+    jobbatch.AddJob(mod, &cModularityAnalysis::CalcFunctionalModularity);
+  }
+  jobbatch.RunBatch();
+  cModularityAnalysis* mod = NULL;
+  while ((mod = mod_list.Pop())) delete mod;
+}
+
 void cAnalyze::CommandAverageModularity(cString cur_string)
 {
   cout << "Average Modularity calculations" << endl;
@@ -6198,7 +6217,6 @@
 {
   // Align does not need any args yet.
   (void) cur_string;
-  int perform_slow_alignment = (cur_string.GetSize()) ? cur_string.PopWord().AsInt() : 0;
   
   cout << "Aligning sequences..." << endl;
   
@@ -6224,28 +6242,7 @@
     int num_del = 0;
     
     // Compare each string to the previous.
-    if (perform_slow_alignment == 0) {
-      cStringUtil::EditDistance(sequences[i], sequences[i-1], diff_info, '_');
-    }
-    else
-    if (perform_slow_alignment == 1) {
-      cStringUtil::GapMinimizingEditDistance(sequences[i], sequences[i-1], diff_info, '_');
-    }
-    else {
-      cString best_diff_info;
-      int min_dist = -1;
-      for (int j=0; j<i; j++) {
-        cString test_diff_info;
-        int test_dist = cStringUtil::GapMinimizingEditDistance(sequences[i], sequences[j], test_diff_info, '_');
-        if (min_dist == -1 || test_dist < min_dist) {
-          min_dist = test_dist;
-          best_diff_info = test_diff_info;
-          if (min_dist == 0) j=i;
-        }
-      }
-      
-       diff_info = best_diff_info;
-    }
+    cStringUtil::EditDistance(sequences[i], sequences[i-1], diff_info, '_');
     
     while (diff_info.GetSize() != 0) {
       cString cur_mut = diff_info.Pop(',');
@@ -9244,6 +9241,7 @@
   AddLibraryDef("MAP", &cAnalyze::CommandMapTasks);  // Deprecated...
   AddLibraryDef("MAP_TASKS", &cAnalyze::CommandMapTasks);
   AddLibraryDef("AVERAGE_MODULARITY", &cAnalyze::CommandAverageModularity);
+  AddLibraryDef("CALC_FUNCTIONAL_MODULARITY", &cAnalyze::CommandCalcFunctionalModularity);
   AddLibraryDef("ANALYZE_REDUNDANCY_BY_INST_FAILURE", &cAnalyze::CommandAnalyzeRedundancyByInstFailure);
   AddLibraryDef("MAP_MUTATIONS", &cAnalyze::CommandMapMutations);
   AddLibraryDef("ANALYZE_COMPLEXITY", &cAnalyze::AnalyzeComplexity);

Modified: branches/interrupt/source/analyze/cAnalyze.h
===================================================================
--- branches/interrupt/source/analyze/cAnalyze.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/analyze/cAnalyze.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -260,6 +260,7 @@
   // Individual Organism Analysis...
   void CommandFitnessMatrix(cString cur_string);
   void CommandMapTasks(cString cur_string);
+  void CommandCalcFunctionalModularity(cString cur_string);
   void CommandAverageModularity(cString cur_string);
   void CommandAnalyzeModularity(cString cur_string);
   void CommandAnalyzeRedundancyByInstFailure(cString cur_string);

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -45,7 +45,7 @@
 #include "tArray.h"
 #include "tAutoRelease.h"
 #include "tDataCommandManager.h"
-#include "tDMSingleton.h"w
+#include "tDMSingleton.h"
 
 
 #include <cmath>
@@ -295,9 +295,12 @@
   ADD_GDATA(double (), "phen_likely_freq",   "Freq of Most Likely Phenotype",         GetLikelyFrequency,        SetNULL, 0, 0, 0);
   ADD_GDATA(double (), "phen_likely_fitness","Fitness of Most Likely Phenotype",      GetLikelyFitness,          SetNULL, 0, 0, 0);
   
+  // @JEB There is a difference between these two. parent_muts is based on an alignment. mut_steps is based on recorded mutations during run.
   ADD_GDATA(const cString& (), "parent_muts", "Mutations from Parent", GetParentMuts,   SetParentMuts, 0, "(none)", "");
+  ADD_GDATA(const cString (), "mut_steps", "Mutation Steps from Parent", GetMutSteps,   SetMutSteps,   0, "", "");
+
   ADD_GDATA(const cString& (), "task_order", "Task Performance Order", GetTaskOrder,    SetTaskOrder,  0, "(none)", "");
-  ADD_GDATA(cString (),        "sequence",    "Genome Sequence",               GetSequence,     SetSequence,   0, "(N/A)", "");
+  ADD_GDATA(cString (),        "sequence", "Genome Sequence",               GetSequence,     SetSequence,   0, "(N/A)", "");
   ADD_GDATA(const cString& (), "alignment", "Aligned Sequence",        GetAlignedSequence, SetAlignedSequence, 0, "(N/A)", "");
   
   ADD_GDATA(cString (), "executed_flags", "Executed Flags",             GetExecutedFlags, SetNULL, 0, "(N/A)", "");
@@ -328,13 +331,13 @@
   ADD_GDATA(int (),     "dom_depth",    "Tree Depth of Dominant Genotype", GetDepth,      SetDepth,      0, 0, 0);
   ADD_GDATA(int (),     "dom_id",       "Dominant Genotype ID",            GetID,         SetID,         0, 0, 0);
   ADD_GDATA(cString (), "dom_sequence", "Dominant Genotype Sequence",      GetSequence,   SetSequence,   0, "(N/A)", "");
+
   
-  
   return dcm;
 #undef ADD_GDATA
 }
 
-const tDataCommandManager<cAnalyzeGenotype>& cAnalyzeGenotype::GetDataCommandManager()
+tDataCommandManager<cAnalyzeGenotype>& cAnalyzeGenotype::GetDataCommandManager()
 {
   return tDMSingleton<tDataCommandManager<cAnalyzeGenotype> >::GetInstance();
 }
@@ -347,7 +350,19 @@
 }
 
 
+cAnalyzeGenotype::sGenotypeDatastore::~sGenotypeDatastore()
+{
+  for (tArrayMap<int, cGenotypeData*>::iterator it = dmap.begin(); it != dmap.end(); it++) delete it->Value();
+}
 
+void cAnalyzeGenotype::SetGenotypeData(int data_id, cGenotypeData* data)
+{
+  m_data->rwlock.WriteLock();
+  m_data->dmap.Set(data_id, data);
+  m_data->rwlock.WriteUnlock();
+}
+
+
 int cAnalyzeGenotype::CalcMaxGestation() const
 {
   return m_world->GetConfig().TEST_CPU_TIME_MOD.Get() * genome.GetSize();
@@ -600,6 +615,7 @@
     efficiency_ratio = GetEfficiency() / parent_genotype->GetEfficiency();
     comp_merit_ratio = GetCompMerit() / parent_genotype->GetCompMerit();
     parent_dist = cStringUtil::EditDistance(genome.AsString(), parent_genotype->GetGenome().AsString(), parent_muts);
+ 
     ancestor_dist = parent_genotype->GetAncestorDist() + parent_dist;
   }
 

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -103,6 +103,7 @@
 
 class cAnalyzeGenotype
 {
+  friend class ReadToken;
 private:
   cWorld* m_world;
   cGenome genome;            // Full Genome
@@ -112,12 +113,12 @@
   struct sGenotypeDatastore : public cRCObject
   {
     cRWLock rwlock;
-    tArrayMap<int, cGenotypeData*> dmap;
+    mutable tArrayMap<int, cGenotypeData*> dmap;
     
     sGenotypeDatastore() { ; }
     sGenotypeDatastore(const sGenotypeDatastore& ds) : cRCObject(ds) { ; } // Note that data objects are not copied right now
     
-    ~sGenotypeDatastore() { ; }
+    ~sGenotypeDatastore();
   };
   tRCPtr<sGenotypeDatastore> m_data;
   
@@ -254,8 +255,15 @@
   ~cAnalyzeGenotype();
   
   static void Initialize();
-  static const tDataCommandManager<cAnalyzeGenotype>& GetDataCommandManager();
+  static tDataCommandManager<cAnalyzeGenotype>& GetDataCommandManager();
+  
+  class ReadToken;
+  ReadToken* GetReadToken() const { m_data->rwlock.ReadLock(); return new ReadToken(this); }
 
+  void SetGenotypeData(int data_id, cGenotypeData* data);
+  cGenotypeData* GetGenotypeData(ReadToken* tk, int data_id) const { tk->Validate(this); return m_data->dmap.Get(data_id, NULL); }
+  
+
   void Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info = NULL, cAnalyzeGenotype* parent_genotype = NULL, int num_trials = 1);
   void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);
   void PrintTasksQuality(std::ofstream& fp, int min_task = 0, int max_task = -1);
@@ -294,6 +302,8 @@
   void SetLineageLabel(int _label) { lineage_label = _label; }
 
   void SetParentMuts(const cString & in_muts) { parent_muts = in_muts; }
+  void SetMutSteps(const cString in_muts) { genome.GetMutationSteps().Set(in_muts); }
+  
   void SetTaskOrder(const cString & in_order) { task_order = in_order; }
 
   // A set of NULL accessors to simplyfy automated accesses.
@@ -305,6 +315,8 @@
   void SetNULL(cString dummy) { (void) dummy; }
 
   // Accessors...
+  cWorld* GetWorld() { return m_world; }
+  
   const cGenome & GetGenome() const { return genome; }
   const cString& GetName() const { return name; }
   const cInstSet& GetInstructionSet() const { return m_inst_set; }
@@ -342,6 +354,7 @@
   int GetDepth() const { return depth; }
 
   const cString& GetParentMuts() const { return parent_muts; }
+  const cString GetMutSteps() const { const cMutationSteps& ms = genome.GetMutationSteps(); return ms.AsString(); }
 
   // Knockout accessors
   int GetKO_DeadCount() const;
@@ -515,6 +528,25 @@
       return false;
     }
   }
+  
+  
+  class ReadToken
+  {
+    friend class cAnalyzeGenotype;
+  private:
+    const cAnalyzeGenotype* m_ptr;
+
+    ReadToken(const ReadToken&); // @not_implemented
+    ReadToken& operator=(const ReadToken&); // @not_implemented
+
+    inline ReadToken(const cAnalyzeGenotype* ptr) : m_ptr(ptr) { ; }
+    
+    inline void Validate(const cAnalyzeGenotype* ptr) { assert(ptr == m_ptr); }
+    
+  public:
+    ~ReadToken() { m_ptr->m_data->rwlock.ReadUnlock(); }
+  };
+    
 };
 
 #endif

Added: branches/interrupt/source/analyze/cModularityAnalysis.cc
===================================================================
--- branches/interrupt/source/analyze/cModularityAnalysis.cc	                        (rev 0)
+++ branches/interrupt/source/analyze/cModularityAnalysis.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -0,0 +1,337 @@
+/*
+ *  cModularityAnalysis.cc
+ *  Avida
+ *
+ *  Created by David on 1/11/09.
+ *  Copyright 2009 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include "cModularityAnalysis.h"
+
+#include "cAnalyzeGenotype.h"
+#include "cOrganism.h"
+#include "cPhenotype.h"
+#include "tDataCommandManager.h"
+#include "tDataEntry.h"
+
+static const int MD_ID = 1;
+
+void cModularityAnalysis::Initialize()
+{
+  tDataCommandManager<cAnalyzeGenotype>& dcm = cAnalyzeGenotype::GetDataCommandManager();
+  // A basic macro to link a keyword to a description and Get and Set methods in cAnalyzeGenotype.
+#define ADD_GDATA(KEYWORD, DESC, GET, COMP) \
+  dcm.Add(KEYWORD, new tDataEntryProxy<cAnalyzeGenotype, cFlexVar ()> \
+    (KEYWORD, DESC, &cModularityAnalysis::GET, COMP));
+#define ADD_GDATA_IDX(KEYWORD, DESC, GET, COMP) \
+  dcm.Add(KEYWORD, new tDataEntryProxy<cAnalyzeGenotype, cFlexVar (int)> \
+    (KEYWORD, &cModularityAnalysis::DESC, &cModularityAnalysis::GET, COMP));
+
+  ADD_GDATA("tasks_done", "Number of Tasks Performed", GetTasksDoneFor, 2);
+  ADD_GDATA("insts_tasks", "Number of Instructions Involved in Tasks", GetInstsInvolvedInTasksFor, 1);
+  ADD_GDATA("tasks_prop", "Proportion of Sites in Tasks", GetTaskProportionFor, 4);
+  ADD_GDATA("ave_tasks_per_site", "Average Number of Tasks Per Site", GetAveTasksPerSiteFor, 6);
+  ADD_GDATA("ave_sites_per_task", "Average Number of Sites Per Task", GetAveSitesPerTaskFor, 6);
+  ADD_GDATA("ave_prop_nonoverlap", "Average Proportion of the Non-overlapping Region of a Task", GetTaskProportionFor, 4);
+  ADD_GDATA_IDX("sites_per_task", DescSitesPerTask, GetSitesPerTaskFor, 1);
+  ADD_GDATA_IDX("sites_inv_x_tasks", DescSitesInvolvedInXTasks, GetSitesInvolvedInXTasksFor, 1);
+  ADD_GDATA_IDX("task_length", DescTaskLength, GetTaskLengthFor, 4);
+  ADD_GDATA_IDX("ave_task_position", DescAveTaskPosition, GetAveTaskPositionFor, 4);  
+}
+
+void cModularityAnalysis::CalcFunctionalModularity(cAvidaContext& ctx)
+{
+  cTestCPU* testcpu = m_genotype->GetWorld()->GetHardwareManager().CreateTestCPU();
+  cCPUTestInfo test_info;
+
+  const cGenome& base_genome = m_genotype->GetGenome();
+
+  // Calculate the stats for the genotype we're working with...
+  testcpu->TestGenome(ctx, test_info, base_genome);  
+  double base_fitness = test_info.GetColonyFitness();
+  
+  // Check if the organism does any tasks
+  bool does_tasks = false;
+  const tArray<int> base_tasks = test_info.GetColonyOrganism()->GetPhenotype().GetLastTaskCount();
+  const int num_tasks = base_tasks.GetSize();
+  for (int i = 0; i < num_tasks; i++) {
+    if (base_tasks[i] > 0) {
+      does_tasks = true;
+      break;
+    }
+  }
+  
+  // Don't calculate the modularity if the organism doesn't reproduce. i.e. if the fitness is 0
+  if (base_fitness > 0.0 && does_tasks) {
+    // Set up the instruction set for mapping
+    cInstSet map_inst_set(m_genotype->GetInstructionSet());
+    const cInstruction null_inst = map_inst_set.ActivateNullInst();
+    test_info.SetInstSet(&map_inst_set);
+
+    // Genome for testing
+    const int max_line = base_genome.GetSize();
+    cGenome mod_genome(base_genome);
+    
+    // Create and initialize the modularity matrix
+    tMatrix<int> mod_matrix(num_tasks, max_line);
+    mod_matrix.SetAll(0);
+    
+    tArray<int> site_num_tasks(max_line, 0);  // number of tasks instruction is used in
+    tArray<int> sites_per_task(num_tasks, 0); // number of sites involved in each task
+    
+    // Loop through all the lines of code, testing the removal of each.
+    for (int line_num = 0; line_num < max_line; line_num++) {
+      int cur_inst = base_genome[line_num].GetOp();
+      
+      mod_genome.SetInst(line_num, null_inst, false);
+      
+      // Run the modified genome through the Test CPU
+      testcpu->TestGenome(ctx, test_info, mod_genome);
+      
+      if (test_info.GetColonyFitness() > 0.0) {
+        const tArray<int>& test_tasks = test_info.GetColonyOrganism()->GetPhenotype().GetLastTaskCount();
+        
+        for (int cur_task = 0; cur_task < num_tasks; cur_task++) {
+          // This is done so that under 'binary' option it marks
+          // the task as being influenced by the mutation iff
+          // it is completely knocked out, not just decreased
+          if (base_tasks[cur_task] && !test_tasks[cur_task]) {
+            // If knocking out an instruction stops the expression of a particular task, mark that in the modularity matrix
+            // and add it to two counts
+            mod_matrix(cur_task, line_num) = 1;
+            sites_per_task[cur_task]++;
+            site_num_tasks[line_num]++;
+          }
+        }
+      }
+          
+      // Reset the mod_genome back to the original sequence.
+      mod_genome.SetOp(line_num, cur_inst);
+    }
+    
+    tArray<int> sites_inv_x_tasks(num_tasks + 1, 0);  // # of inst's involved in 0,1,2,3... tasks    
+    tArray<double> ave_task_position(num_tasks, 0.0); // mean positions of the tasks in the genome
+    tArray<int> task_length(num_tasks, 0);  // distance between first and last inst involved in a task
+ 
+    int total_task = 0;           // total number of tasks done
+    int total_inst = 0;           // total number of instructions involved in tasks
+    int total_all = 0;            // sum of mod_matrix
+    double sum_task_overlap = 0;  // sum of task overlap for for this genome
+
+
+    // Calculate instruction and task totals
+    for (int i = 0; i < num_tasks; i++) {
+      total_all += sites_per_task[i];
+      if (sites_per_task[i]) total_task++;
+    }
+    for (int i = 0; i < max_line; i++) {
+      sites_inv_x_tasks[site_num_tasks[i]]++;
+      if (site_num_tasks[i] != 0) total_inst++;
+    }
+    
+    
+    // Calculate average task overlap
+    // first construct num_task x num_task matrix with number of sites overlapping
+    tMatrix<int> task_overlap(num_tasks, num_tasks);
+    task_overlap.SetAll(0);
+
+    for (int i = 0; i < max_line; i++) {
+      for (int j = 0; j < num_tasks; j++) {
+        for (int k = j; k < num_tasks; k++) {
+          if (mod_matrix(j, i) > 0 && mod_matrix(k, i) > 0) {
+            task_overlap(j, k)++;
+            if (j != k) task_overlap(k, j)++;
+          }               
+        }
+      }
+    }
+    
+    // go though the task_overlap matrix, add and average everything up. 
+    if (total_task > 1) {
+      for (int i = 0; i < num_tasks; i++) {
+        if (task_overlap(i, i)) {
+          int overlap_per_task = 0;
+          for (int j = 0; j < num_tasks; j++) if (i != j) overlap_per_task += task_overlap(i,j);
+          sum_task_overlap += (double)overlap_per_task / (task_overlap(i, i) * (total_task - 1));
+        }
+      }
+    }
+    
+    
+    // Calculate the first/last position of a task, the task "spread"
+    // starting from the top look for the fist command that matters for a task
+    for (int i = 0; i < num_tasks; i++) { 
+      for (int j = 0; j < max_line; j++) {
+        if (mod_matrix(i, j) > 0 && task_length[i] == 0) {
+          task_length[i] = j;
+          break;
+        }
+      }
+    }
+    
+    // starting from the bottom look for the last command that matters for a task
+    // and subtract it from the first to get the task length
+    // add one in order to account for both the beginning and the end instruction
+    for (int i = 0; i < num_tasks; i++) {
+      for (int j = max_line - 1; j >= 0; j--) {
+        if (mod_matrix(i, j) > 0) {
+          task_length[i] = j - task_length[i] + 1;
+          break;
+        }
+      }
+    }
+    
+    
+    // Calculate mean positions of the tasks
+    tArray<int> task_position(num_tasks);
+    for (int i = 0; i < num_tasks; i++) {
+      task_position[i] = 0;
+      for (int j = 0; j < max_line; j++) if (mod_matrix(i,j) > 0) task_position[i] += j;
+    }
+    for (int i = 0; i < num_tasks; i++) ave_task_position[i] = (double)task_position[i] / sites_per_task[i];
+    
+    
+    cModularityData* mod_data = new cModularityData;
+    mod_data->tasks_done = total_task;
+    mod_data->insts_tasks = total_inst;
+    mod_data->tasks_prop = (double)total_inst / max_line;
+    mod_data->ave_tasks_per_site = (total_inst) ? (double)total_all / total_inst : 0.0;
+    mod_data->ave_sites_per_task = (total_task) ? (double)total_all / total_task : 0.0;
+    mod_data->ave_prop_nonoverlap = (total_task) ? sum_task_overlap / total_task : 0.0;
+    mod_data->sites_per_task = sites_per_task;
+    mod_data->sites_inv_x_tasks = sites_inv_x_tasks;
+    mod_data->task_length = task_length;
+    mod_data->ave_task_position = ave_task_position;
+    m_genotype->SetGenotypeData(MD_ID, mod_data);
+  }
+}
+
+#ifdef DEBUG
+#define GET_MD() \
+  cAnalyzeGenotype::ReadToken* tok = genotype->GetReadToken(); \
+  cModularityData* data = dynamic_cast<cModularityData*>(genotype->GetGenotypeData(tok, MD_ID)); \
+  delete tok;
+#else
+#define GET_MD() \
+  cAnalyzeGenotype::ReadToken* tok = genotype->GetReadToken(); \
+  cModularityData* data = static_cast<cModularityData*>(genotype->GetGenotypeData(tok, MD_ID)); \
+  delete tok;
+#endif
+
+cFlexVar cModularityAnalysis::GetTasksDoneFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->tasks_done);
+  return cFlexVar(0);
+}
+
+cFlexVar cModularityAnalysis::GetInstsInvolvedInTasksFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->insts_tasks);
+  return cFlexVar(0);
+}
+
+cFlexVar cModularityAnalysis::GetTaskProportionFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->tasks_prop);
+  return cFlexVar(0.0);
+}
+
+cFlexVar cModularityAnalysis::GetAveTasksPerSiteFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->ave_tasks_per_site);
+  return cFlexVar(0.0);
+}
+
+cFlexVar cModularityAnalysis::GetAveSitesPerTaskFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->ave_sites_per_task);
+  return cFlexVar(0.0);
+}
+
+cFlexVar cModularityAnalysis::GetPropNonoverlapFor(const cAnalyzeGenotype* genotype)
+{
+  GET_MD();
+  if (data) return cFlexVar(data->ave_prop_nonoverlap);
+  return cFlexVar(0.0);
+}
+
+
+cFlexVar cModularityAnalysis::GetSitesPerTaskFor(const cAnalyzeGenotype* genotype, int idx)
+{
+  GET_MD();
+  if (data && idx >= 0 && idx < data->sites_per_task.GetSize()) return cFlexVar(data->sites_per_task[idx]);
+  return cFlexVar(0);
+}
+
+cString cModularityAnalysis::DescSitesPerTask(const cAnalyzeGenotype* genotype, int idx)
+{
+  return cStringUtil::Stringf("Number of Sites Per Task %d", idx);
+}
+
+
+cFlexVar cModularityAnalysis::GetSitesInvolvedInXTasksFor(const cAnalyzeGenotype* genotype, int idx)
+{
+  GET_MD();
+  if (data && idx >= 0 && idx < data->sites_per_task.GetSize()) return cFlexVar(data->sites_inv_x_tasks[idx]);
+  return cFlexVar(0);
+}
+
+cString cModularityAnalysis::DescSitesInvolvedInXTasks(const cAnalyzeGenotype* genotype, int idx)
+{
+  return cStringUtil::Stringf("Number of Sites Involved in %d Tasks", idx);
+}
+
+
+cFlexVar cModularityAnalysis::GetTaskLengthFor(const cAnalyzeGenotype* genotype, int idx)
+{
+  GET_MD();
+  if (data && idx >= 0 && idx < data->sites_per_task.GetSize()) return cFlexVar(data->task_length[idx]);
+  return cFlexVar(0);
+}
+
+cString cModularityAnalysis::DescTaskLength(const cAnalyzeGenotype* genotype, int idx)
+{
+  return cStringUtil::Stringf("Task %d Length", idx);
+}
+
+
+cFlexVar cModularityAnalysis::GetAveTaskPositionFor(const cAnalyzeGenotype* genotype, int idx)
+{
+  GET_MD();
+  if (data && idx >= 0 && idx < data->sites_per_task.GetSize()) return cFlexVar(data->ave_task_position[idx]);
+  return cFlexVar(0.0);
+}
+
+cString cModularityAnalysis::DescAveTaskPosition(const cAnalyzeGenotype* genotype, int idx)
+{
+  return cStringUtil::Stringf("Task %d Position", idx);
+}
+
+#undef GET_MD
+
+
+cModularityAnalysis::cModularityData::cModularityData()
+: tasks_done(0), insts_tasks(0), tasks_prop(0.0), ave_tasks_per_site(0.0), ave_sites_per_task(0.0), ave_prop_nonoverlap(0.0)
+{
+}

Added: branches/interrupt/source/analyze/cModularityAnalysis.h
===================================================================
--- branches/interrupt/source/analyze/cModularityAnalysis.h	                        (rev 0)
+++ branches/interrupt/source/analyze/cModularityAnalysis.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -0,0 +1,89 @@
+/*
+ *  cModularityAnalysis.h
+ *  Avida
+ *
+ *  Created by David on 1/11/09.
+ *  Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef cModularityAnalysis_h
+#define cModularityAnalysis_h
+
+#ifndef cGenotypeData_h
+#include "cGenotypeData.h"
+#endif
+#ifndef tArray_h
+#include "tArray.h"
+#endif
+
+class cAvidaContext;
+class cAnalyzeGenotype;
+class cFlexVar;
+class cString;
+
+
+class cModularityAnalysis
+{
+private:
+  cAnalyzeGenotype* m_genotype;
+  
+public:
+  cModularityAnalysis(cAnalyzeGenotype* genotype) : m_genotype(genotype) { ; }
+  
+  static void Initialize();
+  
+  void CalcFunctionalModularity(cAvidaContext& ctx);
+  
+  static cFlexVar GetTasksDoneFor(const cAnalyzeGenotype* genotype);
+  static cFlexVar GetInstsInvolvedInTasksFor(const cAnalyzeGenotype* genotype);
+  static cFlexVar GetTaskProportionFor(const cAnalyzeGenotype* genotype);
+  static cFlexVar GetAveTasksPerSiteFor(const cAnalyzeGenotype* genotype);
+  static cFlexVar GetAveSitesPerTaskFor(const cAnalyzeGenotype* genotype);
+  static cFlexVar GetPropNonoverlapFor(const cAnalyzeGenotype* genotype);
+  
+  static cFlexVar GetSitesPerTaskFor(const cAnalyzeGenotype* genotype, int idx);
+  static cString DescSitesPerTask(const cAnalyzeGenotype* genotype, int idx);  
+  static cFlexVar GetSitesInvolvedInXTasksFor(const cAnalyzeGenotype* genotype, int idx);
+  static cString DescSitesInvolvedInXTasks(const cAnalyzeGenotype* genotype, int idx);
+  static cFlexVar GetTaskLengthFor(const cAnalyzeGenotype* genotype, int idx);
+  static cString DescTaskLength(const cAnalyzeGenotype* genotype, int idx);
+  static cFlexVar GetAveTaskPositionFor(const cAnalyzeGenotype* genotype, int idx);
+  static cString DescAveTaskPosition(const cAnalyzeGenotype* genotype, int idx);
+
+  
+private:
+  class cModularityData : public cGenotypeData
+  {
+  public:
+    int tasks_done;                           // number of tasks performed by this genotype
+    int insts_tasks;                          // number of instructions involved in task performance
+    double tasks_prop;                        // proportion of sites used in tasks
+    double ave_tasks_per_site;                // average tasks per site
+    double ave_sites_per_task;                // average sites per task
+    double ave_prop_nonoverlap;               // average proportion of nonoverlap
+    tArray<int> sites_per_task;               // number sites used for each task
+    tArray<int> sites_inv_x_tasks;            // Number of sites involved in 0, 1, 2, 3... tasks
+    tArray<int> task_length;                  // Length of each task from first to last instruction
+    tArray<double> ave_task_position;         // Average task position
+    
+    cModularityData();
+  };
+};
+
+#endif

Modified: branches/interrupt/source/classification/cClassificationManager.cc
===================================================================
--- branches/interrupt/source/classification/cClassificationManager.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/classification/cClassificationManager.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -669,26 +669,26 @@
   return true;
 }
 
-bool cClassificationManager::DumpDetailedSummary(ofstream& fp)
+bool cClassificationManager::DumpDetailedSummary(ofstream& fp, bool print_mut_steps)
 {
   m_genotype_ctl->Reset(0);
-  DumpDetailHeading(fp);
+  DumpDetailHeading(fp, print_mut_steps);
   for (int i = 0; i < m_genotype_ctl->GetSize(); i++) {
-    DumpDetailedEntry(m_genotype_ctl->Get(0), fp);
+    DumpDetailedEntry(m_genotype_ctl->Get(0), fp, print_mut_steps);
     m_genotype_ctl->Next(0);
   }
   
   return true;
 }
 
-bool cClassificationManager::DumpHistoricSummary(ofstream& fp, int back_dist)
+bool cClassificationManager::DumpHistoricSummary(ofstream& fp, int back_dist, bool print_mut_steps)
 {
   // Calculate the update we should start printing from...
   int start_update = 0;
   if (back_dist > 0) start_update = m_world->GetStats().GetUpdate() - back_dist;
   
   // Loop through all defunct genotypes that we're saving.
-  DumpDetailHeading(fp);
+  DumpDetailHeading(fp, print_mut_steps);
   m_genotype_ctl->ResetHistoric(0);
   for (int i = 0; i < m_genotype_ctl->GetHistoricCount(); i++) {
     // Get the next genotype.  Only print it if its in range...
@@ -697,7 +697,7 @@
       m_genotype_ctl->Next(0);
       continue;
     }
-    DumpDetailedEntry(cur_genotype, fp);
+    DumpDetailedEntry(cur_genotype, fp, print_mut_steps);
     
     // Move to the next genotype...
     m_genotype_ctl->Next(0);
@@ -730,11 +730,12 @@
   return true;
 }
 
-void cClassificationManager::DumpDetailHeading (ofstream& fp)
+void cClassificationManager::DumpDetailHeading (ofstream& fp, bool print_mut_steps)
 {
   fp << "#filetype genotype_data" << endl
-  << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl
-  << endl
+  << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence";
+  if (print_mut_steps) { fp << " mut_steps"; }
+  fp << endl << endl
   << "#  1: ID" << endl
   << "#  2: parent ID" << endl
   << "#  3: parent distance" << endl
@@ -747,7 +748,9 @@
   << "# 10: update born" << endl
   << "# 11: update deactivated" << endl
   << "# 12: depth in phylogentic tree" << endl
-  << "# 13: genome of organism" << endl << endl;
+  << "# 13: genome of organism" << endl;
+  if (print_mut_steps) { fp << "# 14: mutation steps from parent" << endl; }
+  fp << endl;  
 }
 
 void cClassificationManager::DumpDetailSexHeading (ofstream& fp)
@@ -771,7 +774,7 @@
   << "# 14: genome of organism" << endl << endl;
 }
 
-void cClassificationManager::DumpDetailedEntry(cGenotype* genotype, ofstream& fp)
+void cClassificationManager::DumpDetailedEntry(cGenotype* genotype, ofstream& fp, bool print_mut_steps)
 {
   fp << genotype->GetID() << " "                //  1
   << genotype->GetParentID() << " "          //  2
@@ -786,8 +789,9 @@
   << genotype->GetUpdateBorn() << " "        // 10
   << genotype->GetUpdateDeactivated() << " " // 11
   << genotype->GetDepth() << " "             // 12
-  << genotype->GetGenome().AsString() << " " // 13
-  << endl;
+  << genotype->GetGenome().AsString() << " "; // 13
+  if (print_mut_steps) { fp << genotype->GetGenome().GetMutationSteps().AsString() << " "; } // 14
+  fp << endl;
 }
 
 void cClassificationManager::DumpDetailedSexEntry(cGenotype * genotype, ofstream& fp)

Modified: branches/interrupt/source/classification/cClassificationManager.h
===================================================================
--- branches/interrupt/source/classification/cClassificationManager.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/classification/cClassificationManager.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -105,7 +105,7 @@
   // Private Helper Functions
   void AddGenotype(cGenotype* in_genotype, int list_num = -1);
   void AddInjectGenotype(cInjectGenotype* in_inject_genotype, int in_list_num = -1);
-  void DumpDetailHeading(std::ofstream& fp);
+  void DumpDetailHeading(std::ofstream& fp, bool print_mut_steps = false);
   void DumpDetailSexHeading (std::ofstream& fp);
   unsigned int FindCRC(const cGenome& in_genome) const;
   unsigned int FindInjectCRC(const cGenome& in_genome) const;
@@ -155,11 +155,11 @@
   // Genotype Output
   bool DumpTextSummary(std::ofstream& fp);
   bool PrintGenotypes(std::ofstream& fp, cString & data_fields, int historic);
-  bool DumpDetailedSummary(std::ofstream& fp);
+  bool DumpDetailedSummary(std::ofstream& fp, bool print_mut_steps = false);
   bool DumpDetailedSexSummary(std::ofstream& fp);
-  bool DumpHistoricSummary(std::ofstream& fp, int back_dist);
+  bool DumpHistoricSummary(std::ofstream& fp, int back_dist, bool print_mut_steps = false);
   bool DumpHistoricSexSummary(std::ofstream& fp);
-  void DumpDetailedEntry(cGenotype* genotype, std::ofstream& fp);
+  void DumpDetailedEntry(cGenotype* genotype, std::ofstream& fp, bool print_mut_steps = false);
   void DumpDetailedSexEntry(cGenotype* genotype, std::ofstream& fp);
   
   

Copied: branches/interrupt/source/classification/cMutationSteps.cc (from rev 3133, development/source/classification/cMutationSteps.cc)
===================================================================
--- branches/interrupt/source/classification/cMutationSteps.cc	                        (rev 0)
+++ branches/interrupt/source/classification/cMutationSteps.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -0,0 +1,95 @@
+/*
+ *  cMutationSteps.cc
+ *  Avida
+ *
+ *  Copyright 1999-2009 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#include "cMutationSteps.h"
+
+cMutationSteps::cMutationSteps(const cMutationSteps& in_ms) : tList<cMutationStep>()
+{
+  tConstListIterator<cMutationStep> mutation_it(in_ms);
+  while (cMutationStep* mut = mutation_it.Next()) {
+    this->PushRear(mut->copy());
+  }
+}
+
+void cMutationSteps::operator=(const cMutationSteps& in_ms)
+{
+  tConstListIterator<cMutationStep> mutation_it(in_ms);
+  while (cMutationStep* mut = mutation_it.Next()) {
+    this->PushRear(mut->copy());
+  }
+}
+
+cMutationSteps::~cMutationSteps()
+{
+  tListIterator<cMutationStep> mutation_it(*this);
+  while (cMutationStep* mut = mutation_it.Next()) {
+    delete mut;
+  }
+}
+
+void cMutationSteps::Clear()
+{
+  tListIterator<cMutationStep> mutation_it(*this);
+  while (cMutationStep* mut = mutation_it.Next()) {
+    delete mut;
+  }
+  tList<cMutationStep>::Clear();
+}
+
+void cMutationSteps::AddSubstitutionMutation(int _pos, char _from, char _to)
+{
+  cMutationStep* mut = new cSubstitutionMutationStep(_pos, _from, _to);
+  this->PushRear(mut);
+}
+
+void cMutationSteps::AddDeletionMutation(int _pos, char _from)
+{
+  cMutationStep* mut = new cDeletionMutationStep(_pos, _from);
+  this->PushRear(mut);
+}
+
+void cMutationSteps::AddInsertionMutation(int _pos, int _to)
+{
+  cMutationStep* mut = new cInsertionMutationStep(_pos, _to);
+  this->PushRear(mut);
+}
+
+void cMutationSteps::AddSlipMutation(int _start, int _end)
+{
+  cMutationStep* mut = new cSlipMutationStep(_start, _end);
+  this->PushRear(mut);
+}
+
+cString cMutationSteps::AsString() const
+{
+  if (m_loaded_string.GetSize() > 0) return m_loaded_string;
+
+  cString return_string;
+  tConstListIterator<cMutationStep> mutation_it(*this);
+  while (cMutationStep* mut = mutation_it.Next()) {
+    if (return_string.GetSize() > 0) { return_string += ","; }
+    return_string += mut->AsString();
+  }
+  return return_string;
+}

Copied: branches/interrupt/source/classification/cMutationSteps.h (from rev 3133, development/source/classification/cMutationSteps.h)
===================================================================
--- branches/interrupt/source/classification/cMutationSteps.h	                        (rev 0)
+++ branches/interrupt/source/classification/cMutationSteps.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -0,0 +1,115 @@
+/*
+ *  cMutationSteps.h
+ *  Avida
+ *
+ *  Copyright 1999-2009 Michigan State University. All rights reserved.
+ *  Copyright 1999-2003 California Institute of Technology.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef cMutationSteps_h
+#define cMutationSteps_h
+
+#ifndef cString_h
+#include "cString.h"
+#endif
+
+#ifndef tList_h
+#include "tList.h"
+#endif
+
+
+class cMutationStep {
+public:
+  virtual ~cMutationStep() {};
+  virtual cMutationStep* copy() const = 0;
+  virtual cString AsString() = 0;  
+};
+
+class cSubstitutionMutationStep : public cMutationStep {
+public:
+  int m_pos;
+  char m_from;
+  char m_to;
+  cSubstitutionMutationStep(const cSubstitutionMutationStep& _in) : cMutationStep(), m_pos(_in.m_pos), m_from(_in.m_from), m_to(_in.m_to) {}
+  void operator=(const cSubstitutionMutationStep& _in) { m_pos=_in.m_pos; m_from=_in.m_from; m_to=_in.m_to; };  
+  cSubstitutionMutationStep(int _pos, char _from, char _to) { m_pos = _pos; m_from = _from;  m_to = _to; }
+  ~cSubstitutionMutationStep() {};
+  cMutationStep* copy() const { return new cSubstitutionMutationStep(*this); }
+  cString AsString() { cString s; s.Set("M%c%i%c", m_from, m_pos, m_to); return s; }
+};
+
+class cDeletionMutationStep : public cMutationStep {
+public:
+  int m_pos;
+  char m_from;
+  cDeletionMutationStep(const cDeletionMutationStep& _in) : cMutationStep(), m_pos(_in.m_pos), m_from(_in.m_from) {}
+  void operator=(const cDeletionMutationStep& _in) { m_pos=_in.m_pos; m_from=_in.m_from; };  
+  cDeletionMutationStep(int _pos, char _from) { m_pos = _pos; m_from = _from; }
+  ~cDeletionMutationStep() {};
+  cMutationStep* copy() const { return new cDeletionMutationStep(*this); }
+  cString AsString() { cString s; s.Set("D%i%c", m_pos, m_from); return s; }
+};
+
+class cInsertionMutationStep : public cMutationStep{
+public:
+  int m_pos;
+  char m_to;
+  cInsertionMutationStep(const cInsertionMutationStep& _in) : cMutationStep(), m_pos(_in.m_pos), m_to(_in.m_to) {}
+  void operator=(const cInsertionMutationStep& _in) { m_pos=_in.m_pos; m_to=_in.m_to; };  
+  cInsertionMutationStep(int _pos, int _to) { m_pos = _pos; m_to = _to; };
+  ~cInsertionMutationStep() {};
+  cMutationStep* copy() const { return new cInsertionMutationStep(*this); }
+  cString AsString() { cString s; s.Set("I%i%c", m_pos, m_to); return s; }
+};
+
+class cSlipMutationStep : public cMutationStep {
+public:
+  int m_start;
+  int m_end;
+  cSlipMutationStep(const cSlipMutationStep& _in) : cMutationStep(), m_start(_in.m_start), m_end(_in.m_end) {}
+  void operator=(const cSlipMutationStep& _in) { m_start=_in.m_start; m_end=_in.m_end; };
+  cSlipMutationStep(int _start, int _end) { m_start = _start; m_end = _end; };
+  ~cSlipMutationStep() {};
+  cMutationStep* copy() const { return new cSlipMutationStep(*this); }
+  cString AsString() { cString s; s.Set("S%i-%i", m_start, m_end); return s; }
+};
+
+
+class cMutationSteps : public tList<cMutationStep> {
+private:
+  cString m_loaded_string;
+public:
+  cMutationSteps() {};
+  cMutationSteps(const cMutationSteps& in_ms);
+  void operator=(const cMutationSteps& in_ms);
+  ~cMutationSteps();
+  void Clear();  
+
+  void AddSubstitutionMutation(int _pos, char _from, char _to);
+  void AddDeletionMutation(int _pos, char _from);
+  void AddInsertionMutation(int _pos, int _to);
+  void AddSlipMutation(int _start, int _end);
+
+  void Set(const cString& in_mut_steps) { m_loaded_string = in_mut_steps; }  
+    // need to implement for reading, right now, we fake it.
+  cString AsString() const;
+};
+
+
+#endif

Modified: branches/interrupt/source/cpu/cCPUMemory.h
===================================================================
--- branches/interrupt/source/cpu/cCPUMemory.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cCPUMemory.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -47,7 +47,6 @@
 	static const unsigned char MASK_UNUSED   = 0x80; // unused bit
   
   tArray<unsigned char> flag_array;
-  
 
   // A collection of sloppy instructions to perform oft-used functions that
   // will need to be cleaned up after this is run.
@@ -73,6 +72,7 @@
 			genome[i].SetOp(0);
 			flag_array[i] = 0;
 		}
+    m_mutation_steps.Clear();
 	}
   void ClearFlags() { flag_array.SetAll(0); }
   void Reset(int new_size);     // Reset size, clearing contents...

Modified: branches/interrupt/source/cpu/cHardwareBase.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareBase.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cHardwareBase.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -191,7 +191,9 @@
   // Divide Mutations
   if (m_organism->TestDivideMut(ctx) && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(offspring_genome.GetSize());
+    char before_mutation = offspring_genome[mut_line].GetSymbol();
     offspring_genome.SetInst(mut_line, m_inst_set->GetRandomInst(ctx), false);
+    offspring_genome.GetMutationSteps().AddSubstitutionMutation(mut_line, before_mutation, offspring_genome[mut_line].GetSymbol());
     totalMutations++;
   }
   
@@ -199,12 +201,14 @@
   if (m_organism->TestDivideIns(ctx) && offspring_genome.GetSize() < MAX_CREATURE_SIZE && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(offspring_genome.GetSize() + 1);
     offspring_genome.Insert(mut_line, m_inst_set->GetRandomInst(ctx));
+    offspring_genome.GetMutationSteps().AddInsertionMutation(mut_line, offspring_genome[mut_line].GetSymbol());
     totalMutations++;
   }
   
   // Divide Deletions
   if (m_organism->TestDivideDel(ctx) && offspring_genome.GetSize() > MIN_CREATURE_SIZE && totalMutations < maxmut) {
     const unsigned int mut_line = ctx.GetRandom().GetUInt(offspring_genome.GetSize());
+    offspring_genome.GetMutationSteps().AddDeletionMutation(mut_line, offspring_genome[mut_line].GetSymbol());
     offspring_genome.Remove(mut_line);
     totalMutations++;
   }
@@ -226,7 +230,9 @@
     if (num_mut > 0 && totalMutations < maxmut) {
       for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
         int site = ctx.GetRandom().GetUInt(offspring_genome.GetSize());
+        char before_mutation = offspring_genome[site].GetSymbol();
         offspring_genome.SetInst(site, m_inst_set->GetRandomInst(ctx), false);
+        offspring_genome.GetMutationSteps().AddSubstitutionMutation(site, before_mutation, offspring_genome[site].GetSymbol());
         totalMutations++;
       }
     }
@@ -237,7 +243,7 @@
   if (m_organism->GetDivInsProb() > 0 && totalMutations < maxmut) {
     int num_mut = ctx.GetRandom().GetRandBinomial(offspring_genome.GetSize(), m_organism->GetDivInsProb());
 
-    // If would make creature to big, insert up to MAX_CREATURE_SIZE
+    // If would make creature too big, insert up to MAX_CREATURE_SIZE
     if (num_mut + offspring_genome.GetSize() > MAX_CREATURE_SIZE) {
       num_mut = MAX_CREATURE_SIZE - offspring_genome.GetSize();
     }
@@ -252,6 +258,7 @@
       // Actually do the mutations (in reverse sort order)
       for (int i = mut_sites.GetSize() - 1; i >= 0; i--) {
         offspring_genome.Insert(mut_sites[i], m_inst_set->GetRandomInst(ctx));
+        offspring_genome.GetMutationSteps().AddInsertionMutation(mut_sites[i], offspring_genome[mut_sites[i]].GetSymbol());
       }
       
       totalMutations += num_mut;
@@ -270,7 +277,9 @@
     
     // If we have lines to delete...
     for (int i = 0; i < num_mut; i++) {
-      offspring_genome.Remove(ctx.GetRandom().GetUInt(offspring_genome.GetSize()));
+      int site = ctx.GetRandom().GetUInt(offspring_genome.GetSize());
+      offspring_genome.GetMutationSteps().AddDeletionMutation(site, offspring_genome[site].GetSymbol());
+      offspring_genome.Remove(site);
     }
 
     totalMutations += num_mut;
@@ -373,19 +382,22 @@
     copied_so_far.SetAll(false);
     for (int i = 0; i < insertion_length; i++) {
       switch (m_world->GetConfig().SLIP_FILL_MODE.Get()) {
+        //Duplication
         case 0:
           genome.SetInst(from + i, genome_copy[to + i], false);
-          break;
-          
+        break;
+
+        //Empty (nop-X)
         case 1:
           genome.SetInst(from + i, m_inst_set->GetInst("nop-X"), false);
-          break;
-          
+        break;
+
+        //Random
         case 2:
           genome.SetInst(from + i, m_inst_set->GetRandomInst(ctx), false);
-          break;
+        break;
           
-          //Randomized order of instructions
+        //Scrambled order
         case 3:
         {
           int copy_index = m_world->GetRandom().GetInt(insertion_length - i);
@@ -402,7 +414,12 @@
           genome.SetInst(from + i, genome[to + copy_index], false);
           copied_so_far[copy_index] = true;
         }
-          break;
+        break;
+        
+        //Empty (nop-C)
+        case 4:
+          genome.SetInst(from + i, m_inst_set->GetInst("nop-C"), false);
+        break;
           
         default:
           m_world->GetDriver().RaiseException("Unknown SLIP_FILL_MODE\n");
@@ -414,6 +431,7 @@
   if (insertion_length < 0) insertion_length = 0;
   for (int i = insertion_length; i < genome_copy.GetSize() - to; i++)
 		genome.SetInst(from + i, genome_copy[to + i], false);
+  genome.GetMutationSteps().AddSlipMutation(from, to);
   
   if (m_world->GetVerbosity() >= VERBOSE_DETAILS) {
     cout << "SLIP MUTATION from " << from << " to " << to << endl;

Modified: branches/interrupt/source/cpu/cHardwareBase.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareBase.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cHardwareBase.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -27,6 +27,7 @@
 #define cHardwareBase_h
 
 #include <cassert>
+#include <climits>
 #include <iostream>
 
 #ifndef cInstSet_h

Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -566,16 +566,18 @@
     tInstLibEntry<tMethod>("relinquishEnergyToOrganismsInDeme", &cHardwareCPU::Inst_RelinquishEnergyToOrganismsInDeme, nInstFlag::STALL),
 
     // Energy level detection
-	  tInstLibEntry<tMethod>("if-energy-low", &cHardwareCPU::Inst_IfEnergyLow, nInstFlag::STALL),
-	  tInstLibEntry<tMethod>("if-energy-not-low", &cHardwareCPU::Inst_IfEnergyNotLow, nInstFlag::STALL),
-	  tInstLibEntry<tMethod>("if-faced-energy-low", &cHardwareCPU::Inst_IfFacedEnergyLow, nInstFlag::STALL),
-	  tInstLibEntry<tMethod>("if-faced-energy-not-low", &cHardwareCPU::Inst_IfFacedEnergyNotLow, nInstFlag::STALL),
-  	tInstLibEntry<tMethod>("if-energy-high", &cHardwareCPU::Inst_IfEnergyHigh, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("if-energy-low", &cHardwareCPU::Inst_IfEnergyLow, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("if-energy-not-low", &cHardwareCPU::Inst_IfEnergyNotLow, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("if-faced-energy-low", &cHardwareCPU::Inst_IfFacedEnergyLow, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("if-faced-energy-not-low", &cHardwareCPU::Inst_IfFacedEnergyNotLow, nInstFlag::STALL),
+    tInstLibEntry<tMethod>("if-energy-high", &cHardwareCPU::Inst_IfEnergyHigh, nInstFlag::STALL),
   	tInstLibEntry<tMethod>("if-energy-not-high", &cHardwareCPU::Inst_IfEnergyNotHigh, nInstFlag::STALL),
   	tInstLibEntry<tMethod>("if-faced-energy-high", &cHardwareCPU::Inst_IfFacedEnergyHigh, nInstFlag::STALL),
   	tInstLibEntry<tMethod>("if-faced-energy-not-high", &cHardwareCPU::Inst_IfFacedEnergyNotHigh, nInstFlag::STALL),
   	tInstLibEntry<tMethod>("if-energy-med", &cHardwareCPU::Inst_IfEnergyMed, nInstFlag::STALL),	 
-  	tInstLibEntry<tMethod>("if-faced-energy-med", &cHardwareCPU::Inst_IfFacedEnergyMed, nInstFlag::STALL),	  
+  	tInstLibEntry<tMethod>("if-faced-energy-med", &cHardwareCPU::Inst_IfFacedEnergyMed, nInstFlag::STALL),	
+  	tInstLibEntry<tMethod>("if-faced-energy-less", &cHardwareCPU::Inst_IfFacedEnergyLess, nInstFlag::STALL),	
+  	tInstLibEntry<tMethod>("if-faced-energy-more", &cHardwareCPU::Inst_IfFacedEnergyMore, nInstFlag::STALL),	    
 	  tInstLibEntry<tMethod>("if-energy-in-buffer", &cHardwareCPU::Inst_IfEnergyInBuffer, nInstFlag::STALL),
 	  tInstLibEntry<tMethod>("if-energy-not-in-buffer", &cHardwareCPU::Inst_IfEnergyNotInBuffer, nInstFlag::STALL),
 	  
@@ -1585,6 +1587,11 @@
   cGenome & child_genome = m_organism->ChildGenome();
   child_genome = cGenomeUtil::Crop(m_memory, div_point, div_point+child_size);
   
+  // Make sure it is an exact copy at this point (before divide mutations) if required
+  if (m_world->GetConfig().REQUIRE_EXACT_COPY.Get() && (m_organism->GetGenome() != child_genome) ) {
+    return false;
+  }
+  
   // Cut off everything in this memory past the divide point.
   m_memory.Resize(div_point);
   
@@ -3712,27 +3719,32 @@
   assert(losspct <= 1);
     
   double cur_energy = m_organism->GetPhenotype().GetStoredEnergy();
+  const int update_metabolic = m_world->GetConfig().ENERGY_SHARING_UPDATE_METABOLIC.Get();
   double energy_given = cur_energy * frac_energy_given;
   
   //update energy store and merit of donor
   m_organism->GetPhenotype().ReduceEnergy(energy_given);
   m_organism->GetPhenotype().IncreaseEnergyDonated(energy_given);
-  double senderMerit = cMerit::EnergyToMerit(m_organism->GetPhenotype().GetStoredEnergy()  * m_organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
-  m_organism->UpdateMerit(senderMerit);
-  
+	
+  if(update_metabolic == 1) {
+    double senderMerit = cMerit::EnergyToMerit(m_organism->GetPhenotype().GetStoredEnergy()  * m_organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
+    m_organism->UpdateMerit(senderMerit);
+  }
+	  
   //apply loss in transfer
   energy_given *= (1 - losspct);
   
   //place energy into receiver's incoming energy buffer
   to_org->GetPhenotype().ReceiveDonatedEnergy(energy_given);
-  to_org->GetPhenotype().IncreaseEnergyReceived(energy_given);
-  GetOrganism()->GetOrgInterface().GetDeme()->IncEnergyDonationsMade();
   
   //if we are using the push energy method, pass the new energy into the receiver's energy store and recalculate merit
   if(m_world->GetConfig().ENERGY_SHARING_METHOD.Get() == 1) {
     to_org->GetPhenotype().ApplyDonatedEnergy();
-    double receiverMerit = cMerit::EnergyToMerit(to_org->GetPhenotype().GetStoredEnergy() * to_org->GetPhenotype().GetEnergyUsageRatio(), m_world);
-    to_org->UpdateMerit(receiverMerit);
+	  
+	  if(update_metabolic == 1) {
+        double receiverMerit = cMerit::EnergyToMerit(to_org->GetPhenotype().GetStoredEnergy() * to_org->GetPhenotype().GetEnergyUsageRatio(), m_world);
+        to_org->UpdateMerit(receiverMerit);
+	  }
   }
   
 } //End DoEnergyDonatePercent()
@@ -4240,8 +4252,11 @@
   if(m_organism->GetPhenotype().GetEnergyInBufferAmount() > 0) {
     m_organism->GetPhenotype().ApplyDonatedEnergy();
     m_organism->GetPhenotype().SetHasUsedDonatedEnergy();
-    double receiverMerit = cMerit::EnergyToMerit(m_organism->GetPhenotype().GetStoredEnergy() * m_organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
-    m_organism->UpdateMerit(receiverMerit);
+	 
+	  if(m_world->GetConfig().ENERGY_SHARING_UPDATE_METABOLIC.Get() == 1) {
+        double receiverMerit = cMerit::EnergyToMerit(m_organism->GetPhenotype().GetStoredEnergy() * m_organism->GetPhenotype().GetEnergyUsageRatio(), m_world);
+        m_organism->UpdateMerit(receiverMerit);
+  	}
   }
   
   return true;
@@ -4280,7 +4295,6 @@
   
   DoEnergyDonatePercent(energyReceiver, m_organism->GetFracEnergyDonating());
   m_organism->GetPhenotype().IncDonates();
-  m_organism->GetOrgInterface().GetDeme()->IncEnergyDonationsMade();
   m_organism->GetPhenotype().SetIsEnergyDonor();
   
   return true;
@@ -4314,7 +4328,6 @@
     {
       DoEnergyDonatePercent(neighbor, m_organism->GetFracEnergyDonating());
       m_organism->GetPhenotype().IncDonates();
-      m_organism->GetOrgInterface().GetDeme()->IncEnergyDonationsMade();
       m_organism->GetPhenotype().SetIsEnergyDonor();
     }
   }  
@@ -4377,7 +4390,6 @@
   // Could set the data field of the message to be the multiplier
   
   m_organism->BroadcastMessage(ctx, msg);
-  m_organism->GetOrgInterface().GetDeme()->IncEnergyRequestsMade();
   m_organism->GetPhenotype().SetIsEnergyRequestor();
   
   return true;
@@ -4392,7 +4404,6 @@
     return false;
   }	
   
-  m_organism->GetOrgInterface().GetDeme()->IncEnergyRequestsMade();
   m_organism->GetPhenotype().SetIsEnergyRequestor();
   m_organism->GetPhenotype().SetHasOpenEnergyRequest();
   return true;
@@ -5508,6 +5519,56 @@
 } //End Inst_IfFacedEnergyMed()
 
 
+/* Execute the next instruction if the faced organism has less energy */
+bool cHardwareCPU::Inst_IfFacedEnergyLess(cAvidaContext& ctx) {
+  
+  if(m_organism->GetCellID() < 0) {
+    return false;
+  }	
+	
+  // Get faced neighbor
+  cOrganism * neighbor = m_organism->GetNeighbor();
+  
+  if ( (neighbor != NULL) && (!neighbor->IsDead()) ) {
+    const double neighbor_energy = neighbor->GetPhenotype().GetStoredEnergy();
+    const double my_energy = m_organism->GetPhenotype().GetStoredEnergy();
+    const double epsilon = m_world->GetConfig().ENERGY_COMPARISON_EPSILON.Get();
+    
+    if(neighbor_energy >= (my_energy * (1 - epsilon))) {
+      IP().Advance();
+    }    
+  }  
+	
+  return true;
+	
+} //End Inst_IfFacedEnergyLess()
+
+
+/* Execute the next instruction if the faced organism has more energy */
+bool cHardwareCPU::Inst_IfFacedEnergyMore(cAvidaContext& ctx) {
+  
+  if(m_organism->GetCellID() < 0) {
+    return false;
+  }	
+	
+  // Get faced neighbor
+  cOrganism * neighbor = m_organism->GetNeighbor();
+  
+  if ( (neighbor != NULL) && (!neighbor->IsDead()) ) {
+    const double neighbor_energy = neighbor->GetPhenotype().GetStoredEnergy();
+    const double my_energy = m_organism->GetPhenotype().GetStoredEnergy();
+    const double epsilon = m_world->GetConfig().ENERGY_COMPARISON_EPSILON.Get();
+
+    if(neighbor_energy <= (my_energy * (1 + epsilon))) {
+      IP().Advance();
+    }    
+  }  
+	
+  return true;
+	
+} //End Inst_IfFacedEnergyMore()
+
+
 /* Execute the next instruction if the organism has received energy */
 bool cHardwareCPU::Inst_IfEnergyInBuffer(cAvidaContext& ctx) {
   

Modified: branches/interrupt/source/cpu/cHardwareCPU.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cHardwareCPU.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -653,6 +653,8 @@
   bool Inst_IfFacedEnergyNotHigh(cAvidaContext& ctx);
   bool Inst_IfEnergyMed(cAvidaContext& ctx);
   bool Inst_IfFacedEnergyMed(cAvidaContext& ctx);
+  bool Inst_IfFacedEnergyMore(cAvidaContext& ctx);
+  bool Inst_IfFacedEnergyLess(cAvidaContext& ctx);
   bool Inst_IfEnergyInBuffer(cAvidaContext& ctx);
   bool Inst_IfEnergyNotInBuffer(cAvidaContext& ctx);
 	

Modified: branches/interrupt/source/cpu/cHardwareManager.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareManager.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/cpu/cHardwareManager.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -91,19 +91,19 @@
 	
   switch (m_type) {
     case HARDWARE_TYPE_CPU_ORIGINAL:
-      hw = new cHardwareCPU(ctx, m_world, in_org, m_inst_set);
+      hw = new cHardwareCPU(ctx, m_world, in_org, inst_set);
       break;
     case HARDWARE_TYPE_CPU_SMT:
-      hw = new cHardwareSMT(ctx, m_world, in_org, m_inst_set);
+      hw = new cHardwareSMT(ctx, m_world, in_org, inst_set);
       break;
     case HARDWARE_TYPE_CPU_TRANSSMT:
-      hw = new cHardwareTransSMT(ctx, m_world, in_org, m_inst_set);
+      hw = new cHardwareTransSMT(ctx, m_world, in_org, inst_set);
       break;
     case HARDWARE_TYPE_CPU_EXPERIMENTAL:
-      hw = new cHardwareExperimental(ctx, m_world, in_org, m_inst_set);
+      hw = new cHardwareExperimental(ctx, m_world, in_org, inst_set);
       break;
     case HARDWARE_TYPE_CPU_GX:
-      hw = new cHardwareGX(ctx, m_world, in_org, m_inst_set);
+      hw = new cHardwareGX(ctx, m_world, in_org, inst_set);
       break;
     default:
       cDriverManager::Status().SignalError("Unknown/Unsupported HARDWARE_TYPE specified", -1);

Modified: branches/interrupt/source/main/cAvidaConfig.h
===================================================================
--- branches/interrupt/source/main/cAvidaConfig.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cAvidaConfig.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -361,7 +361,7 @@
   CONFIG_ADD_VAR(SAME_LENGTH_SEX, int, 0, "0 = recombine with any genome\n1 = only recombine w/ same length");
 
   CONFIG_ADD_GROUP(DIVIDE_GROUP, "Divide Restrictions");
-  CONFIG_ADD_VAR(CHILD_SIZE_RANGE, double, 2.0, "Maximal differential between child and parent sizes.");
+  CONFIG_ADD_VAR(CHILD_SIZE_RANGE, double, 2.0, "Maximal differential between child and parent sizes.\n(Checked BEFORE mutations applied on divide.)");
   CONFIG_ADD_VAR(MIN_COPIED_LINES, double, 0.5, "Code fraction which must be copied before divide.");
   CONFIG_ADD_VAR(MIN_EXE_LINES, double, 0.5, "Code fraction which must be executed before divide.");
   CONFIG_ADD_VAR(MIN_GENOME_SIZE, int, 0, "Minimum number of instructions allowed in a genome. 0 = OFF");
@@ -371,12 +371,12 @@
   CONFIG_ADD_VAR(IMMUNITY_TASK, int, -1, "Task providing immunity from the required task.");
   CONFIG_ADD_VAR(REQUIRED_REACTION, int, -1, "Reaction ID required for successful divide.");
   CONFIG_ADD_VAR(REQUIRED_BONUS, double, 0.0, "Required bonus to divide.");
+  CONFIG_ADD_VAR(REQUIRE_EXACT_COPY, int, 0, "Require offspring to be an exact copy (only divide mutations allowed).");
   CONFIG_ADD_VAR(IMPLICIT_REPRO_BONUS, int, 0, "Call Inst_Repro to divide upon achieving this bonus. 0 = OFF");  
   CONFIG_ADD_VAR(IMPLICIT_REPRO_CPU_CYCLES, int, 0, "Call Inst_Repro after this many cpu cycles. 0 = OFF");  
   CONFIG_ADD_VAR(IMPLICIT_REPRO_TIME, int, 0, "Call Inst_Repro after this time used. 0 = OFF");  
   CONFIG_ADD_VAR(IMPLICIT_REPRO_END, int, 0, "Call Inst_Repro after executing the last instruction in the genome.");  
   CONFIG_ADD_VAR(IMPLICIT_REPRO_ENERGY, double, 0.0, "Call Inst_Repro if organism accumulates this amount of energy.");    
-
   
   CONFIG_ADD_GROUP(MUTATION_GROUP, "Mutations");
   CONFIG_ADD_VAR(POINT_MUT_PROB, double, 0.0, "Mutation rate (per-location per update)");
@@ -391,7 +391,7 @@
   CONFIG_ADD_VAR(DIV_INS_PROB, double, 0.0, "Insertion rate (per site, applied on divide)");
   CONFIG_ADD_VAR(DIV_DEL_PROB, double, 0.0, "Deletion rate (per site, applied on divide)");
   CONFIG_ADD_VAR(DIV_UNIFORM_PROB, double, 0.0, "Uniform mutation probability (per site, applied on divide)\n- Randomly applies any of the three classes of mutations (ins, del, point).");
-  CONFIG_ADD_VAR(DIV_SLIP_PROB, double, 0.0, "Slip rate");
+  CONFIG_ADD_VAR(DIV_SLIP_PROB, double, 0.0, "Slip rate (per site, applied on divide)");
   
   CONFIG_ADD_VAR(DIVIDE_MUT_PROB, double, 0.0, "Mutation rate (per divide)");
   CONFIG_ADD_VAR(DIVIDE_INS_PROB, double, 0.05, "Insertion rate (per divide)");
@@ -403,7 +403,7 @@
   CONFIG_ADD_VAR(INJECT_DEL_PROB, double, 0.0, "Deletion rate (per site, applied on inject)");
   CONFIG_ADD_VAR(INJECT_MUT_PROB, double, 0.0, "Mutation rate (per site, applied on inject)");
   
-  CONFIG_ADD_VAR(SLIP_FILL_MODE, int, 0, "Fill insertions from slip mutations with 0=duplication, 1=nop-X, 2=random, 3=scrambled");
+  CONFIG_ADD_VAR(SLIP_FILL_MODE, int, 0, "Fill insertions from slip mutations with 0=duplication, 1=nop-X, 2=random, 3=scrambled, 4=nop-C");
   CONFIG_ADD_VAR(SLIP_COPY_MODE, int, 0, "How to handle 'on-copy' slip mutations:\n0 = actual read head slip\n1 = instant large mutation (obeys slip mode)");
   CONFIG_ADD_VAR(PARENT_MUT_PROB, double, 0.0, "Per-site, in parent, on divide");
   CONFIG_ADD_VAR(SPECIAL_MUT_LINE, int, -1, "If this is >= 0, ONLY this line is mutated");
@@ -517,9 +517,10 @@
   CONFIG_ADD_VAR(FRAC_PARENT_ENERGY_GIVEN_TO_DEME_AT_BIRTH, double, 0.5, "Fraction of parent's energy given to offspring deme.");
   CONFIG_ADD_VAR(FRAC_ENERGY_DECAY_AT_ORG_BIRTH, double, 0.0, "Fraction of energy lost due to decay during organism reproduction.");
   CONFIG_ADD_VAR(FRAC_ENERGY_DECAY_AT_DEME_BIRTH, double, 0.0, "Fraction of energy lost due to decay during deme reproduction.");
-  CONFIG_ADD_VAR(NUM_INST_EXC_BEFORE_0_ENERGY, int, 0, "Number of instructions executed before energy is exhausted.");
+  CONFIG_ADD_VAR(NUM_CYCLES_EXC_BEFORE_0_ENERGY, int, 0, "Number of virtual CPU cycles executed before energy is exhausted.");
   CONFIG_ADD_VAR(ENERGY_CAP, double, -1.0, "Maximum amount of energy that can be stored in an organism.  -1 means the cap is set to Max Double");  // TODO - is this done?
   CONFIG_ADD_VAR(APPLY_ENERGY_METHOD, int, 0, "When should rewarded energy be applied to current energy?\n0 = on divide\n1 = on completion of task\n2 = on sleep");  
+  CONFIG_ADD_VAR(FIX_METABOLIC_RATE, double, -1.0, "Fix organism metobolic rate to value.  This value is static.  Feature disabled by default (value == -1)");
   CONFIG_ADD_VAR(FRAC_ENERGY_TRANSFER, double, 0.0, "Fraction of replaced organism's energy take by new resident");
   CONFIG_ADD_VAR(LOG_SLEEP_TIMES, bool, 0, "Log sleep start and end times. 0/1 (off/on)\nWARNING: may use lots of memory.");
   CONFIG_ADD_VAR(FRAC_ENERGY_RELINQUISH, double, 1.0, "Fraction of organisms energy to relinquish");
@@ -528,12 +529,14 @@
   CONFIG_ADD_VAR(ATTACK_DECAY_RATE, double, 0.0, "Percent of cell's energy decayed by attack");
   CONFIG_ADD_VAR(ENERGY_THRESH_LOW, double, .33, "Threshold percent below which energy level is considered low.  Requires ENERGY_CAP.");
   CONFIG_ADD_VAR(ENERGY_THRESH_HIGH, double, .75, "Threshold percent above which energy level is considered high.  Requires ENERGY_CAP.");
+  CONFIG_ADD_VAR(ENERGY_COMPARISON_EPSILON, double, 0.0, "Percent difference (relative to executing organism) required in energy level comparisons");
   
   CONFIG_ADD_GROUP(ENERGY_SHARING_GROUP, "Energy Sharing Settings");
   CONFIG_ADD_VAR(ENERGY_SHARING_METHOD, int, 0, "Method for sharing energy.  0=receiver must actively receive/request, 1=energy pushed on receiver");
   CONFIG_ADD_VAR(ENERGY_SHARING_PCT, double, 0.0, "Percent of energy to share");
   CONFIG_ADD_VAR(ENERGY_SHARING_INCREMENT, double, 0.01, "Amount to change percent energy shared");
   CONFIG_ADD_VAR(ENERGY_SHARING_LOSS, double, 0.0, "Percent of shared energy lost in transfer");
+  CONFIG_ADD_VAR(ENERGY_SHARING_UPDATE_METABOLIC, bool, 0, "0/1 (off/on) - Whether to update an organism's metabolic rate on donate or reception/application of energy");
   
 	CONFIG_ADD_GROUP(INTERRUPT_GROUP, "Interrupt Settings");
   CONFIG_ADD_VAR(INTERRUPT_ENABLED, bool, 0, "Enable Interrupt Model. 0/1 (off/on)");

Modified: branches/interrupt/source/main/cDeme.cc
===================================================================
--- branches/interrupt/source/main/cDeme.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cDeme.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -76,9 +76,6 @@
   last_org_reaction_count.ResizeClear(num_reactions);
   last_org_reaction_count.SetAll(0);
   
-  energy_requests_made = 0;
-  energy_donations_made = 0;
-  
   // If width is negative, set it to the full number of cells.
   width = in_width;
   if (width < 1) width = cell_ids.GetSize();

Modified: branches/interrupt/source/main/cDeme.h
===================================================================
--- branches/interrupt/source/main/cDeme.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cDeme.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -87,8 +87,6 @@
   unsigned int consecutiveSuccessfulEventPeriods;
   int sleeping_count; //!< Number of organisms currently sleeping
   cDoubleSum energyUsage;
-  unsigned int energy_requests_made;
-  unsigned int energy_donations_made;
   
   tArray<int> cur_task_exe_count;
   tArray<int> cur_reaction_count;
@@ -320,10 +318,6 @@
 	unsigned int GetMessageSuccessfullySent() { return MSG_SuccessfullySent; }
 	unsigned int GetMessageDropped() { return MSG_dropped; }
 	unsigned int GetMessageSendFailed() { return MSG_sendFailed; }
-  
-  // --- Energy sharing stats --- //
-  void IncEnergyRequestsMade() { energy_requests_made++; }
-  void IncEnergyDonationsMade() { energy_donations_made++; }
 
   // --- Pheromones --- //
   void AddPheromone(int absolute_cell_id, double value);

Modified: branches/interrupt/source/main/cEventList.cc
===================================================================
--- branches/interrupt/source/main/cEventList.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cEventList.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -376,7 +376,9 @@
 // birth queue.
 bool cEventList::CheckBirthInterruptQueue(double t_val)
 {
-	return (m_birth_interrupt_queue.Find(&t_val) != NULL);
+	return false;
+	//Disabled for now...
+	//return (m_birth_interrupt_queue.Find(&t_val) != NULL);
 }
 
 

Modified: branches/interrupt/source/main/cGenome.cc
===================================================================
--- branches/interrupt/source/main/cGenome.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cGenome.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -36,7 +36,7 @@
 }
 
 cGenome::cGenome(const cGenome & in_genome)
-  : genome(in_genome.GetSize()), protected_sites(in_genome.GetSize()), active_size(in_genome.GetSize())
+  : genome(in_genome.GetSize()), protected_sites(in_genome.GetSize()), active_size(in_genome.GetSize()), m_mutation_steps(in_genome.GetMutationSteps())
 {
   for (int i = 0; i < active_size; i++) {
 		genome[i] = in_genome[i];
@@ -99,6 +99,8 @@
     genome[i] = other_genome[i];
 		protected_sites[i] = other_genome.IsProtected(i);
   }
+  
+  m_mutation_steps = other_genome.m_mutation_steps;
 }
 
 

Modified: branches/interrupt/source/main/cGenome.h
===================================================================
--- branches/interrupt/source/main/cGenome.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cGenome.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -31,6 +31,9 @@
 #ifndef cInstruction_h
 #include "cInstruction.h"
 #endif
+#ifndef cMutationSteps_h
+#include "cMutationSteps.h"
+#endif
 #ifndef cString_h
 #include "cString.h"
 #endif
@@ -49,6 +52,7 @@
   tArray<cInstruction> genome;
 	tArray<bool> protected_sites;
   int active_size;
+  cMutationSteps m_mutation_steps;
 
 public:
   //! Default constructor.
@@ -83,6 +87,10 @@
    
   int GetSize() const { return active_size; }
   cString AsString() const;
+  
+  cMutationSteps& GetMutationSteps() { return m_mutation_steps; }
+  const cMutationSteps& GetMutationSteps() const { return m_mutation_steps; }
+
 };
 
 

Modified: branches/interrupt/source/main/cPhenotype.cc
===================================================================
--- branches/interrupt/source/main/cPhenotype.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cPhenotype.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -1381,14 +1381,15 @@
 
 void cPhenotype::ApplyDonatedEnergy() {
   double energy_cap = m_world->GetConfig().ENERGY_CAP.Get();
-  
+
   if((energy_store + energy_received_buffer) >= energy_cap) {
     IncreaseEnergyApplied(energy_cap - energy_store);
+    SetEnergy(energy_store + (energy_cap - energy_received_buffer));
   } else {
     IncreaseEnergyApplied(energy_received_buffer);
+    SetEnergy(energy_store + energy_received_buffer);
   }
   
-  SetEnergy(energy_store + energy_received_buffer);
   energy_received_buffer = 0.0;
 } //End AppplyDonatedEnergy()
 
@@ -1396,6 +1397,7 @@
 void cPhenotype::ReceiveDonatedEnergy(const double donation) {
   assert(donation >= 0.0);  
   energy_received_buffer += donation;
+  IncreaseEnergyReceived(donation);
   is_energy_receiver = true;
 } //End ReceiveDonatedEnergy()
 

Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cPopulation.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -403,6 +403,9 @@
         GetCell(target_cells[i]).Rotate(parent_cell);
       }
     }
+    
+    // Purge the mutations since last division
+    parent_organism.ChildGenome().GetMutationSteps().Clear();
   }
   
   // Do any statistics on the parent that just gave birth...
@@ -2636,9 +2639,9 @@
   df_donor.WriteTimeStamp();
   df_donor.Write(stats.GetUpdate(), "update");
   
-  int num_requestors = 0;
-  int num_donors = 0;
-  int num_receivers = 0;
+  double num_requestors = 0;
+  double num_donors = 0;
+  double num_receivers = 0;
   double amount_donated = 0.0;
   double amount_received = 0.0;
   double amount_applied = 0.0;  
@@ -2659,11 +2662,11 @@
     }
   }
   df_donor.Write(num_requestors/num_demes, "Average number of organisms that have requested energy");
-  df_donor.Write(num_donors/num_demes, "Average umber of organisms that have donated energy");
+  df_donor.Write(num_donors/num_demes, "Average number of organisms that have donated energy");
   df_donor.Write(num_receivers/num_demes, "Average number of organisms that have received energy");
-  df_donor.Write(amount_donated/num_demes, "Average total amount of energy donated");
-  df_donor.Write(amount_received/num_demes, "Average total amount of energy received");
-  df_donor.Write(amount_applied/num_demes, "Average total amount of donated energy applied");
+  df_donor.Write(amount_donated/num_demes, "Average total amount of energy donated per deme");
+  df_donor.Write(amount_received/num_demes, "Average total amount of energy received per deme");
+  df_donor.Write(amount_applied/num_demes, "Average total amount of donated energy applied per deme");
   df_donor.Endl();  
   
 }

Modified: branches/interrupt/source/main/cReactionRequisite.h
===================================================================
--- branches/interrupt/source/main/cReactionRequisite.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cReactionRequisite.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -26,6 +26,8 @@
 #ifndef cReactionRequisite_h
 #define cReactionRequisite_h
 
+#include <climits>
+
 #ifndef tList_h
 #include "tList.h"
 #endif

Modified: branches/interrupt/source/main/cWorld.cc
===================================================================
--- branches/interrupt/source/main/cWorld.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/main/cWorld.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -105,6 +105,8 @@
 	if (m_conf->TRACK_CCLADES.Get() > 0)
 		m_class_mgr->LoadCCladeFounders(m_conf->TRACK_CCLADES_IDS.Get());
   
+	m_pop = new cPopulation(this);
+  m_pop->InitiatePop();
   
   // Setup Event List
   m_event_list = new cEventList(this);
@@ -113,8 +115,6 @@
     Avida::Exit(-1);
   }
 	
-	m_pop = new cPopulation(this);
-  m_pop->InitiatePop();
   
   const bool revert_fatal = m_conf->REVERT_FATAL.Get() > 0.0;
   const bool revert_neg = m_conf->REVERT_DETRIMENTAL.Get() > 0.0;

Copied: branches/interrupt/source/platform/tRLockPtr.h (from rev 3133, development/source/platform/tRLockPtr.h)
===================================================================
--- branches/interrupt/source/platform/tRLockPtr.h	                        (rev 0)
+++ branches/interrupt/source/platform/tRLockPtr.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -0,0 +1,72 @@
+/*
+ *  tRLockPtr.h
+ *  Avida
+ *
+ *  Created by David on 1/12/09.
+ *  Copyright 2009 Michigan State University. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; version 2
+ *  of the License.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ */
+
+#ifndef tRLockPtr_h
+#define tRLockPtr_h
+
+#ifndef cRWLock_h
+#include "cRWLock.h"
+#endif
+
+
+template<class T> class tRLockPtr
+{
+private:
+  T* m_ptr;
+  cRWLock* m_rwlock;
+  
+  
+public:
+  tRLockPtr(T* ptr, cRWLock* rwlock) : m_ptr(ptr), m_rwlock(rwlock) { m_rwlock->ReadLock(); }
+  tRLockPtr(const tRLockPtr& p) : m_ptr(p.m_ptr), m_rwlock(p.m_rwlock) { m_rwlock->ReadLock(); }
+  ~tRLockPtr() { m_rwlock->Unlock(); }
+  
+  tRLockPtr& operator=(const tRLockPtr& rhs);
+
+  inline bool operator!() const { return !m_ptr; }
+  inline operator bool() const { return !operator!(); }
+  
+  inline T* operator->() const { return m_ptr; }
+  inline T& operator*() const { return *m_ptr; }
+  
+  template<class S> inline S* operator->() const { return m_ptr; }
+  template<class S> inline S& operator->() const { return *m_ptr; }
+  
+  template<class S> operator tRLockPtr<S>() { return tRLockPtr<S>(m_ptr, m_rwlock); }
+};
+
+template<class T> tRLockPtr<T>& tRLockPtr<T>::operator=(const tRLockPtr& rhs)
+{
+  if (m_ptr != rhs.m_ptr) {
+    m_rwlock->Unlock();
+    m_ptr = rhs.m_ptr;
+    m_rwlock = rhs.m_rwlock;
+    m_rwlock->ReadLock();
+  }
+  
+  return *this;
+}
+
+
+#endif

Modified: branches/interrupt/source/tools/cMerit.cc
===================================================================
--- branches/interrupt/source/tools/cMerit.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/cMerit.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -72,7 +72,10 @@
 
 double cMerit::EnergyToMerit(const double orgEnergy, cWorld* m_world) {
   assert(m_world->GetConfig().ENERGY_ENABLED.Get() == 1);
-  int inst_2_exc = m_world->GetConfig().NUM_INST_EXC_BEFORE_0_ENERGY.Get();
+	static double FIX_METABOLIC_RATE = m_world->GetConfig().FIX_METABOLIC_RATE.Get();
+	if(FIX_METABOLIC_RATE > 0.0)
+		return 100 * FIX_METABOLIC_RATE;
+  int inst_2_exc = m_world->GetConfig().NUM_CYCLES_EXC_BEFORE_0_ENERGY.Get();
   return 100 * orgEnergy / (inst_2_exc);
 }
 

Modified: branches/interrupt/source/tools/cStringUtil.cc
===================================================================
--- branches/interrupt/source/tools/cStringUtil.cc	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/cStringUtil.cc	2009-01-23 15:26:04 UTC (rev 3134)
@@ -184,144 +184,6 @@
   return value;
 }
 
-
-int cStringUtil::GapMinimizingEditDistance(const cString & string1, const cString & string2,
-			      cString & info, const char gap)
-{
-  const int size1 = string1.GetSize();
-  const int size2 = string2.GetSize();
- 
-  if (!size1) return size2;
-  if (!size2) return size1;
-
-  // Note: For both matrices, the first and last cols/rows 
-  // are for alignments to an end gap.
-  tMatrix<double> dist_matrix(size2+2, size1+2);
-
-  // Keep track of changes in a mut_matrix.
-  //  N=None, M=Mutations, I=Insertion, D=Deletion
-  tMatrix<char> mut_matrix(size2+2, size1+2);
-
-  // Initialize the last row and col to record the difference from nothing.
-  for (int i = 0; i < size1+1; i++) {
-    dist_matrix(size2+1,i) = (double) (size1+1 - i);
-    mut_matrix(size2+1,i) = 'I';
-  }
-  for (int i = 0; i < size2+1; i++) {
-    dist_matrix(i,size1+1) = (double) (size2+1 - i);
-    mut_matrix(i,size1+1) = 'D';
-  }
-  mut_matrix(size2+1,size1+1) = 'N';
-  dist_matrix(size2+1,size1+1) = (double) 0;
-  
-  for (int i = size2; i >= 0; i--) {
-    // Move down the cur_row and fill it out.
-    for (int j = size1; j >= 0; j--) {
-      // Otherwise, set the current position to the minimal of the three
-      // numbers above (insertion), to the left (deletion), or upper left
-      // (mutation/match) plus one if the aligned positions do not match.
-      
-      char c1 = (j-1 >= 0) ? string1[j-1] : '\0';
-      char c2 = (i-1 >= 0) ? string2[i-1] : '\0';
-
-      bool matched = (c1 == c2);
-      if (j-1 < 0 && i-1 <= 0) matched = 0;
-      double match_dist = dist_matrix(i+1,j+1) + ((matched) ? 0 : 1);
-      
-      double ins_dist = dist_matrix(i+1,j) + 1;
-      if (mut_matrix(i+1,j) != 'D') ins_dist += 0.0001;
-      double del_dist = dist_matrix(i,j+1) + 1;
-      if (mut_matrix(i,j+1) != 'I') del_dist += 0.0001;
-
-      if (ins_dist <= del_dist && ins_dist <= match_dist) {     // Insertion!
-        dist_matrix(i,j) = ins_dist;
-        mut_matrix(i,j) = 'D';
-      } else if (match_dist <= del_dist) {                       // Mutation!
-        dist_matrix(i,j) = match_dist;
-        mut_matrix(i,j) = (matched) ? 'N' : 'M';        
-
-      } else {                     // Deletion!
-        dist_matrix(i,j) = del_dist;
-        mut_matrix(i,j) = 'I';
-      }
-    }
-  }
-  mut_matrix(size2+1,size1+1) = 'N';
-  dist_matrix(size2+1,size1+1) = (double) 0;
-  
-  /* For debugging, print out matrices
-  for (int i = 0; i <= size2+1; i++) {
-    for (int j = 0; j <=size1+1; j++) {
-      cout << dist_matrix(i,j) << " ";
-    }
-    cout << endl;
-  }
-
-  for (int i = 0; i <= size2+1; i++) {
-    for (int j = 0; j <=size1+1; j++) {
-      cout << mut_matrix(i,j) << " ";
-    }
-  cout << endl;
-  }
-  */
-
-  // Construct the list of changes
-  int pos1 = 0;
-  int pos2 = 0;
-  info = "";
-
-  // We don't start at 0,0 (which would be an initial gap to an initial gap alignment)
-  // Choose whether there are initial gaps.
-  cString mut_string;
-  bool first_time = true;
-  while (pos1 < size1+1 || pos2 < size2+1) {
-    if (mut_matrix(pos2, pos1) == 'N') {     
-      pos1++; pos2++;
-      continue;
-    }
-
-    // There is a mutation here; determine the type...
-    const char old_char = (pos2-1 < size2 && pos2>0) ? string2[pos2-1] : '\0';
-    const char new_char = (pos1-1 < size1 && pos1>0) ? string1[pos1-1] : '\0';
-
-    if (mut_matrix(pos2, pos1) == 'M') {
-      mut_string.Set("M%d%c%c", pos2-1, old_char, new_char);
-      
-      // "Mutations" in the initial column are really alignments
-      // with gaps so we must substitute insertions or deletions.
-      if (pos1==0) {
-          mut_string.Set("D%d%c", pos1, new_char);
-      }
-      if (pos2==0) {
-            mut_string.Set("I%d%c", pos2, new_char);
-      }
-        pos1++; pos2++;
-    }
-    else if (mut_matrix(pos2, pos1) == 'D') {
-      mut_string.Set("D%d%c", pos2-1, old_char);
-      pos2++;
-    }
-    else { // if (mut_matrix(pos2+1, pos1+1) == 'I') {
-      mut_string.Set("I%d%c", pos1-1, new_char);
-      pos1++;
-    }
-  
-    if (first_time) {
-      first_time = false;
-      continue;
-    }
-    
-    /* For debugging, print out mutations found
-    cout << mut_string << endl;
-    */
-    if (info.GetSize() > 0) mut_string.Insert(",");
-    info += mut_string;
-  } 
-
-  // Now that we are done, return the bottom-right corner of the chart.
-  return (int) dist_matrix(0, 0);
-}
-
 int cStringUtil::EditDistance(const cString & string1, const cString & string2,
 			      cString & info, const char gap)
 {

Modified: branches/interrupt/source/tools/cStringUtil.h
===================================================================
--- branches/interrupt/source/tools/cStringUtil.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/cStringUtil.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -65,7 +65,6 @@
    **/
   static int EditDistance(const cString& string1, const cString& string2);
   static int EditDistance(const cString& string1, const cString& string2, cString& info, const char gap = ' '); 
-  static int GapMinimizingEditDistance(const cString& string1, const cString& string2, cString& info, const char gap = ' '); 
 
   /**
    * Various, overloaded conversion functions for use in templates.  Note

Modified: branches/interrupt/source/tools/tArrayMap.h
===================================================================
--- branches/interrupt/source/tools/tArrayMap.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/tArrayMap.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -63,7 +63,7 @@
     return false;
   }
   
-  const ValueType& Get(const KeyType& key, const ValueType& default_value) const
+  const ValueType& Get(const KeyType& key, const ValueType& default_value)
   {
     for (int i = 0; i < m_map.GetSize(); i++) {
       if (m_map[i].Key() == key) return m_map[i].Value();
@@ -101,10 +101,10 @@
   typedef typename tArray<tKVPair<KeyType, ValueType> >::iterator iterator;
   typedef typename tArray<tKVPair<KeyType, ValueType> >::const_iterator const_iterator;
   
-  inline iterator begin() { m_map.begin(); }
-  inline iterator end() { m_map.end(); }
-  inline const_iterator begin() const { m_map.begin(); }
-  inline const_iterator end() const { m_map.end(); }
+  inline iterator begin() { return m_map.begin(); }
+  inline iterator end() { return m_map.end(); }
+  inline const_iterator begin() const { return m_map.begin(); }
+  inline const_iterator end() const { return m_map.end(); }
 };
 
 #endif

Modified: branches/interrupt/source/tools/tDataEntry.h
===================================================================
--- branches/interrupt/source/tools/tDataEntry.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/tDataEntry.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -156,4 +156,78 @@
 };
 
 
+template <class TargetType, class IdxType> class tDataEntryProxy;
+
+template <class TargetType>
+class tDataEntryProxy<TargetType, cFlexVar ()> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(const TargetType*);
+  
+public:
+  tDataEntryProxy(const cString& name, const cString& desc,
+                  cFlexVar (*_funR)(const TargetType*),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, desc, compare_type, null, html_cell), DataRetrieval(_funR) { ; }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target);
+  }
+};
+
+template <class TargetType, class IdxType>
+class tDataEntryProxy<TargetType, cFlexVar (IdxType)> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(const TargetType*, IdxType);
+  cString (*DescFunction)(const TargetType*, IdxType);
+  
+public:
+  tDataEntryProxy(const cString& name,
+                  cString (*_funD)(const TargetType*, IdxType),
+                  cFlexVar (*_funR)(const TargetType*, IdxType),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
+  
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
+  {
+    return (*DescFunction)(target, idx.As<IdxType>());
+  }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target, idx.As<IdxType>());
+  }
+};
+
+template <class TargetType, class IdxType>
+class tDataEntryProxy<TargetType, cFlexVar (IdxType, const cStringList&)> : public tDataEntry<TargetType>
+{
+protected:
+  cFlexVar (*DataRetrieval)(const TargetType*, IdxType, const cStringList&);
+  cString (*DescFunction)(const TargetType*, IdxType);
+  
+public:
+  tDataEntryProxy(const cString& name,
+                  cString (*_funD)(const TargetType*, IdxType),
+                  cFlexVar (*_funR)(const TargetType*, IdxType, const cStringList&),
+                  int compare_type = 0, const cString& null = "0", const cString& html_cell = "align=center")
+  : tDataEntry<TargetType>(name, name, compare_type, null, html_cell), DataRetrieval(_funR), DescFunction(_funD) { ; }
+  
+  cString GetDesc(const TargetType* target, const cFlexVar& idx) const
+  {
+    return (*DescFunction)(target, idx.As<IdxType>());
+  }
+  
+  cFlexVar Get(const TargetType* target, const cFlexVar& idx, const cStringList& args) const
+  {
+    assert(target != NULL);
+    return (*DataRetrieval)(target, idx.As<IdxType>(), args);
+  }
+};
+
+
 #endif

Modified: branches/interrupt/source/tools/tKVPair.h
===================================================================
--- branches/interrupt/source/tools/tKVPair.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/tKVPair.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -35,7 +35,7 @@
   inline tKVPair(const K& key, const V& value) : m_key(key), m_value(value) { ; }
   inline tKVPair(const tKVPair& p) : m_key(p.m_key), m_value(p.m_value) { ; }
   
-  inline tKVPair& operator=(const tKVPair& rhs) { m_key = rhs.m_key; m_value = rhs.m_value; }
+  inline tKVPair& operator=(const tKVPair& rhs) { m_key = rhs.m_key; m_value = rhs.m_value; return *this; }
   
   inline K& Key() { return m_key; }
   inline const K& Key() const { return m_key; }

Modified: branches/interrupt/source/tools/tRCPtr.h
===================================================================
--- branches/interrupt/source/tools/tRCPtr.h	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/source/tools/tRCPtr.h	2009-01-23 15:26:04 UTC (rev 3134)
@@ -46,7 +46,7 @@
   inline T& operator*() const { return *m_ptr; }
   
   template<class S> inline S* operator->() const { return m_ptr; }
-  template<class S> inline S& operator->() const { return *m_ptr; }
+  template<class S> inline S& operator*() const { return *m_ptr; }
   
   template<class S> operator tRCPtr<S>() { return tRCPtr<S>(m_ptr); }
 };

Modified: branches/interrupt/tests/energy_asex_1000u/config/avida.cfg
===================================================================
--- branches/interrupt/tests/energy_asex_1000u/config/avida.cfg	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/tests/energy_asex_1000u/config/avida.cfg	2009-01-23 15:26:04 UTC (rev 3134)
@@ -228,6 +228,6 @@
 ENERGY_GIVEN_AT_BIRTH 0.0                # Energy given to offspring upon birth.
 FRAC_PARENT_ENERGY_GIVEN_TO_ORG_AT_BIRTH 0.5  # Fraction of energy given to offspring.
 FRAC_ENERGY_DECAY_AT_ORG_BIRTH 0.05         # Fraction of energy lost due to decay during reproduction.
-NUM_INST_EXC_BEFORE_0_ENERGY 1000000         # Number of instructions executed before energy is exhausted.
+NUM_CYCLES_EXC_BEFORE_0_ENERGY 1000000         # Number of instructions executed before energy is exhausted.
 ENERGY_CAP -1                          # Maximun amount of energy that can be stored in an organism.  -1 means the cap is set to Max Int
 ENERGY_VERBOSE 0                       # Print energy and merit values. 0/1 (off/on)

Modified: branches/interrupt/tests/energy_deme_level_res/config/avida.cfg
===================================================================
--- branches/interrupt/tests/energy_deme_level_res/config/avida.cfg	2009-01-23 14:51:56 UTC (rev 3133)
+++ branches/interrupt/tests/energy_deme_level_res/config/avida.cfg	2009-01-23 15:26:04 UTC (rev 3134)
@@ -252,6 +252,6 @@
 FRAC_PARENT_ENERGY_GIVEN_TO_ORG_AT_BIRTH 0.5  # Fraction of energy given to offspring.
 FRAC_ENERGY_DECAY_AT_ORG_BIRTH 0.05         # Fraction of energy lost due to decay during reproduction.
 FRAC_ENERGY_DECAY_AT_DEME_BIRTH 1.0
-NUM_INST_EXC_BEFORE_0_ENERGY 1000000         # Number of instructions executed before energy is exhausted.
+NUM_CYCLES_EXC_BEFORE_0_ENERGY 1000000         # Number of instructions executed before energy is exhausted.
 ENERGY_CAP -1                          # Maximun amount of energy that can be stored in an organism.  -1 means the cap is set to Max Int
 ENERGY_VERBOSE 0                       # Print energy and merit values. 0/1 (off/on)




More information about the Avida-cvs mailing list