[Avida-SVN] r3338 - in branches/interrupt: documentation source/actions source/analyze source/classification source/cpu source/drivers source/main source/targets/avida-viewer source/tools source/utils/hist_map source/utils/process_map tests tests/collect_specification_analyze tests/collect_specification_analyze/config tests/collect_specification_analyze/expected tests/collect_specification_analyze/expected/data tests/interruptModel_quorumSensing

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Thu Jun 25 13:57:37 PDT 2009


Author: beckma24
Date: 2009-06-25 16:57:37 -0400 (Thu, 25 Jun 2009)
New Revision: 3338

Added:
   branches/interrupt/tests/collect_specification_analyze/
   branches/interrupt/tests/collect_specification_analyze/config/
   branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg
   branches/interrupt/tests/collect_specification_analyze/config/avida.cfg
   branches/interrupt/tests/collect_specification_analyze/config/default-classic.org
   branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop
   branches/interrupt/tests/collect_specification_analyze/config/environment.9resource
   branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg
   branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg
   branches/interrupt/tests/collect_specification_analyze/expected/
   branches/interrupt/tests/collect_specification_analyze/expected/data/
   branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat
   branches/interrupt/tests/collect_specification_analyze/test_list
Removed:
   branches/interrupt/tests/collect_specification_analyze/config/
   branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg
   branches/interrupt/tests/collect_specification_analyze/config/avida.cfg
   branches/interrupt/tests/collect_specification_analyze/config/default-classic.org
   branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop
   branches/interrupt/tests/collect_specification_analyze/config/environment.9resource
   branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg
   branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg
   branches/interrupt/tests/collect_specification_analyze/expected/
   branches/interrupt/tests/collect_specification_analyze/expected/data/
   branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat
   branches/interrupt/tests/collect_specification_analyze/test_list
   branches/interrupt/tests/interruptModel_quorumSensing/expected/
Modified:
   branches/interrupt/documentation/analyze.html
   branches/interrupt/source/actions/DriverActions.cc
   branches/interrupt/source/actions/EnvironmentActions.cc
   branches/interrupt/source/actions/PopulationActions.cc
   branches/interrupt/source/actions/PrintActions.cc
   branches/interrupt/source/actions/SaveLoadActions.cc
   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/cHardwareCPU.cc
   branches/interrupt/source/cpu/cHardwareCPU.h
   branches/interrupt/source/drivers/cDefaultAnalyzeDriver.h
   branches/interrupt/source/drivers/cDefaultRunDriver.h
   branches/interrupt/source/drivers/cFallbackWorldDriver.h
   branches/interrupt/source/drivers/cWorldDriver.h
   branches/interrupt/source/main/cDeme.cc
   branches/interrupt/source/main/cDeme.h
   branches/interrupt/source/main/cDemePredicate.h
   branches/interrupt/source/main/cGenomeUtil.cc
   branches/interrupt/source/main/cGenomeUtil.h
   branches/interrupt/source/main/cPhenotype.cc
   branches/interrupt/source/main/cPopulation.cc
   branches/interrupt/source/main/cPopulation.h
   branches/interrupt/source/main/cStats.cc
   branches/interrupt/source/main/cStats.h
   branches/interrupt/source/main/cTaskLib.cc
   branches/interrupt/source/main/cTaskLib.h
   branches/interrupt/source/targets/avida-viewer/cTextViewerAnalyzeDriver.h
   branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.cc
   branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.h
   branches/interrupt/source/targets/avida-viewer/cTextViewerDriver_Base.h
   branches/interrupt/source/tools/tArray.h
   branches/interrupt/source/tools/tArrayUtils.h
   branches/interrupt/source/tools/tManagedPointerArray.h
   branches/interrupt/source/tools/tSmartArray.h
   branches/interrupt/source/utils/hist_map/Makefile
   branches/interrupt/source/utils/process_map/Makefile
Log:
merged development r3250:3275 into interrupt branch.  All tests pass.  Remove expected results for test interruptModel_quorumSensing because I added a column to deme_repl.dat

Modified: branches/interrupt/documentation/analyze.html
===================================================================
--- branches/interrupt/documentation/analyze.html	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/documentation/analyze.html	2009-06-25 20:57:37 UTC (rev 3338)
@@ -644,11 +644,12 @@
 </tr>
 <tr>
 	<td><strong>total_task_performance_count</strong> (total # of tasks done)</td>
-  <td><strong>inst.n</strong> (# of times instruction number n is done)</td>
+  <td><strong>inst.n</strong> (# of times instruction #n is done)</td>
   <td><strong>r_tot.n</strong> (amount of resource n added to the organism's store in its lifetime)</td>
 </tr>
 <tr>
 	<td><strong>r_avail.n</strong> (amount of resource n in organism's store)</td>
+	<td><strong>r_spec.n</strong> (# of times specification #n is used)</td>
 </tr>
 </table>
 </div>
@@ -658,6 +659,11 @@
 </p>
 
 <p>
+<b>A note on r_spec.n</b>: This counts nop specifications done by any and all "collect-type" instructions -- that is, any instruction that uses the helper function DoCollect.  If more than one such instruction is included in the instruction set, r_spec.n will include specification counts for both instructions without any differentiation.
+For details on what the specification numbers mean, see cCodeLabel::AsIntUnique.
+</p>
+
+<p>
 If a FIND_LINEAGE was done before the RECALCULATE (or RECALC), the parent
 genotype for each regular genotype will be available, enabling the
 additional formats:

Modified: branches/interrupt/source/actions/DriverActions.cc
===================================================================
--- branches/interrupt/source/actions/DriverActions.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/actions/DriverActions.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -40,6 +40,14 @@
   void Process(cAvidaContext& ctx) { m_world->GetDriver().SetDone(); }
 };
 
+class cActionPause : public cAction
+{
+public:
+  cActionPause(cWorld* world, const cString& args) : cAction(world, args) { ; }
+  static const cString GetDescription() { return "No Arguments"; }
+  void Process(cAvidaContext& ctx) { m_world->GetDriver().SetPause(); }
+};
+
 class cActionExitAveLineageLabelGreater : public cAction
 {
 private:
@@ -197,6 +205,7 @@
   action_lib->Register<cActionExitAveGeneration>("ExitAveGeneration");
   action_lib->Register<cActionExitElapsedTime>("ExitElapsedTime");
   action_lib->Register<cActionStopFastForward>("StopFastForward");
+  action_lib->Register<cActionPause>("Pause");
 
   // @DMB - The following actions are DEPRECATED aliases - These will be removed in 2.7.
   action_lib->Register<cActionExit>("exit");

Modified: branches/interrupt/source/actions/EnvironmentActions.cc
===================================================================
--- branches/interrupt/source/actions/EnvironmentActions.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/actions/EnvironmentActions.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -921,6 +921,29 @@
   }
 };
 
+class cActionSetFracDemeTreatable : public cAction {
+private:
+	double factionTreatable; // total number of unique event to create; they may overlab
+	
+public:
+	cActionSetFracDemeTreatable(cWorld* world, const cString& args) : cAction(world, args), factionTreatable(0.0) {
+		cString largs(args);
+		if (largs.GetSize()) factionTreatable = largs.PopWord().AsDouble();
+	}
+	
+	static const cString GetDescription() { return "Arguments: <double factionTreatable>"; }
+	
+	void Process(cAvidaContext& ctx) {
+		cPopulation& pop = m_world->GetPopulation();
+		int numDemes = pop.GetNumDemes();
+		for(int i = 0; i < numDemes; i++) {
+			if(ctx.GetRandom().P(factionTreatable))
+				pop.GetDeme(i).setTreatable(true);
+			else
+				pop.GetDeme(i).setTreatable(false);
+		}
+	}
+};
 
 class cActionSetConfig : public cAction
 {
@@ -951,6 +974,7 @@
 
 void RegisterEnvironmentActions(cActionLibrary* action_lib)
 {
+	action_lib->Register<cActionSetFracDemeTreatable>("SetFracDemeTreatable");
   action_lib->Register<cActionDelayedDemeEvent>("DelayedDemeEvent");
   action_lib->Register<cActionDelayedDemeEventsPerSlots>("DelayedDemeEventsPerSlots");
   action_lib->Register<cActionInjectResource>("InjectResource");

Modified: branches/interrupt/source/actions/PopulationActions.cc
===================================================================
--- branches/interrupt/source/actions/PopulationActions.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/actions/PopulationActions.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -30,6 +30,7 @@
 #include "cGenome.h"
 #include "cGenomeUtil.h"
 #include "cHardwareManager.h"
+#include "cIntSum.h"
 #include "cOrgMessagePredicate.h"
 #include "cPopulation.h"
 #include "cPopulationCell.h"
@@ -895,8 +896,183 @@
 	}
 };
 
+/*
+ Randomly removes organisms proportional to number of a specific instruction in genome.
+ Proportion is based on instruction count weight and exponent.
+ 
+ Parameters:
+ 1. instruction type (string) default: "nand"
+  - The type of instruction in question.
+ 2. weight value multiplied by instruction count
+ 3. exponent applied to weighted instruction count
+ */
+class cAction_TherapyStructuralNumInst : public cAction {
+private:
+	cString m_inst;
+	double m_exprWeight;
+	double m_exponent;
+	int m_printUpdate;
+	cIntSum m_totalkilled;
+	cDoubleSum m_killProd;
 
+public:
+	cAction_TherapyStructuralNumInst(cWorld* world, const cString& args) : cAction(world, args), m_inst("nand"), m_exprWeight(1.0), m_exponent(1.0), m_printUpdate(100)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_inst = largs.PopWord();
+		if (largs.GetSize()) m_exprWeight = largs.PopWord().AsDouble();
+		if (largs.GetSize()) m_exponent = largs.PopWord().AsDouble();
+		if (largs.GetSize()) m_printUpdate = largs.PopWord().AsInt();
+		m_totalkilled.Clear();
+		m_killProd.Clear();
+	}
+	
+	static const cString GetDescription() { return "Arguments: [cString inst=nand] [double exprWeight=1.0] [double exponent=1.0(linear)]"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int totalkilled = 0;
+		cDoubleSum currentKillProb;
+		currentKillProb.Clear();
+
+		// for each deme in the population...
+		cPopulation& pop = m_world->GetPopulation();
+		const int numDemes = pop.GetNumDemes();
+		for (int demeCounter = 0; demeCounter < numDemes; ++demeCounter) {
+			cDeme& currentDeme = pop.GetDeme(demeCounter);
+			
+			// if deme treatable?
+			if(currentDeme.IsTreatableNow() == false)
+				continue; //No, go to next deme
+			
+			//Yes
+			for(int cellInDeme = 0; cellInDeme < currentDeme.GetSize(); ++cellInDeme) {
+				cPopulationCell& cell = currentDeme.GetCell(cellInDeme);
+
+				if (cell.IsOccupied() == false)
+					continue;
+				
+				// count the number of target instructions in the genome
+				int count = cGenomeUtil::CountInst(cell.GetOrganism()->GetGenome(), m_world->GetHardwareManager().GetInstSet().GetInst(m_inst));
+
+				double killprob = min(pow(m_exprWeight*count,m_exponent), 100.0)/100.0;
+				// cout << count << " " << killprob << endl;
+				currentKillProb.Add(killprob);
+				// decide if it should be killed or not, based on the kill probability
+				if (ctx.GetRandom().P(killprob)) {
+					m_world->GetPopulation().KillOrganism(cell);
+					++totalkilled;
+				}
+			}
+		}
+		m_totalkilled.Add(totalkilled);
+		m_killProd.Add(currentKillProb.Average());
+			
+		const int update = m_world->GetStats().GetUpdate();
+		if(update % m_printUpdate == 0) {
+			cDataFile& df = m_world->GetDataFile("TherapyStructuralNumInst_kill.dat");
+			df.WriteComment("Number of organisms killed by structural therapy NumInst");
+			df.Write(update, "Update");
+			df.Write(m_totalkilled.Average(), "Mean organisms killed per update since last print");
+			df.Write(m_killProd.Average(), "Mean organism kill probablity");
+			df.Endl();
+			m_totalkilled.Clear();
+			m_killProd.Clear();
+		}
+	}
+};
+
 /*
+ Randomly removes organisms proportional to minimum distance between two instances of the same instruction in its genome.
+ Proportion is based on instruction count weight and exponent.
+ 
+ Parameters:
+ 1. instruction type (string) default: "nand"
+ - The type of instruction in question.
+ 2. weight value multiplied by instruction count
+ 3. exponent applied to weighted instruction count
+ */
+class cAction_TherapyStructuralRatioDistBetweenNearest : public cAction {
+private:
+	cString m_inst;
+	double m_exprWeight;
+	double m_exponent;
+	int m_printUpdate;
+	cIntSum m_totalkilled;
+	cDoubleSum m_killProd;
+	
+public:
+	cAction_TherapyStructuralRatioDistBetweenNearest(cWorld* world, const cString& args) : cAction(world, args), m_inst("nand"), m_exprWeight(1.0), m_exponent(1.0), m_printUpdate(100)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_inst = largs.PopWord();
+		if (largs.GetSize()) m_exprWeight = largs.PopWord().AsDouble();
+		if (largs.GetSize()) m_exponent = largs.PopWord().AsDouble();
+		if (largs.GetSize()) m_printUpdate = largs.PopWord().AsInt();
+		m_totalkilled.Clear();
+		m_killProd.Clear();
+	}
+	
+	static const cString GetDescription() { return "Arguments: [cString inst=nand] [double exprWeight=1.0] [double exponent=1.0(linear)] [int print=100]"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int totalkilled = 0;
+		cDoubleSum currentKillProb;
+		currentKillProb.Clear();
+		// for each deme in the population...
+		cPopulation& pop = m_world->GetPopulation();
+		const int numDemes = pop.GetNumDemes();
+
+		for (int demeCounter = 0; demeCounter < numDemes; ++demeCounter) {
+			cDeme& currentDeme = pop.GetDeme(demeCounter);
+			
+			// if deme treatable?
+			if(currentDeme.IsTreatableNow() == false)
+				continue; //No, go to next deme
+			
+			//Yes
+			for(int cellInDeme = 0; cellInDeme < currentDeme.GetSize(); ++cellInDeme) {
+				cPopulationCell& cell = currentDeme.GetCell(cellInDeme);
+				
+				if (cell.IsOccupied() == false)
+					continue;
+				
+				// count the number of target instructions in the genome
+				const cGenome& genome = cell.GetOrganism()->GetGenome();
+				const double genomeSize = static_cast<double>(genome.GetSize());
+				int minDist = cGenomeUtil::MinDistBetween(genome, m_world->GetHardwareManager().GetInstSet().GetInst(m_inst));
+				
+				int ratioNumerator = min(genomeSize, pow(m_exprWeight*minDist, m_exponent));
+				double killprob = (genomeSize - static_cast<double>(ratioNumerator))/genomeSize;
+				// cout<<minDist << " " << killprob<<endl;
+				currentKillProb.Add(killprob);
+				// decide if it should be killed or not, based on the kill probability
+				if (ctx.GetRandom().P(killprob)) {
+					m_world->GetPopulation().KillOrganism(cell);
+					++totalkilled;
+				}
+			}
+		}
+		m_totalkilled.Add(totalkilled);
+		m_killProd.Add(currentKillProb.Average());
+		
+		const int update = m_world->GetStats().GetUpdate();
+		if(update % m_printUpdate == 0) {
+			cDataFile& df = m_world->GetDataFile("TherapyStructuralRatioDistBetweenNearest_kill.dat");
+			df.WriteComment("Number of organisms killed by structural therapy RatioDistBetweenNearest");
+			df.Write(update, "Update");
+			df.Write(m_totalkilled.Average(), "Mean organisms killed per update since last print");
+			df.Write(m_killProd.Average(), "Mean organism kill probablity");
+			df.Endl();
+			m_totalkilled.Clear();
+			m_killProd.Clear();
+		}
+	}
+};
+
+
+/*
  In avida.cfg, when BASE_MERIT_METHOD is set to 6 (Merit prop. to num times MERIT_BONUS_INST is in genome), 
  the merit is incremented by MERIT_BONUS_EFFECT if MERIT_BONUS_EFFECT is positive and decremented by
  MERIT_BONUS_EFFECT if it is negative. For positive values the counting starts at 1, for negative values it starts
@@ -2892,16 +3068,17 @@
     {
       double level;
       int target_cell;
+      cPopulation& pop = m_world->GetPopulation();
       int res_id = m_world->GetPopulation().GetResourceCount().GetResourceCountID(m_resname);
       
       assert(res_id != -1);
       
       for(int i=0; i < m_numkills; i++) {
-        target_cell = m_world->GetRandom().GetInt(0, m_world->GetPopulation().GetSize()-1);
-        level = m_world->GetPopulation().GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
+        target_cell = m_world->GetRandom().GetInt(0, pop.GetSize()-1);
+        level = pop.GetResourceCount().GetSpatialResource(res_id).GetAmount(target_cell);
         
         if(level > m_threshold) {
-          m_world->GetPopulation().KillOrganism(m_world->GetPopulation().GetCell(target_cell));
+          pop.KillOrganism(pop.GetCell(target_cell));
           m_world->GetStats().IncNumOrgsKilled();
         }
       }
@@ -2911,7 +3088,6 @@
 
 
 
-
 /*
  Kill a percentage of organisms in all demes
  
@@ -2920,7 +3096,7 @@
  */
 
 class cActionKillDemePercent : public cAction
-  {
+{
   private:
     double m_pctkills;
   public:
@@ -2933,29 +3109,77 @@
       assert(m_pctkills <= 1);
     }
     
-    static const cString GetDescription() { return "Arguments: [int pctkills=0.0]"; }
+    static const cString GetDescription() { return "Arguments: [double pctkills=0.0]"; }
     
     void Process(cAvidaContext& ctx)
     {
       int target_cell;
-
-      for (int d = 0; d < m_world->GetPopulation().GetNumDemes(); d++) {
-        for (int c = 0; c < m_world->GetPopulation().GetDeme(d).GetWidth() * m_world->GetPopulation().GetDeme(d).GetHeight(); c++) {
-          target_cell = m_world->GetPopulation().GetDeme(d).GetCellID(c); 
+      cPopulation& pop = m_world->GetPopulation();
+      
+      for (int d = 0; d < pop.GetNumDemes(); d++) {
+        
+        cDeme &deme = pop.GetDeme(d);
+                
+        if(deme.IsTreatableNow()) {
+        
+          for (int c = 0; c < deme.GetWidth() * deme.GetHeight(); c++) {
+            target_cell = deme.GetCellID(c); 
           
-          if( m_world->GetRandom().GetDouble() < m_pctkills) {
-            m_world->GetPopulation().KillOrganism(m_world->GetPopulation().GetCell(target_cell));
-            m_world->GetStats().IncNumOrgsKilled();
-          }
+            if(ctx.GetRandom().P(m_pctkills)) {
+              pop.KillOrganism(pop.GetCell(target_cell));
+              m_world->GetStats().IncNumOrgsKilled();
+            }
           
-        } //End iterating through all cells
+          } //End iterating through all cells
+           
+        } //End if deme is treatable
         
       } //End iterating through all demes
       
     } //End Process()
-  };
+};
 
 
+/*
+ Set the ages at which treatable demes can be treated
+ 
+ Parameters:
+ - 1+ age numbers at which a deme may be treated (int)
+ */
+
+class cActionSetDemeTreatmentAges : public cAction
+{
+private:
+  std::set<int> treatment_ages;
+public:
+  static const cString GetDescription() { return "Arguments: <int treatment age>+"; }
+  
+  cActionSetDemeTreatmentAges(cWorld* world, const cString& args) : cAction(world, args)
+  {
+    cString largs(args);
+    while (largs.GetSize()) {
+      treatment_ages.insert(largs.PopWord().AsInt());
+    }
+  }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    for (int d = 0; d < m_world->GetPopulation().GetNumDemes(); d++) {
+      cDeme& deme = m_world->GetPopulation().GetDeme(d);
+      
+      if(deme.isTreatable()) {
+        for (std::set<int>::iterator it = treatment_ages.begin(); it != treatment_ages.end(); it++) {
+          deme.AddTreatmentAge(*it);
+        }
+      }
+      
+    } //End iterating through demes
+    
+  } //End Process()
+  
+};
+
+
 void RegisterPopulationActions(cActionLibrary* action_lib)
 {
   action_lib->Register<cActionInject>("Inject");
@@ -2975,6 +3199,12 @@
 	action_lib->Register<cActionKillInstLimit>("KillInstLimit");
 	action_lib->Register<cActionKillInstPair>("KillInstPair");
   action_lib->Register<cActionKillProb>("KillProb");
+	
+	// Theraputic deme actions
+	action_lib->Register<cAction_TherapyStructuralNumInst>("TherapyStructuralNumInst");
+	action_lib->Register<cAction_TherapyStructuralRatioDistBetweenNearest>("TherapyStructuralRatioDistBetweenNearest");
+	
+	
   action_lib->Register<cActionToggleRewardInstruction>("ToggleRewardInstruction");
   action_lib->Register<cActionToggleFitnessValley>("ToggleFitnessValley");
   action_lib->Register<cActionKillProb>("KillRate");
@@ -3070,4 +3300,5 @@
   action_lib->Register<cActionDisconnectCells>("disconnect_cells");
   action_lib->Register<cActionSwapCells>("swap_cells");
   action_lib->Register<cActionKillDemePercent>("KillDemePercent");
+  action_lib->Register<cActionSetDemeTreatmentAges>("SetDemeTreatmentAges");
 }

Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/actions/PrintActions.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -102,6 +102,10 @@
 STATS_OUT_FILE(PrintSleepData,              sleep.dat           );
 STATS_OUT_FILE(PrintCompetitionData,        competition.dat     );
 STATS_OUT_FILE(PrintDemeReplicationData,    deme_repl.dat       );
+STATS_OUT_FILE(PrintDemeTreatableReplicationData,    deme_repl_treatable.dat       );
+STATS_OUT_FILE(PrintDemeUntreatableReplicationData,  deme_repl_untreatable.dat       );
+STATS_OUT_FILE(PrintDemeTreatableCount,    deme_treatable.dat       );
+
 STATS_OUT_FILE(PrintDemeCompetitionData,    deme_compete.dat);
 STATS_OUT_FILE(PrintDemeFoundersData,       deme_founders.dat   );
 STATS_OUT_FILE(PrintPerDemeTasksData,       per_deme_tasks.dat      );
@@ -121,6 +125,7 @@
 
 STATS_OUT_FILE(PrintCurrentTaskCounts,      curr_task_counts.dat);
 STATS_OUT_FILE(PrintGermlineData,           germline.dat        );
+STATS_OUT_FILE(PrintDemeResourceThresholdPredicate,     deme_resourceThresholdPredicate.dat );
 STATS_OUT_FILE(PrintPredicatedMessages,     messages.dat        );
 STATS_OUT_FILE(PrintCellData,               cell_data.dat       );
 STATS_OUT_FILE(PrintCurrentOpinions,        opinions.dat        );
@@ -139,6 +144,10 @@
 STATS_OUT_FILE(PrintDirectReciprocityData,         reciprocity.dat);
 STATS_OUT_FILE(PrintStringMatchData,         stringmatch.dat);
 
+// group formation 
+STATS_OUT_FILE(PrintGroupsFormedData,         groupformation.dat);
+
+
 #define POP_OUT_FILE(METHOD, DEFAULT)                                                     /*  1 */ \
 class cAction ## METHOD : public cAction {                                                /*  2 */ \
 private:                                                                                  /*  3 */ \
@@ -157,6 +166,7 @@
 POP_OUT_FILE(PrintPhenotypeStatus,     phenotype_status.dat);
 POP_OUT_FILE(PrintDemeTestamentStats,  deme_testament.dat  );
 POP_OUT_FILE(DumpDemeBoundaryData,     deme_boundary  ); // file name is dummy
+POP_OUT_FILE(PrintCurrentMeanDemeDensity,  deme_currentMeanDensity.dat  );
 
 
 class cActionPrintData : public cAction
@@ -3041,7 +3051,9 @@
   action_lib->Register<cActionPrintPhenotypeStatus>("PrintPhenotypeStatus");
   
   action_lib->Register<cActionPrintDemeTestamentStats>("PrintDemeTestamentStats");
-  
+	action_lib->Register<cActionPrintCurrentMeanDemeDensity>("PrintCurrentMeanDemeDensity");
+
+	action_lib->Register<cActionPrintDemeResourceThresholdPredicate>("PrintDemeResourceThresholdPredicate");
 	action_lib->Register<cActionPrintPredicatedMessages>("PrintPredicatedMessages");
 	action_lib->Register<cActionPrintCellData>("PrintCellData");
 	action_lib->Register<cActionPrintCurrentOpinions>("PrintCurrentOpinions");
@@ -3059,6 +3071,11 @@
   action_lib->Register<cActionPrintDemeSpatialSleep>("PrintDemeSpatialSleepStats");
   action_lib->Register<cActionPrintDemeResources>("PrintDemeResourceStats");
   action_lib->Register<cActionPrintDemeReplicationData>("PrintDemeReplicationData");
+  action_lib->Register<cActionPrintDemeTreatableReplicationData>("PrintDemeTreatableReplicationData");
+  action_lib->Register<cActionPrintDemeUntreatableReplicationData>("PrintDemeUntreatableReplicationData");
+  action_lib->Register<cActionPrintDemeTreatableCount>("PrintDemeTreatableCount");
+
+	
   action_lib->Register<cActionPrintDemeCompetitionData>("PrintDemeCompetitionData");
   action_lib->Register<cActionPrintDemeFoundersData>("PrintDemeFoundersData");
   action_lib->Register<cActionPrintGermlineData>("PrintGermlineData");
@@ -3195,6 +3212,8 @@
   action_lib->Register<cActionPrintStringMatchData>("PrintStringMatchData");
 	action_lib->Register<cActionPrintShadedAltruists>("PrintShadedAltruists");
 
+	// Group Formation
+	action_lib->Register<cActionPrintGroupsFormedData>("PrintGroupsFormedData");
 	
   action_lib->Register<cActionSetVerbose>("VERBOSE");
 }

Modified: branches/interrupt/source/actions/SaveLoadActions.cc
===================================================================
--- branches/interrupt/source/actions/SaveLoadActions.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/actions/SaveLoadActions.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -130,6 +130,45 @@
 
 
 /*
+ Sets up a population based on a dump file such as written out by
+ detail_pop. It is also possible to append a history file to the dump
+ file, in order to preserve the history of a previous run.
+ 
+ Parameters:
+   filename (string)
+     The name of the file to open.
+   update (int) *optional*
+     ??
+ */
+class cActionLoadStructuredPopulation : public cAction
+{
+private:
+  cString m_filename;
+  int m_update;
+  
+public:
+  cActionLoadStructuredPopulation(cWorld* world, const cString& args) : cAction(world, args), m_filename(""), m_update(-1)
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();
+    if (largs.GetSize()) m_update = largs.PopWord().AsInt();
+  }
+  
+  static const cString GetDescription() { return "Arguments: <cString fname> [int update=-1]"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    // set the update if requested
+    if (m_update >= 0) m_world->GetStats().SetCurrentUpdate(m_update);
+    
+    if (!m_world->GetPopulation().LoadStructuredPopulation(m_filename)) {
+      m_world->GetDriver().RaiseFatalException(-1, "failed to load structured population");
+    }
+  }
+};
+
+
+/*
  Writes out a line of data for each genotype in the current population. The
  line contains the genome as string, the number of organisms of that genotype,
  and the genotype ID.
@@ -198,6 +237,29 @@
 };
 
 
+class cActionSaveStructuredPopulation : public cAction
+{
+private:
+  cString m_filename;
+  
+public:
+  cActionSaveStructuredPopulation(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+  {
+    cString largs(args);
+    if (largs.GetSize()) m_filename = largs.PopWord();
+  }
+  
+  static const cString GetDescription() { return "Arguments: [string fname='']"; }
+  
+  void Process(cAvidaContext& ctx)
+  {
+    cString filename(m_filename);
+    if (filename == "") filename.Set("detail-%d.spop", m_world->GetStats().GetUpdate());
+    m_world->GetPopulation().SaveStructuredPopulation(filename);
+  }
+};
+
+
 /*
  Like detail_pop, but for sexual populations. 
  Info for both parents is writen out.
@@ -339,9 +401,11 @@
   action_lib->Register<cActionLoadClone>("LoadClone");
 
   action_lib->Register<cActionLoadPopulation>("LoadPopulation");
+  action_lib->Register<cActionLoadStructuredPopulation>("LoadStructuredPopulation");
 
   action_lib->Register<cActionDumpPopulation>("DumpPopulation");
   action_lib->Register<cActionSavePopulation>("SavePopulation");
+  action_lib->Register<cActionSaveStructuredPopulation>("SaveStructuredPopulation");
   action_lib->Register<cActionSaveSexPopulation>("SaveSexPopulation");
   action_lib->Register<cActionSaveParasitePopulation>("SaveParasitePopulation");
   action_lib->Register<cActionSaveHistoricPopulation>("SaveHistoricPopulation");

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -82,6 +82,7 @@
   , internal_task_qualities(0)
   , rbins_total(0)
   , rbins_avail(0)
+  , collect_spec_counts(0)
   , fitness_ratio(0.0)
   , efficiency_ratio(0.0)
   , comp_merit_ratio(0.0)
@@ -136,6 +137,7 @@
   , internal_task_qualities(0)
   , rbins_total(0)
   , rbins_avail(0)
+  , collect_spec_counts(0)
   , fitness_ratio(0.0)
   , efficiency_ratio(0.0)
   , comp_merit_ratio(0.0)
@@ -179,6 +181,7 @@
   , internal_task_qualities(_gen.internal_task_qualities)
   , rbins_total(_gen.rbins_total)
   , rbins_avail(_gen.rbins_avail)
+  , collect_spec_counts(_gen.collect_spec_counts)
   , fitness_ratio(_gen.fitness_ratio)
   , efficiency_ratio(_gen.efficiency_ratio)
   , comp_merit_ratio(_gen.comp_merit_ratio)
@@ -331,6 +334,8 @@
            ("r_avail", &cAnalyzeGenotype::DescRAvail, &cAnalyzeGenotype::GetRBinAvail));
   dcm->Add("prob_task", new tDataEntryOfType<cAnalyzeGenotype, double (int)>
            ("prob_task", &cAnalyzeGenotype::DescTaskProb, &cAnalyzeGenotype::GetTaskProbability, 5));
+  dcm->Add("r_spec", new tDataEntryOfType<cAnalyzeGenotype, int (int)>
+           ("r_spec", &cAnalyzeGenotype::DescRSpec, &cAnalyzeGenotype::GetRSpec));
   
   
   // The remaining values should actually go in a separate list called
@@ -611,6 +616,7 @@
   internal_task_qualities = likely_phenotype->GetLastInternalTaskQuality();
   rbins_total           = likely_phenotype->GetLastRBinsTotal();
   rbins_avail           = likely_phenotype->GetLastRBinsAvail();
+  collect_spec_counts   = likely_phenotype->GetLastCollectSpecCounts();
 
   // Setup a new parent stats if we have a parent to work with.
   if (parent_genotype != NULL) {

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -159,6 +159,7 @@
   tArray<double> internal_task_qualities;
   tArray<double> rbins_total;
   tArray<double> rbins_avail;
+  tArray<int> collect_spec_counts;
   tArray<int> m_env_inputs;
 
   // Group 3 : Stats requiring parental genotype (Also from test CPUs)
@@ -458,6 +459,12 @@
     return rbins_avail[resource_id];
   }
   cString DescRAvail(int resource_id) const { return cStringUtil::Stringf("Resource %d Available", resource_id);}
+  
+  int GetRSpec(int spec_id) const {
+    if (spec_id >= collect_spec_counts.GetSize() || spec_id < 0) return -1;
+    return collect_spec_counts[spec_id];
+  }
+  cString DescRSpec(int spec_id) const { return cStringUtil::Stringf("# times specification %d used", spec_id);}
 
   // Comparisons...  Compares a genotype to the "previous" one, which is
   // passed in, in one specified phenotype.

Modified: branches/interrupt/source/classification/cClassificationManager.cc
===================================================================
--- branches/interrupt/source/classification/cClassificationManager.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/classification/cClassificationManager.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -718,10 +718,10 @@
   return true;
 }
 
-bool cClassificationManager::DumpHistoricSexSummary(ofstream& fp)
+bool cClassificationManager::DumpHistoricSexSummary(ofstream& fp, bool header)
 {
   m_genotype_ctl->ResetHistoric(0);
-  DumpDetailSexHeading(fp);
+  if (header) DumpDetailSexHeading(fp);
   for (int i = 0; i < m_genotype_ctl->GetHistoricCount(); i++) {
     DumpDetailedSexEntry(m_genotype_ctl->Get(0), fp);
     m_genotype_ctl->Next(0);

Modified: branches/interrupt/source/classification/cClassificationManager.h
===================================================================
--- branches/interrupt/source/classification/cClassificationManager.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/classification/cClassificationManager.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -158,7 +158,7 @@
   bool DumpDetailedSummary(std::ofstream& fp, bool print_mut_steps = false);
   bool DumpDetailedSexSummary(std::ofstream& fp);
   bool DumpHistoricSummary(std::ofstream& fp, int back_dist, bool print_mut_steps = false);
-  bool DumpHistoricSexSummary(std::ofstream& fp);
+  bool DumpHistoricSexSummary(std::ofstream& fp, bool header = true);
   void DumpDetailedEntry(cGenotype* genotype, std::ofstream& fp, bool print_mut_steps = false);
   void DumpDetailedSexEntry(cGenotype* genotype, std::ofstream& fp);
   

Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -392,7 +392,10 @@
     tInstLibEntry<tMethod>("and", &cHardwareCPU::Inst_And),
     tInstLibEntry<tMethod>("order", &cHardwareCPU::Inst_Order),
     tInstLibEntry<tMethod>("xor", &cHardwareCPU::Inst_Xor),
-    
+
+		// treatable instructions
+		tInstLibEntry<tMethod>("nand-treatable", &cHardwareCPU::Inst_NandTreatable, nInstFlag::DEFAULT, "Nand BX by CX and place the result in ?BX?, fails if deme is treatable"),
+		
     tInstLibEntry<tMethod>("copy", &cHardwareCPU::Inst_Copy),
     tInstLibEntry<tMethod>("read", &cHardwareCPU::Inst_ReadInst),
     tInstLibEntry<tMethod>("write", &cHardwareCPU::Inst_WriteInst),
@@ -828,8 +831,10 @@
 		tInstLibEntry<tMethod>("if-donor",  &cHardwareCPU::Inst_IfDonor, nInstFlag::STALL),
 		tInstLibEntry<tMethod>("prod-string",  &cHardwareCPU::Inst_ProduceString, nInstFlag::STALL),
 		
+		// Group formation instructions
+		tInstLibEntry<tMethod>("join-group", &cHardwareCPU::Inst_JoinGroup, nInstFlag::STALL),
+		tInstLibEntry<tMethod>("orgs-in-group", &cHardwareCPU::Inst_NumberOrgsInGroup, nInstFlag::STALL),
 		
-		
     // Must always be the last instruction in the array
     tInstLibEntry<tMethod>("NULL", &cHardwareCPU::Inst_Nop, 0, "True no-operation instruction: does nothing"),
   };
@@ -2813,6 +2818,19 @@
   return true;
 }
 
+bool cHardwareCPU::Inst_NandTreatable(cAvidaContext& ctx)
+{
+/*	
+	if(!m_organism->GetDeme()->isTreatable() && m_world->GetRandom().P(probFail))
+		return true;
+	
+  const int dst = FindModifiedRegister(REG_BX);
+  const int op1 = REG_BX;
+  const int op2 = REG_CX;
+  GetRegister(dst) = ~(GetRegister(op1) & GetRegister(op2));
+  */return true;
+}
+
 bool cHardwareCPU::Inst_Nor(cAvidaContext& ctx)
 {
   const int dst = FindModifiedRegister(REG_BX);
@@ -9659,3 +9677,41 @@
 	return true;
 }
 
+//! An organism joins a group by setting it opinion to the group id. 
+bool cHardwareCPU::Inst_JoinGroup(cAvidaContext& ctx)
+{
+	int opinion;
+	// Check if the org is currently part of a group
+	assert(m_organism != 0);
+  if(m_organism->HasOpinion()) {
+		opinion = m_organism->GetOpinion().first;
+		// subtract org from group
+		m_world->GetPopulation().LeaveGroup(opinion);
+  }
+	
+	
+	// Call the set opinion instruction, which does all the dirty work.
+	Inst_SetOpinion(ctx);
+	
+	// Add org to group count
+	opinion = m_organism->GetOpinion().first;	
+	m_world->GetPopulation().JoinGroup(opinion);
+	return true;
+}
+
+//! Gets the number of organisms in the current organism's group 
+//! and places the value in the ?CX? register
+bool cHardwareCPU::Inst_NumberOrgsInGroup(cAvidaContext& ctx)
+{
+	int num_orgs = 0;
+	assert(m_organism != 0);
+	const int num_org_reg = FindModifiedRegister(REG_CX);
+	int opinion;
+	
+  if(m_organism->HasOpinion()) {
+		opinion = m_organism->GetOpinion().first;
+		num_orgs = m_world->GetPopulation().NumberOfOrganismsInGroup(opinion);
+  }
+	GetRegister(num_org_reg) = num_orgs;
+	return true;
+}

Modified: branches/interrupt/source/cpu/cHardwareCPU.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/cpu/cHardwareCPU.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -470,6 +470,9 @@
   bool Inst_Order(cAvidaContext& ctx);
   bool Inst_Xor(cAvidaContext& ctx);
 
+  // Double Argument Math that are treatable
+	bool Inst_NandTreatable(cAvidaContext& ctx);
+
   // Biological
   bool Inst_Copy(cAvidaContext& ctx);
   bool Inst_ReadInst(cAvidaContext& ctx);
@@ -944,8 +947,17 @@
   bool Inst_GetNeighborhood(cAvidaContext& ctx);
 	//! Test if the current neighborhood has changed from that in the organism's memory.
 	bool Inst_IfNeighborhoodChanged(cAvidaContext& ctx);
+
 	
+// -------- Group Formation Support --------
+public:
+	//! An organism joins a group by setting it opinion to the group id. 
+	bool Inst_JoinGroup(cAvidaContext& ctx);
+	//! Returns the number of organisms in the current organism's group
+	bool Inst_NumberOrgsInGroup(cAvidaContext& ctx);
+		
 	
+	
 };
 
 

Modified: branches/interrupt/source/drivers/cDefaultAnalyzeDriver.h
===================================================================
--- branches/interrupt/source/drivers/cDefaultAnalyzeDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/drivers/cDefaultAnalyzeDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -61,6 +61,7 @@
   // Driver Actions
   void SignalBreakpoint() { return; }
   void SetDone() { return; }
+  void SetPause() { return; }
   
   void RaiseException(const cString& in_string);
   void RaiseFatalException(int exit_code, const cString& in_string);

Modified: branches/interrupt/source/drivers/cDefaultRunDriver.h
===================================================================
--- branches/interrupt/source/drivers/cDefaultRunDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/drivers/cDefaultRunDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -57,6 +57,7 @@
   // Driver Actions
   void SignalBreakpoint() { return; }
   void SetDone() { m_done = true; }
+  void SetPause() { return; }
   
   void RaiseException(const cString& in_string);
   void RaiseFatalException(int exit_code, const cString& in_string);

Modified: branches/interrupt/source/drivers/cFallbackWorldDriver.h
===================================================================
--- branches/interrupt/source/drivers/cFallbackWorldDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/drivers/cFallbackWorldDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -42,6 +42,7 @@
   // Driver Actions
   void SignalBreakpoint() { return; }
   void SetDone() { return; }
+  void SetPause() { return; }
   
   void RaiseException(const cString& in_string);
   void RaiseFatalException(int exit_code, const cString& in_string);

Modified: branches/interrupt/source/drivers/cWorldDriver.h
===================================================================
--- branches/interrupt/source/drivers/cWorldDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/drivers/cWorldDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -49,6 +49,7 @@
   // Driver Actions
   virtual void SignalBreakpoint() = 0;
   virtual void SetDone() = 0;
+  virtual void SetPause() = 0;
 
   virtual void RaiseException(const cString& in_string) = 0;
   virtual void RaiseFatalException(int exit_code, const cString& in_string) = 0;

Modified: branches/interrupt/source/main/cDeme.cc
===================================================================
--- branches/interrupt/source/main/cDeme.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cDeme.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -739,7 +739,9 @@
 void cDeme::AddDemeResourceThresholdPredicate(cString resourceName, cString comparisonOperator, double threasholdValue) {
 	cDemeResourceThresholdPredicate* pred = new cDemeResourceThresholdPredicate(resourceName, comparisonOperator, threasholdValue);
 	deme_pred_list.Add(pred);
-	
+
+	cString name = resourceName + " " + comparisonOperator + cStringUtil::Stringf(" %f", threasholdValue);
+	m_world->GetStats().AddDemeResourceThresholdPredicate(name);
 }
 
 void cDeme::AddEventReceivedCenterPred(int times) {
@@ -864,3 +866,19 @@
   return 0;
 }
 
+
+// Return whether or not this deme is treatable at the given age (updates).  If a deme is not treatable,
+// this function will always return false.
+bool cDeme::IsTreatableAtAge(const int age) {
+  
+  if(isTreatable()) {
+		if(treatment_ages.size() == 0) // implies treatable every update
+			return true;
+    set<int>::iterator it;
+    it = treatment_ages.find(age);
+    if(it != treatment_ages.end()) return true;  
+  }
+  
+  return false;
+  
+} //End cDeme::IsTreatableAtAge()

Modified: branches/interrupt/source/main/cDeme.h
===================================================================
--- branches/interrupt/source/main/cDeme.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cDeme.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -24,6 +24,7 @@
 #ifndef cDeme_h
 #define cDeme_h
 
+#include <set>
 #include <vector>
 
 #include "cDemeCellEvent.h"
@@ -58,6 +59,8 @@
   int width; //!< Width of this deme.
 
 	bool replicateDeme;
+	bool treatable;
+  std::set<int> treatment_ages;
 	
 // The following should be moved to cDemePhenotype / cPopulationPhenotype
   int cur_birth_count; //!< Number of organisms that have been born into this deme since reset.
@@ -141,7 +144,7 @@
 	
   
 public:
-  cDeme() : _id(0), width(0), replicateDeme(false), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
+  cDeme() : _id(0), width(0), replicateDeme(false), treatable(false), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
             _age(0), generation(0), total_org_energy(0.0),
             time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(0.0), 
 						MSG_sendFailed(0), MSG_dropped(0), MSG_SuccessfullySent(0), MSG_sent(0),
@@ -181,6 +184,7 @@
 
   int GetOrgCount() const { return cur_org_count; }
   int GetLastOrgCount() const { return last_org_count; }
+	double GetDensity() const { return static_cast<double>(cur_org_count) / static_cast<double>(GetSize()); }
 
   void IncOrgCount() { cur_org_count++; }
   void DecOrgCount() { cur_org_count--; }
@@ -199,6 +203,12 @@
 	
 	bool TestReplication() const { return replicateDeme; }
 	void ReplicateDeme() { replicateDeme = true; }
+	
+	bool isTreatable() const { return treatable; }
+	void setTreatable(bool value) { treatable = value; }
+  void AddTreatmentAge(const int age) { treatment_ages.insert(age); }
+  bool IsTreatableAtAge(const int age);
+  bool IsTreatableNow() { return IsTreatableAtAge(_age); }
 
   int GetSlotFlowRate() const;
   int GetEventsTotal() const { return eventsTotal; }

Modified: branches/interrupt/source/main/cDemePredicate.h
===================================================================
--- branches/interrupt/source/main/cDemePredicate.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cDemePredicate.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -98,7 +98,10 @@
 	void Reset() { previouslySatisfied = false; }
 	bool PreviouslySatisfied() { return previouslySatisfied; }
 	cString GetName() { return cString("cDemeResourceThreshold"); }
-	void UpdateStats(cStats& stats) {;}
+	void UpdateStats(cStats& stats) {
+		cString name = demeResourceName + " " + compareOperator + cStringUtil::Stringf(" %f", resourceThresholdValue);
+		stats.IncDemeResourceThresholdPredicate(name);
+	}
 };
 
 #endif

Modified: branches/interrupt/source/main/cGenomeUtil.cc
===================================================================
--- branches/interrupt/source/main/cGenomeUtil.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cGenomeUtil.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -58,6 +58,43 @@
   return count;
 }
 
+// Returns minimum distance between two instance of inst respecting genome circularity.
+// If only one instance is found then lenght of genome is returned.
+int cGenomeUtil::MinDistBetween(const cGenome& genome, const cInstruction& inst) {
+	const int genomeSize = genome.GetSize();
+	int firstInstance(-1);
+	int secondInstance(-1);
+	int startIndex(0);
+	int minDist(genomeSize);
+
+	while(startIndex < genomeSize) {
+		firstInstance = FindInst(genome, inst, startIndex);
+		startIndex = firstInstance + 1;
+		
+		if(startIndex >= genomeSize)
+			return minDist;
+		
+		secondInstance = FindInst(genome, inst, startIndex);
+	
+		if(firstInstance != -1 and secondInstance != -1) {
+			minDist = min(min(secondInstance-firstInstance, firstInstance+genomeSize-secondInstance), minDist);
+		} else if(secondInstance != -1) {
+			secondInstance = FindInst(genome, inst, 0);
+			if(firstInstance == secondInstance)
+				return minDist;
+			else {
+				assert(secondInstance < firstInstance);
+				minDist = min(secondInstance+genomeSize-firstInstance, minDist);
+			}
+		} else {
+			return minDist;
+		}
+	}
+	assert(false);
+	return -1;
+}
+
+
 int cGenomeUtil::FindOverlap(const cGenome & gen1, const cGenome & gen2,
 			     int offset)
 {

Modified: branches/interrupt/source/main/cGenomeUtil.h
===================================================================
--- branches/interrupt/source/main/cGenomeUtil.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cGenomeUtil.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -43,6 +43,7 @@
   // ========= Detection =========
   static int FindInst(const cGenome& gen, const cInstruction& inst, int start_index = 0);
 	static int CountInst(const cGenome& gen, const cInstruction& inst);
+	static int MinDistBetween(const cGenome& gen, const cInstruction& inst);
 	
   static bool HasInst(const cGenome& gen, const cInstruction& inst)
   {

Modified: branches/interrupt/source/main/cPhenotype.cc
===================================================================
--- branches/interrupt/source/main/cPhenotype.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cPhenotype.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -795,7 +795,7 @@
 
   // A few final changes if the parent was supposed to be be considered
   // a second child on the divide.
-  if(m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
+  if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) {
     gestation_start = 0;
     cpu_cycles_used = 0;
     time_used = 0;

Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cPopulation.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -62,6 +62,12 @@
 #include "cTestCPU.h"
 #include "cCPUTestInfo.h"
 
+#include "tArrayUtils.h"
+#include "tKVPair.h"
+#include "tHashTable.h"
+#include "tManagedPointerArray.h"
+
+
 #include <fstream>
 #include <vector>
 #include <algorithm>
@@ -2776,6 +2782,22 @@
 	m_world->GetDataFileManager().Remove(m_filename);
 }	
 
+void cPopulation::PrintCurrentMeanDemeDensity(const cString& filename) {	
+	cDoubleSum demeDensity;
+	demeDensity.Clear();
+	const int num_demes = deme_array.GetSize();
+	for (int deme_id = 0; deme_id < num_demes; ++deme_id) {
+    const cDeme & cur_deme = deme_array[deme_id];
+		demeDensity.Add(cur_deme.GetDensity());
+	}
+	
+	cDataFile& df = m_world->GetDataFile(filename);
+  df.WriteTimeStamp();
+  df.Write(m_world->GetStats().GetUpdate(), "Update");
+	df.Write(demeDensity.Average(), "Current mean deme density");
+	df.Endl();
+}
+
 // Print some stats about the energy sharing behavior of each deme
 void cPopulation::PrintDemeEnergySharingStats() {
   const int num_demes = deme_array.GetSize();
@@ -2795,7 +2817,7 @@
   double amount_received = 0.0;
   double amount_applied = 0.0;  
   
-  for (int deme_id = 0; deme_id < num_demes; deme_id++) {
+  for (int deme_id = 0; deme_id < num_demes; ++deme_id) {
     const cDeme & cur_deme = deme_array[deme_id];
     
     for (int i = 0; i < cur_deme.GetSize(); i++) {
@@ -4438,29 +4460,11 @@
   return true;
 }
 
-// This class is needed for the next function
-class cTmpGenotype {
-public:
-  int id_num;
-  int parent_id;
-  int num_cpus;
-  int total_cpus;
-  double merit;
-  int update_born;
-  int update_dead;
-  
-  cGenotype *genotype;
-  
-  bool operator<( const cTmpGenotype rhs ) const {
-    return id_num < rhs.id_num; }
-};	
 
-
 bool cPopulation::LoadDumpFile(cString filename, int update)
 {
   // set the update if requested
-  if ( update >= 0 )
-    m_world->GetStats().SetCurrentUpdate(update);
+  if (update >= 0) m_world->GetStats().SetCurrentUpdate(update);
   
   // Clear out the population
   for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
@@ -4478,13 +4482,13 @@
   
   // First, we read in all the genotypes and store them in a list
   
-  vector<cTmpGenotype> genotype_vect;
+  vector<sTmpGenotype> genotype_vect;
   
   for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
     cString cur_line = input_file.GetLine(line_id);
     
     // Setup the genotype for this line...
-    cTmpGenotype tmp;
+    sTmpGenotype tmp;
     tmp.id_num      = cur_line.PopWord().AsInt();
     tmp.parent_id   = cur_line.PopWord().AsInt();
     /*parent_dist =*/          cur_line.PopWord().AsInt();
@@ -4516,9 +4520,9 @@
   sort( genotype_vect.begin(), genotype_vect.end() );
   // set the parents correctly
   
-  vector<cTmpGenotype>::const_iterator it = genotype_vect.begin();
+  vector<sTmpGenotype>::const_iterator it = genotype_vect.begin();
   for ( ; it != genotype_vect.end(); it++ ){
-    vector<cTmpGenotype>::const_iterator it2 = it;
+    vector<sTmpGenotype>::const_iterator it2 = it;
     cGenotype *parent = 0;
     // search backwards till we find the parent
     if ( it2 != genotype_vect.begin() )
@@ -4580,6 +4584,193 @@
 }
 
 
+bool cPopulation::SaveStructuredPopulation(const cString& filename)
+{
+  cDataFile& df = m_world->GetDataFile(filename);
+  df.WriteRawComment("#filetype genotype_data");
+  df.WriteRawComment("#format id parent_id parent2_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence cells");
+  df.WriteComment("");
+  df.WriteComment("Structured Population Dump");
+  df.WriteTimeStamp();
+  
+  // Build up hash table of all current genotypes and the cells in which the organisms reside
+  tHashTable<int, tKVPair<cGenotype*, tArray<int> >* > genotype_map;
+  
+  for (int i = 0; i < cell_array.GetSize(); i++) {
+    if (cell_array[i].IsOccupied()) {
+      cGenotype* genotype = cell_array[i].GetOrganism()->GetGenotype();
+      tKVPair<cGenotype*, tArray<int> >* map_entry = NULL;
+      if (genotype_map.Find(genotype->GetID(), map_entry)) {
+        map_entry->Value().Push(i);
+      } else {
+        map_entry = new tKVPair<cGenotype*, tArray<int> >(genotype, tArray<int>(0));
+        map_entry->Value().Push(i);
+        genotype_map.Add(genotype->GetID(), map_entry);
+      }
+    }
+  }
+  
+  // Output all current genotypes
+  
+  tArray<tKVPair<cGenotype*, tArray<int> >* > genotype_entries;
+  genotype_map.GetValues(genotype_entries);
+  for (int i = 0; i < genotype_entries.GetSize(); i++) {
+    cGenotype* genotype = genotype_entries[i]->Key();
+    
+    df.Write(genotype->GetID(), "Genotype ID");
+    df.Write(genotype->GetAncestorID(0), "Parent 1 Genotype ID");
+    df.Write(genotype->GetAncestorID(1), "Parent 2 Genotype ID");
+    df.Write(genotype->GetParentDistance(), "Parent Distance");
+    df.Write(genotype->GetNumOrganisms(), "Number of currently living organisms");
+    df.Write(genotype->GetTotalOrganisms(), "Total number of organisms that ever existed");
+    df.Write(genotype->GetLength(), "Genome Length");
+    df.Write(genotype->GetMerit(), "Merit");
+    df.Write(genotype->GetGestationTime(), "Gestation Time");
+    df.Write(genotype->GetFitness(), "Fitness");
+    df.Write(genotype->GetUpdateBorn(), "Update Born");
+    df.Write(genotype->GetUpdateDeactivated(), "Update Deactivated");
+    df.Write(genotype->GetDepth(), "Phylogenetic Depth");
+    df.Write(genotype->GetGenome().AsString(), "Genome Sequence");
+    
+    tArray<int>& cells = genotype_entries[i]->Value();
+    cString cellstr;
+    cellstr.Set("%d", cells[0]);
+    for (int cell_i = 1; cell_i < cells.GetSize(); cell_i++) {
+      cellstr.Set("%s,%d", (const char*)cellstr, cells[cell_i]);
+    }
+    df.Write(cellstr, "Occupied Cell IDs");
+    df.Endl();
+    
+    delete genotype_entries[i];
+  }
+  
+  // Output historic genotypes
+  m_world->GetClassificationManager().DumpHistoricSexSummary(df.GetOFStream(), false);
+  
+  m_world->GetDataFileManager().Remove(filename);
+  return true;
+}
+
+
+bool cPopulation::LoadStructuredPopulation(const cString& filename)
+{
+  // @TODO - build in support for verifying population dimensions
+  
+  cInitFile input_file(filename);
+  if (!input_file.WasOpened()) {
+    tConstListIterator<cString> err_it(input_file.GetErrors());
+    const cString* errstr = NULL;
+    while ((errstr = err_it.Next())) m_world->GetDriver().RaiseException(*errstr);
+    return false;
+  }
+  
+  // Clear out the population
+  for (int i = 0; i < cell_array.GetSize(); i++) KillOrganism(cell_array[i]);
+
+  // First, we read in all the genotypes and store them in an array
+  tManagedPointerArray<sTmpGenotype> genotypes(input_file.GetNumLines());
+  const int update = m_world->GetStats().GetUpdate();
+  
+  for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) {
+    cString cur_line = input_file.GetLine(line_id);
+    
+    // Setup the genotype for this line...
+    sTmpGenotype& tmp = genotypes[line_id];
+    tmp.id_num      = cur_line.PopWord().AsInt();
+    tmp.parent_id   = cur_line.PopWord().AsInt();
+    tmp.parent_id2  = cur_line.PopWord().AsInt();    
+    /* parent_dist */ cur_line.PopWord();
+    tmp.num_cpus    = cur_line.PopWord().AsInt();
+    tmp.total_cpus  = cur_line.PopWord().AsInt();
+    /* length */      cur_line.PopWord();
+    tmp.merit 	    = cur_line.PopWord().AsDouble();
+    /* gest_time */   cur_line.PopWord();
+    /* fitness */     cur_line.PopWord();
+    tmp.update_born = cur_line.PopWord().AsInt();
+    tmp.update_dead = cur_line.PopWord().AsInt();
+    /* depth */       cur_line.PopWord();
+    cString name = cStringUtil::Stringf("org-%d", tmp.id_num);
+    cGenome genome(cur_line.PopWord());
+    
+    // Process resident cell ids
+    cString cellstr(cur_line.PopWord());
+    while (cellstr.GetSize()) tmp.cells.Push(cellstr.Pop(',').AsInt());
+    assert(tmp.cells.GetSize() == tmp.num_cpus);
+    
+    // Don't allow birth or death times larger than the current update
+    if (update > tmp.update_born) tmp.update_born = update;
+    if (update > tmp.update_dead) tmp.update_dead = update;
+    
+    tmp.genotype = m_world->GetClassificationManager().GetGenotypeLoaded(genome, tmp.update_born, tmp.id_num);
+    tmp.genotype->SetName(name);
+  }
+  
+  // Sort genotypes in ascending order according to their id_num
+  tArrayUtils::QSort(genotypes);
+  
+  
+  // Set parents correctly
+  for (int gen_i = genotypes.GetSize() - 1; gen_i > 0; gen_i--) {
+    cGenotype* parent1 = NULL;
+    cGenotype* parent2 = NULL;
+    
+    int pid = genotypes[gen_i].parent_id;
+    if (pid != -1) {
+      for (int p_i = gen_i + 1; p_i < genotypes.GetSize(); p_i++) {
+        if (genotypes[p_i].id_num == pid) {
+          parent1 = genotypes[p_i].genotype;
+          break;
+        }
+      }
+    }
+    
+    pid = genotypes[gen_i].parent_id2;
+    if (pid != -1) {
+      for (int p_i = gen_i + 1; p_i < genotypes.GetSize(); p_i++) {
+        if (genotypes[p_i].id_num == pid) {
+          parent2 = genotypes[p_i].genotype;
+          break;
+        }
+      }
+    }    
+    
+    genotypes[gen_i].genotype->SetParent(parent1, parent2);
+  }
+  
+
+  // Process genotypes, inject into organisms as necessary
+  for (int gen_i = genotypes.GetSize() - 1; gen_i > 0; gen_i--) {
+    sTmpGenotype& tmp = genotypes[gen_i];
+    if (tmp.num_cpus == 0) {
+      // historic organism - remove immediately, so that it gets transferred into
+      // the historic database. We change the update temporarily to the
+      // true death time of this organism, so that all stats are correct
+      m_world->GetStats().SetCurrentUpdate(tmp.update_dead);
+      m_world->GetClassificationManager().RemoveGenotype(*tmp.genotype);
+      m_world->GetStats().SetCurrentUpdate(update);
+    } else {
+      // otherwise, we insert as many organisms as we need
+      for (int cell_i = 0; cell_i < tmp.num_cpus; cell_i++) {
+        int cell_id = tmp.cells[cell_i];
+        
+        InjectGenotype(cell_id, tmp.genotype);
+        
+        cPhenotype& phenotype = GetCell(cell_id).GetOrganism()->GetPhenotype();
+        if (tmp.merit > 0) phenotype.SetMerit(cMerit(tmp.merit));
+        AdjustSchedule(GetCell(cell_id), phenotype.GetMerit());
+        
+        LineageSetupOrganism(GetCell(cell_id).GetOrganism(), NULL, 0, tmp.genotype->GetParentGenotype());
+      }
+    }
+  }
+  sync_events = true;
+  
+  return true;
+}
+
+
+
+
 bool cPopulation::DumpMemorySummary(ofstream& fp)
 {
   if (fp.good() == false) return false;
@@ -5576,3 +5767,41 @@
   }
   
 }
+
+
+// Adds an organism to a group
+void  cPopulation::JoinGroup(int group_id)
+{
+	map<int,int>::iterator it;
+	it=m_groups.find(group_id);
+	if (it == m_groups.end()) {
+		m_groups[group_id] = 0;
+	}
+	m_groups[group_id]++;
+	
+}
+
+
+// Removes an organism from a group
+void  cPopulation::LeaveGroup(int group_id)
+{
+	map<int,int>::iterator it;
+	it=m_groups.find(group_id);
+	if (it != m_groups.end()) {
+		m_groups[group_id]--;
+	}
+
+}
+
+// Identifies the number of organisms in a group
+int  cPopulation::NumberOfOrganismsInGroup(int group_id)
+{
+	map<int,int>::iterator it;
+	it=m_groups.find(group_id);
+	int num_orgs = 0;
+	if (it != m_groups.end()) {
+		num_orgs = m_groups[group_id];
+	}
+	return num_orgs;	
+
+}

Modified: branches/interrupt/source/main/cPopulation.h
===================================================================
--- branches/interrupt/source/main/cPopulation.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cPopulation.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -27,7 +27,9 @@
 #define cPopulation_h
 
 #include <fstream>
+#include <map>
 
+
 #ifndef cBirthChamber_h
 #include "cBirthChamber.h"
 #endif
@@ -115,7 +117,10 @@
 	
 	double fracOrgsCantSendMSG;
 	double fracOrgsCantReceiveMSG;
-	
+		
+	// Group formation information
+	std::map<int, int> m_groups; //<! Maps the group id to the number of orgs in the group
+
   ///////////////// Private Methods ////////////////////
   void BuildTimeSlicer(cChangeList* change_list); // Build the schedule object
 
@@ -232,6 +237,7 @@
   // Deme-related stats methods
   void PrintDemeAllStats();
   void PrintDemeTestamentStats(const cString& filename);
+	void PrintCurrentMeanDemeDensity(const cString& filename);
   void PrintDemeEnergySharingStats();
   void PrintDemeEnergyDistributionStats();
   void PrintDemeOrganismEnergyDistributionStats();
@@ -274,6 +280,8 @@
   bool SaveClone(std::ofstream& fp);
   bool LoadClone(std::ifstream& fp);
   bool LoadDumpFile(cString filename, int update);
+  bool SaveStructuredPopulation(const cString& filename);
+  bool LoadStructuredPopulation(const cString& filename);
   bool DumpMemorySummary(std::ofstream& fp);
 
   bool OK();
@@ -333,6 +341,39 @@
 	double getFracOrgsCantReceiveMSG() const { return fracOrgsCantReceiveMSG; }
 	void setFracOrgsCantSendMSG(double frac) { assert(1.0 >= frac && frac >= 0.0); fracOrgsCantSendMSG = frac; }
 	void setFracOrgsCantReceiveMSG(double frac) { assert(1.0 >= frac && frac >= 0.0); fracOrgsCantReceiveMSG = frac; }
+	
+	// Adds an organism to a group
+	void JoinGroup(int group_id);
+	// Removes an organism from a group
+	void LeaveGroup(int group_id);
+	// Identifies the number of organisms in a group
+  int NumberOfOrganismsInGroup(int group_id);
+	// Get the group information
+	map<int, int> GetFormedGroups() { return m_groups; }
+	
+private:
+  struct sTmpGenotype
+  {
+  public:
+    int id_num;
+    int parent_id;
+    int parent_id2;
+    int num_cpus;
+    int total_cpus;
+    double merit;
+    int update_born;
+    int update_dead;
+    tArray<int> cells;
+    
+    cGenotype *genotype;
+    
+    inline sTmpGenotype() : id_num(-1) { ; }
+    inline bool operator<(const sTmpGenotype& rhs) const { return id_num < rhs.id_num; }
+    inline bool operator>(const sTmpGenotype& rhs) const { return id_num > rhs.id_num; }
+    inline bool operator<=(const sTmpGenotype& rhs) const { return id_num <= rhs.id_num; }
+    inline bool operator>=(const sTmpGenotype& rhs) const { return id_num >= rhs.id_num; }
+  };  
+  
 };
 
 

Modified: branches/interrupt/source/main/cStats.cc
===================================================================
--- branches/interrupt/source/main/cStats.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cStats.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -137,6 +137,8 @@
   , m_spec_waste(0)
   , num_orgs_killed(0)
   , m_deme_num_repls(0)
+	, m_deme_num_repls_treatable(0)
+	, m_deme_num_repls_untreatable(0)
   , m_donate_to_donor (0)
   , m_donate_to_facing (0)
 {
@@ -1446,7 +1448,30 @@
   relative_pos_pred_sat.ElementAt(pos.first, pos.second)++;
 }
 
+void cStats::AddDemeResourceThresholdPredicate(cString& name) {
+	demeResourceThresholdPredicateMap[name] = 0;
+}
+	
+void cStats::IncDemeResourceThresholdPredicate(cString& name) {
+	++demeResourceThresholdPredicateMap[name];
+}
 
+void cStats::PrintDemeResourceThresholdPredicate(const cString& filename)
+{
+  cDataFile& df = m_world->GetDataFile(filename);
+  df.WriteComment("Avida deme resource threshold predicate data");
+	df.WriteComment("Number of deme reproduced by a specific threshold since last update that data was printed");
+  df.WriteTimeStamp();
+  
+	if(demeResourceThresholdPredicateMap.size() > 0) {
+		df.Write(GetUpdate(), "Update [update]");
+		for(map<cString, int>::iterator iter = demeResourceThresholdPredicateMap.begin(); iter != demeResourceThresholdPredicateMap.end(); ++iter) {
+			df.Write(iter->second, iter->first);
+			iter->second = 0;
+		}
+		df.Endl();
+	}	
+}
 
 /*! This method prints information contained within all active message predicates.
 
@@ -1504,6 +1529,23 @@
   m_deme_births.Add(source_deme.GetBirthCount());
   m_deme_merit.Add(source_deme.GetHeritableDemeMerit().GetDouble());
   m_deme_generation.Add(source_deme.GetGeneration());
+	m_deme_density.Add(source_deme.GetDensity());
+	
+	if(source_deme.isTreatable()) {
+		++m_deme_num_repls_treatable;
+		m_deme_gestation_time_treatable.Add(source_deme.GetAge());
+		m_deme_births_treatable.Add(source_deme.GetBirthCount());
+		m_deme_merit_treatable.Add(source_deme.GetHeritableDemeMerit().GetDouble());
+		m_deme_generation_treatable.Add(source_deme.GetGeneration());		
+		m_deme_density_treatable.Add(source_deme.GetDensity());
+	} else {
+		++m_deme_num_repls_untreatable;
+		m_deme_gestation_time_untreatable.Add(source_deme.GetAge());
+		m_deme_births_untreatable.Add(source_deme.GetBirthCount());
+		m_deme_merit_untreatable.Add(source_deme.GetHeritableDemeMerit().GetDouble());
+		m_deme_generation_untreatable.Add(source_deme.GetGeneration());
+		m_deme_density_untreatable.Add(source_deme.GetDensity());
+	}
 }
 
 
@@ -1551,7 +1593,8 @@
   df.Write(m_deme_births.Average(), "Mean number of births within replicated demes [numbirths]");
   df.Write(m_deme_merit.Average(), "Mean heritable merit of replicated demes [merit]");
   df.Write(m_deme_generation.Average(), "Mean generation of replicated demes [generation]");
-  
+  df.Write(m_deme_density.Average(), "Mean density of replicated demes [density]");
+	
   df.Endl();
   
   m_deme_num_repls = 0;
@@ -1559,9 +1602,91 @@
   m_deme_births.Clear();
   m_deme_merit.Clear();
   m_deme_generation.Clear();
+	m_deme_density.Clear();
 }
 
+/*! Print statistics related to deme replication.  Currently only prints the
+ number of deme replications since the last time PrintDemeReplicationData was
+ invoked.
+ */
+void cStats::PrintDemeTreatableReplicationData(const cString& filename)
+{
+  cDataFile& df = m_world->GetDataFile(filename);
+  
+  df.WriteComment("Avida deme replication data for treatable deme");
+  df.WriteTimeStamp();
+  df.Write(GetUpdate(), "Update [update]");
+  df.Write(m_deme_num_repls_treatable, "Number of deme replications [numrepl]");
+  df.Write(m_deme_gestation_time_treatable.Average(), "Mean deme gestation time [gesttime]");
+  df.Write(m_deme_births_treatable.Average(), "Mean number of births within replicated demes [numbirths]");
+  df.Write(m_deme_merit_treatable.Average(), "Mean heritable merit of replicated demes [merit]");
+  df.Write(m_deme_generation_treatable.Average(), "Mean generation of replicated demes [generation]");
+	df.Write(m_deme_density_treatable.Average(), "Mean density of replicated demes [density]");
+  
+  df.Endl();
+  
+  m_deme_num_repls_treatable = 0;
+  m_deme_gestation_time_treatable.Clear();
+  m_deme_births_treatable.Clear();
+  m_deme_merit_treatable.Clear();
+  m_deme_generation_treatable.Clear();
+	m_deme_density_treatable.Clear();
+}
 
+/*! Print statistics related to deme replication.  Currently only prints the
+ number of deme replications since the last time PrintDemeReplicationData was
+ invoked.
+ */
+void cStats::PrintDemeUntreatableReplicationData(const cString& filename)
+{
+  cDataFile& df = m_world->GetDataFile(filename);
+  
+  df.WriteComment("Avida deme replication data for untreatable deme");
+  df.WriteTimeStamp();
+  df.Write(GetUpdate(), "Update [update]");
+  df.Write(m_deme_num_repls_untreatable, "Number of deme replications [numrepl]");
+  df.Write(m_deme_gestation_time_untreatable.Average(), "Mean deme gestation time [gesttime]");
+  df.Write(m_deme_births_untreatable.Average(), "Mean number of births within replicated demes [numbirths]");
+  df.Write(m_deme_merit_untreatable.Average(), "Mean heritable merit of replicated demes [merit]");
+  df.Write(m_deme_generation_untreatable.Average(), "Mean generation of replicated demes [generation]");
+	df.Write(m_deme_density_untreatable.Average(), "Mean density of replicated demes [density]");
+  
+  df.Endl();
+  
+  m_deme_num_repls_untreatable = 0;
+  m_deme_gestation_time_untreatable.Clear();
+  m_deme_births_untreatable.Clear();
+  m_deme_merit_untreatable.Clear();
+  m_deme_generation_untreatable.Clear();
+	m_deme_density_untreatable.Clear();
+}
+
+
+void cStats::PrintDemeTreatableCount(const cString& filename)
+{
+  cPopulation& pop = m_world->GetPopulation();
+	static const int numDemes = pop.GetNumDemes();
+	int treatable(0);
+	int untreatable(0);
+	for(int i = 0; i < numDemes; ++i) {
+		if(pop.GetDeme(i).isTreatable())
+			++treatable;
+		else
+			++untreatable;
+	}
+  
+	cDataFile& df = m_world->GetDataFile(filename);
+
+  df.WriteComment("Avida deme replication data for untreatable deme");
+  df.WriteTimeStamp();
+  df.Write(GetUpdate(), "Update [update]");
+  df.Write(treatable, "Number demes treatable");
+  df.Write(untreatable, "Number demes untreatable");
+  df.Write(static_cast<double>(treatable)/static_cast<double>(untreatable), "Treatable:untreatable ratio");
+  
+  df.Endl();
+}
+
 void cStats::PrintGermlineData(const cString& filename)
 {
   cDataFile& df = m_world->GetDataFile(filename);
@@ -2476,4 +2601,40 @@
 	
 }
 
+/* 	
+ Print data regarding group formation.
+ */
+void cStats::PrintGroupsFormedData(const cString& filename)
+{
 
+	cDataFile& df = m_world->GetDataFile(filename);
+	df.WriteComment("The number of groups, average, max, and min number of orgs in groups");
+	
+	map<int,int> groups = m_world->GetPopulation().GetFormedGroups();
+	
+	map <int,int>::iterator itr;
+	double avg_size = 0.0;
+	double max_size = 0.0;
+	double min_size = 100000000000.0;
+	double active_groups = 0.0;
+	
+	for(itr = groups.begin();itr!=groups.end();itr++) {
+		avg_size += itr->second;
+		if (itr->second > max_size) max_size = itr->second;
+		if (itr->second < min_size) min_size = itr->second;
+		if (itr->second > 0) active_groups++;
+	}
+	
+	avg_size = avg_size / groups.size();
+	df.Write((double)groups.size(), "number of groups [num]");
+	df.Write(avg_size, "average size of groups [avg-size]");
+	df.Write(max_size, "max size of groups [max-size]");
+	df.Write(min_size, "min size of groups [min-size]");
+	df.Write(active_groups, "active groups [act-group]");
+	
+	
+	df.Endl();
+
+	
+}
+

Modified: branches/interrupt/source/main/cStats.h
===================================================================
--- branches/interrupt/source/main/cStats.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cStats.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -320,6 +320,7 @@
   // deme predicate stats
   tMatrix<int> relative_pos_event_count;
   tMatrix<int> relative_pos_pred_sat;
+	std::map<cString, int> demeResourceThresholdPredicateMap;
 
   // Speculative Execution Stats
   int m_spec_total;
@@ -775,11 +776,16 @@
   void PrintCellVisitsData(const cString& filename);
   void PrintExtendedTimeData(const cString& filename);
   void PrintNumOrgsKilledData(const cString& filename);
+  void PrintGroupsFormedData(const cString& filename);
   
   // deme predicate stats
   void IncEventCount(int x, int y);
   void IncPredSat(int cell_id);
   void PrintPredSatFracDump(const cString& filename);
+	
+	void AddDemeResourceThresholdPredicate(cString& name);
+	void IncDemeResourceThresholdPredicate(cString& name);
+	void PrintDemeResourceThresholdPredicate(const cString& filename);
 
   void addOrgLocations(std::vector<std::pair<int, int> >); 
   void PrintDemeRepOrgLocation(const cString& filename);
@@ -827,6 +833,11 @@
   void GermlineReplication(cGermline& source_germline, cGermline& target_germline);
   //! Print statistics about deme replication.
   void PrintDemeReplicationData(const cString& filename);
+	
+	void PrintDemeTreatableReplicationData(const cString& filename);
+	void PrintDemeUntreatableReplicationData(const cString& filename);
+	void PrintDemeTreatableCount(const cString& filename);
+
   //! Print statistics about germlines.
   void PrintGermlineData(const cString& filename);
   //! Accessor for average "generation" of germlines.
@@ -865,8 +876,24 @@
   cDoubleSum m_deme_births; //!< Mean number of births in replicated demes.
   cDoubleSum m_deme_merit; //!< Mean merit of replicated demes.
   cDoubleSum m_deme_generation; //!< Mean generation of replicated demes.
+	cDoubleSum m_deme_density; //!< Mean density of replicated demes.
   cDoubleSum m_germline_generation; //!< "Generation" accumulator of replicated germlines.
-  t_founder_map m_deme_founders; //!< Data structure to track the founders of demes.
+
+	int m_deme_num_repls_treatable; //!< Number of deme replications in treatable demes since last PrintDemeReplicationData.
+  cDoubleSum m_deme_gestation_time_treatable; //!< Gestation time for treatable demes - mean age at deme replication.
+  cDoubleSum m_deme_births_treatable; //!< Mean number of births in replicated treatable demes.
+  cDoubleSum m_deme_merit_treatable; //!< Mean merit of replicated treatable demes.
+  cDoubleSum m_deme_generation_treatable; //!< Mean generation of replicated treatable demes.
+	cDoubleSum m_deme_density_treatable; //!< Mean density of replicated treatable demes.
+
+	int m_deme_num_repls_untreatable; //!< Number of deme replications in untreatable demes since last PrintDemeReplicationData.
+  cDoubleSum m_deme_gestation_time_untreatable; //!< Gestation time for untreatable demes - mean age at deme replication.
+  cDoubleSum m_deme_births_untreatable; //!< Mean number of births in replicated untreatable demes.
+  cDoubleSum m_deme_merit_untreatable; //!< Mean merit of replicated untreatable demes.
+  cDoubleSum m_deme_generation_untreatable; //!< Mean generation of replicated untreatable demes.
+	cDoubleSum m_deme_density_untreatable; //!< Mean density of replicated untreatable demes.
+	
+	t_founder_map m_deme_founders; //!< Data structure to track the founders of demes.
   
   
   // -------- Deme competition support --------

Modified: branches/interrupt/source/main/cTaskLib.cc
===================================================================
--- branches/interrupt/source/main/cTaskLib.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cTaskLib.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -438,6 +438,8 @@
   if (name == "sg_path_traversal")
     Load_SGPathTraversal(name, info, envreqs, errors);  
   
+	if (name == "form-group")
+    Load_FormSpatialGroup(name, info, envreqs, errors);
   
   // Make sure we have actually found a task  
   if (task_array.GetSize() == start_size) {
@@ -3383,3 +3385,35 @@
 	
 	return bonus; 
 }
+
+
+void cTaskLib::Load_FormSpatialGroup(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors)
+{
+	cArgSchema schema;
+  
+  // Integer Arguments
+  schema.AddEntry("group_size", 0, 1);
+  
+  cArgContainer* args = cArgContainer::Load(argstr, schema, errors);
+  if (args) NewTask(name, "FormSpatialGroups", &cTaskLib::Task_FormSpatialGroup, 0, args);
+}
+
+double cTaskLib::Task_FormSpatialGroup(cTaskContext& ctx) const
+{
+	int ideal_group_size = ctx.GetTaskEntry()->GetArguments().GetInt(0);
+	double reward = 0.0;
+	int group_id = 0; 
+	if (ctx.GetOrganism()->HasOpinion()) {
+		group_id = ctx.GetOrganism()->GetOpinion().first;
+	}
+	int orgs_in_group = m_world->GetPopulation().NumberOfOrganismsInGroup(group_id);
+	
+	if (orgs_in_group < ideal_group_size) {
+		reward = orgs_in_group*orgs_in_group;
+	} else {
+		reward = ideal_group_size*ideal_group_size;
+	}
+	reward = reward / ideal_group_size;
+	return reward;
+}
+

Modified: branches/interrupt/source/main/cTaskLib.h
===================================================================
--- branches/interrupt/source/main/cTaskLib.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/main/cTaskLib.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -317,6 +317,10 @@
 	
 	// reputation
 	double Task_CreatePerfectStrings(cTaskContext& ctx) const; 
+	
+	// group formation 
+	void Load_FormSpatialGroup(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);
+	double Task_FormSpatialGroup(cTaskContext& ctx) const; 
 };
 
 

Modified: branches/interrupt/source/targets/avida-viewer/cTextViewerAnalyzeDriver.h
===================================================================
--- branches/interrupt/source/targets/avida-viewer/cTextViewerAnalyzeDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/targets/avida-viewer/cTextViewerAnalyzeDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -49,6 +49,7 @@
   // Driver Actions
   void SignalBreakpoint() { return; }
   void SetDone() { m_done = true; }
+  void SetPause() { return; }
   
   void RaiseException(const cString& in_string);
   void RaiseFatalException(int exit_code, const cString& in_string);

Modified: branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.cc
===================================================================
--- branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.cc	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.cc	2009-06-25 20:57:37 UTC (rev 3338)
@@ -43,7 +43,7 @@
 
 
 cTextViewerDriver::cTextViewerDriver(cWorld* world)
-  : cTextViewerDriver_Base(world)
+  : cTextViewerDriver_Base(world), m_pause(false), m_firstupdate(true)
 {
   m_view = new cView(world);
   m_view->SetViewMode(world->GetConfig().VIEW_MODE.Get());
@@ -100,7 +100,17 @@
     const int UD_size = ave_time_slice * population.GetNumOrganisms();
     const double step_size = 1.0 / (double) UD_size;
     
-
+    if (m_pause) {
+      m_view->Pause();
+      m_pause = false;
+      
+      // This is needed to have the top bar drawn properly; I'm not sure why...
+      if (m_firstupdate) {
+        m_view->Refresh();
+        m_firstupdate = false;
+      }
+    }
+    
     // Are we stepping through an organism?
     if (m_view->GetStepOrganism() != -1) {  // Yes we are!
                                             // Keep the viewer informed about the organism we are stepping through...
@@ -111,10 +121,9 @@
           m_view->NewUpdate();
           
           // This is needed to have the top bar drawn properly; I'm not sure why...
-          static bool first_update = true;
-          if (first_update) {
+          if (m_firstupdate) {
             m_view->Refresh();
-            first_update = false;
+            m_firstupdate = false;
           }
         }
         population.ProcessStep(ctx, step_size, next_id);
@@ -133,10 +142,9 @@
       m_view->NewUpdate();
  
       // This is needed to have the top bar drawn properly; I'm not sure why...
-      static bool first_update = true;
-      if (first_update) {
+      if (m_firstupdate) {
         m_view->Refresh();
-        first_update = false;
+        m_firstupdate = false;
       }
     }
     

Modified: branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.h
===================================================================
--- branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/targets/avida-viewer/cTextViewerDriver.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -32,6 +32,9 @@
 class cTextViewerDriver : public cTextViewerDriver_Base
 {
 private:
+  bool m_pause;
+  bool m_firstupdate;
+  
   cTextViewerDriver();  // not implemented
   
 public:
@@ -40,6 +43,8 @@
   
   void Run();
   
+  void SetPause() { m_pause = true; }
+
   // Driver Actions
   void SignalBreakpoint();
   void SetDone() { m_done = true; }

Modified: branches/interrupt/source/targets/avida-viewer/cTextViewerDriver_Base.h
===================================================================
--- branches/interrupt/source/targets/avida-viewer/cTextViewerDriver_Base.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/targets/avida-viewer/cTextViewerDriver_Base.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -43,6 +43,7 @@
   cWorld* m_world;
   cView_Base* m_view;
   bool m_done;  // This is set to true when run should finish.
+  bool m_pause;
 
   std::stringstream out_stream;
   std::stringstream err_stream;

Modified: branches/interrupt/source/tools/tArray.h
===================================================================
--- branches/interrupt/source/tools/tArray.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/tools/tArray.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -167,7 +167,19 @@
     m_data[new_pos] = value;
     return new_pos;
   }
+  
+  void Swap(int idx1, int idx2)
+  {
+    assert(idx1 >= 0);     // Lower Bounds Error
+    assert(idx1 < m_size); // Upper Bounds Error
+    assert(idx2 >= 0);     // Lower Bounds Error
+    assert(idx2 < m_size); // Upper Bounds Error
 
+    T v = m_data[idx1];
+    m_data[idx1] = m_data[idx2];
+    m_data[idx2] = v;
+  }
+
   void SetAll(const T& value)
   {
     for (int i = 0; i < m_size; i++) m_data[i] = value;

Modified: branches/interrupt/source/tools/tArrayUtils.h
===================================================================
--- branches/interrupt/source/tools/tArrayUtils.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/tools/tArrayUtils.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -25,7 +25,9 @@
 #ifndef tArrayUtils_h
 #define tArrayUtils_h
 
-#include "tArray.h"
+template<typename T> class tArray;
+template<typename T> class tManagedPointerArray;
+template<typename T> class tSmartArray;
 
 
 class tArrayUtils
@@ -39,7 +41,7 @@
 
 
 public:
-    
+  
   template<typename T> inline static void QSort(tArray<T>& array) { QSort(array, 0, array.GetSize() - 1); }
   template<typename T> static void QSort(tArray<T>& array, int begin, int end)
   {
@@ -58,7 +60,7 @@
       if (array[l] > pivot)
         l++;
       else
-        swap(array, l, r--);
+        array.Swap(l, r--);
     }
     
     if (array[l] > pivot && array[r] > pivot) {
@@ -66,18 +68,91 @@
     } else if (array[l] > pivot && array[r] <= pivot) {
       l++; r--;
     } else if (array[l] <= pivot && array[r] > pivot) {
-      swap(array, l++, r--);
+      array.Swap(l++, r--);
     } else {
       r = l - 1;
     }
     
-    swap(array, r--, begin);
+    array.Swap(r--, begin);
     QSort(array, begin, r);
     QSort(array, l, end);
   }
+  
+  template<typename T> inline static void QSort(tManagedPointerArray<T>& array) { QSort(array, 0, array.GetSize() - 1); }
+  template<typename T> static void QSort(tManagedPointerArray<T>& array, int begin, int end)
+  {
+    if (end < begin) return;
     
+    if (begin - end <= QUICKSORT_THRESHOLD) {
+      ISort(array, begin, end);
+      return;
+    }
     
-  template<typename T> inline static void ISort(tArray<T>& array) { isort(array, 0, array.GetSize() - 1); }
+    T& pivot = array[begin];
+    int l = begin + 1;
+    int r = end;
+    
+    while (l != r - 1) {
+      if (array[l] > pivot)
+        l++;
+      else
+        array.Swap(l, r--);
+    }
+    
+    if (array[l] > pivot && array[r] > pivot) {
+      l = r + 1;
+    } else if (array[l] > pivot && array[r] <= pivot) {
+      l++; r--;
+    } else if (array[l] <= pivot && array[r] > pivot) {
+      array.Swap(l++, r--);
+    } else {
+      r = l - 1;
+    }
+    
+    array.Swap(r--, begin);
+    QSort(array, begin, r);
+    QSort(array, l, end);
+  }
+  
+  template<typename T> inline static void QSort(tSmartArray<T>& array) { QSort(array, 0, array.GetSize() - 1); }
+  template<typename T> static void QSort(tSmartArray<T>& array, int begin, int end)
+  {
+    if (end < begin) return;
+    
+    if (begin - end <= QUICKSORT_THRESHOLD) {
+      ISort(array, begin, end);
+      return;
+    }
+    
+    T pivot = array[begin];
+    int l = begin + 1;
+    int r = end;
+    
+    while (l != r - 1) {
+      if (array[l] > pivot)
+        l++;
+      else
+        array.Swap(l, r--);
+    }
+    
+    if (array[l] > pivot && array[r] > pivot) {
+      l = r + 1;
+    } else if (array[l] > pivot && array[r] <= pivot) {
+      l++; r--;
+    } else if (array[l] <= pivot && array[r] > pivot) {
+      array.Swap(l++, r--);
+    } else {
+      r = l - 1;
+    }
+    
+    array.Swap(r--, begin);
+    QSort(array, begin, r);
+    QSort(array, l, end);
+  }
+  
+  
+    
+  template<typename T> inline static void ISort(tArray<T>& array) { ISort(array, 0, array.GetSize() - 1); }
   template<typename T> static void ISort(tArray<T>& array, int begin, int end)
   {
     T value;
@@ -95,16 +170,43 @@
       array[j + 1] = value;
     }
   }
-  
-  
-private:
-  
-  template<typename T> inline static void swap(tArray<T>& array, int i, int j)
+
+  template<typename T> inline static void ISort(tManagedPointerArray<T>& array) { ISort(array, 0, array.GetSize() - 1); }
+  template<typename T> static void ISort(tManagedPointerArray<T>& array, int begin, int end)
   {
-    T v = array[i];
-    array[i] = array[j];
-    array[j] = v;
+    T value;
+    int j;
+    
+    // for each entry
+    for (int i = begin + 1; i <= end; i++) {
+      // insert into array starting from the end of our sub-array
+      value = array[i];
+      j = i - 1;
+      while (j >= begin && array[j] < array[j + 1]) {
+        array.Swap(j, j + 1);
+        j--;
+      }
+    }
   }
+
+  template<typename T> inline static void ISort(tSmartArray<T>& array) { ISort(array, 0, array.GetSize() - 1); }
+  template<typename T> static void ISort(tSmartArray<T>& array, int begin, int end)
+  {
+    T value;
+    int j;
+    
+    // for each entry
+    for (int i = begin + 1; i <= end; i++) {
+      // insert into array starting from the end of our sub-array
+      value = array[i];
+      j = i - 1;
+      while (j >= begin && array[j] < value) {
+        array[j + 1] = array[j];
+        j--;
+      }
+      array[j + 1] = value;
+    }
+  }
 };
 
 #endif

Modified: branches/interrupt/source/tools/tManagedPointerArray.h
===================================================================
--- branches/interrupt/source/tools/tManagedPointerArray.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/tools/tManagedPointerArray.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -38,7 +38,7 @@
 #include <cassert>
 
 template <class T> class tManagedPointerArray
-{  
+{
 #if USE_tMemTrack
   tMemTrack<tManagedPointerArray<T> > mt;
 #endif
@@ -185,6 +185,21 @@
     *m_data[m_size - 1] = value;
   }
   
+  void Swap(int idx1, int idx2)
+  {
+    // Simple pointer swap, rather than deep copy
+    
+    assert(idx1 >= 0);     // Lower Bounds Error
+    assert(idx1 < m_size); // Upper Bounds Error
+    assert(idx2 >= 0);     // Lower Bounds Error
+    assert(idx2 < m_size); // Upper Bounds Error
+    
+    T* v = m_data[idx1];
+    m_data[idx1] = m_data[idx2];
+    m_data[idx2] = v;
+  }
+  
+  
   void SetAll(const T& value)
   {
     for (int i = 0; i < m_size; i++) *m_data[i] = value;

Modified: branches/interrupt/source/tools/tSmartArray.h
===================================================================
--- branches/interrupt/source/tools/tSmartArray.h	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/tools/tSmartArray.h	2009-06-25 20:57:37 UTC (rev 3338)
@@ -171,7 +171,19 @@
   }
   
   
+  void Swap(int idx1, int idx2)
+  {
+    assert(idx1 >= 0);     // Lower Bounds Error
+    assert(idx1 < m_active); // Upper Bounds Error
+    assert(idx2 >= 0);     // Lower Bounds Error
+    assert(idx2 < m_active); // Upper Bounds Error
+    
+    T v = m_data[idx1];
+    m_data[idx1] = m_data[idx2];
+    m_data[idx2] = v;
+  }  
   
+  
   void SetAll(const T& value)
   {
     for (int i = 0; i < m_active; i++) m_data[i] = value;

Modified: branches/interrupt/source/utils/hist_map/Makefile
===================================================================
--- branches/interrupt/source/utils/hist_map/Makefile	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/utils/hist_map/Makefile	2009-06-25 20:57:37 UTC (rev 3338)
@@ -30,7 +30,7 @@
 SRC		= hist_map.cc			../../tools/cFile.cc  \
 		../../tools/cInitFile.cc	../../tools/cString.cc  \
 		../../tools/cStringList.cc  ../../tools/cStringIterator.cc  \
-		../../tools/cStringUtil.cc
+		../../tools/cStringUtil.cc ../../tools/cRCObject.cc
 
 ### List Object Files (for each source file there is a object file) ###########
 OBJ	 	= $(SRC:.cc=.o)

Modified: branches/interrupt/source/utils/process_map/Makefile
===================================================================
--- branches/interrupt/source/utils/process_map/Makefile	2009-06-25 20:34:47 UTC (rev 3337)
+++ branches/interrupt/source/utils/process_map/Makefile	2009-06-25 20:57:37 UTC (rev 3338)
@@ -30,7 +30,8 @@
 SRC		= process_map.cc		../../tools/cFile.cc  \
 		../../tools/cInitFile.cc	../../tools/cString.cc  \
 		../../tools/cStringList.cc  ../../tools/cStringIterator.cc  \
-		../../tools/cRandom.cc ../../tools/cStringUtil.o
+		../../tools/cRandom.cc ../../tools/cStringUtil.o \
+		../../tools/cRCObject.cc
 
 ### List Object Files (for each source file there is a object file) ###########
 OBJ	 	= $(SRC:.cc=.o)

Copied: branches/interrupt/tests/collect_specification_analyze (from rev 3275, development/tests/collect_specification_analyze)

Copied: branches/interrupt/tests/collect_specification_analyze/config (from rev 3275, development/tests/collect_specification_analyze/config)

Deleted: branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg
===================================================================
--- development/tests/collect_specification_analyze/config/analyze-spec.cfg	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,16 +0,0 @@
-#############################################################################
-# This file is used to setup avida when it is in analysis-only mode (by
-# running "avida -a".  It allows variety of methods to load organisms
-# (specifying the type of each) and analyze them once loaded.
-#
-# See the documentation in doc/analyze_mode.html for usage, or the file
-# doc/analyze_samples.html for guidelines on writing programs.
-#
-#############################################################################
-
-VERBOSE
-
-LOAD detail-200000.pop
-RECALCULATE 1
-DETAIL executed.dat inst.26 task.0 task.1 task.2 task.3 task.4 task.5 task.6 task.7 task.8 sequence num_cpus length merit exe_length gest_time fitness r_spec.0 r_spec.1 r_spec.2 r_spec.3 r_spec.4 r_spec.5 r_spec.6 r_spec.7 r_spec.8 r_spec.9 r_spec.10 r_spec.11 r_spec.12
-PURGE_BATCH

Copied: branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg (from rev 3275, development/tests/collect_specification_analyze/config/analyze-spec.cfg)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/analyze-spec.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,16 @@
+#############################################################################
+# This file is used to setup avida when it is in analysis-only mode (by
+# running "avida -a".  It allows variety of methods to load organisms
+# (specifying the type of each) and analyze them once loaded.
+#
+# See the documentation in doc/analyze_mode.html for usage, or the file
+# doc/analyze_samples.html for guidelines on writing programs.
+#
+#############################################################################
+
+VERBOSE
+
+LOAD detail-200000.pop
+RECALCULATE 1
+DETAIL executed.dat inst.26 task.0 task.1 task.2 task.3 task.4 task.5 task.6 task.7 task.8 sequence num_cpus length merit exe_length gest_time fitness r_spec.0 r_spec.1 r_spec.2 r_spec.3 r_spec.4 r_spec.5 r_spec.6 r_spec.7 r_spec.8 r_spec.9 r_spec.10 r_spec.11 r_spec.12
+PURGE_BATCH

Deleted: branches/interrupt/tests/collect_specification_analyze/config/avida.cfg
===================================================================
--- development/tests/collect_specification_analyze/config/avida.cfg	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/avida.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,241 +0,0 @@
-#############################################################################
-# This file includes all the basic run-time defines for Avida.
-# For more information, see doc/config.html
-#############################################################################
-
-VERSION_ID 2.7.0   # Do not change this value.
-
-### GENERAL_GROUP ###
-# General Settings
-ANALYZE_MODE 1  # 0 = Disabled
-                # 1 = Enabled
-                # 2 = Interactive
-VIEW_MODE 1     # Initial viewer screen
-CLONE_FILE -    # Clone file to load
-VERBOSITY 1     # Control output verbosity
-
-### ARCH_GROUP ###
-# Architecture Variables
-WORLD_X 60        # Width of the Avida world
-WORLD_Y 60        # Height of the Avida world
-WORLD_GEOMETRY 2  # 1 = Bounded Grid
-                  # 2 = Torus
-NUM_DEMES 0       # Number of independed groups in the population; 0=off
-RANDOM_SEED 0     # Random number seed (0 for based on time)
-HARDWARE_TYPE 0   # 0 = Original CPUs
-                  # 1 = New SMT CPUs
-                  # 2 = Transitional SMT
-
-### CONFIG_FILE_GROUP ###
-# Configuration Files
-DATA_DIR data                       # Directory in which config files are found
-INST_SET instset-destroy.cfg        # File containing instruction set
-EVENT_FILE events-collect.cfg       # File containing list of events during run
-ANALYZE_FILE analyze-spec.cfg            # File used for analysis mode
-ENVIRONMENT_FILE environment.9resource    # File that describes the environment
-START_CREATURE default-classic.org  # Organism to seed the soup
-
-### REPRODUCTION_GROUP ###
-# Birth and Death
-BIRTH_METHOD 0           # Which organism should be replaced on birth?
-                         # 0 = Random organism in neighborhood
-                         # 1 = Oldest in neighborhood
-                         # 2 = Largest Age/Merit in neighborhood
-                         # 3 = None (use only empty cells in neighborhood)
-                         # 4 = Random from population (Mass Action)
-                         # 5 = Oldest in entire population
-                         # 6 = Random within deme
-                         # 7 = Organism faced by parent
-                         # 8 = Next grid cell (id+1)
-                         # 9 = Largest energy used in entire population
-                         # 10 = Largest energy used in neighborhood
-PREFER_EMPTY 1           # Give empty cells preference in offsping placement?
-ALLOW_PARENT 1           # Allow births to replace the parent organism?
-DEATH_METHOD 2           # 0 = Never die of old age.
-                         # 1 = Die when inst executed = AGE_LIMIT (+deviation)
-                         # 2 = Die when inst executed = length*AGE_LIMIT (+dev)
-AGE_LIMIT 20             # Modifies DEATH_METHOD
-AGE_DEVIATION 0          # Creates a distribution around AGE_LIMIT
-ALLOC_METHOD 0           # (Orignal CPU Only)
-                         # 0 = Allocated space is set to default instruction.
-                         # 1 = Set to section of dead genome (Necrophilia)
-                         # 2 = Allocated space is set to random instruction.
-DIVIDE_METHOD 1          # 0 = Divide leaves state of mother untouched.
-                         # 1 = Divide resets state of mother
-                         #     (after the divide, we have 2 children)
-                         # 2 = Divide resets state of current thread only
-                         #     (does not touch possible parasite threads)
-GENERATION_INC_METHOD 1  # 0 = Only the generation of the child is
-                         #     increased on divide.
-                         # 1 = Both the generation of the mother and child are
-                         #     increased on divide (good with DIVIDE_METHOD 1).
-
-### RECOMBINATION_GROUP ###
-# Sexual Recombination and Modularity
-RECOMBINATION_PROB 1.0  # probability of recombination in div-sex
-MAX_BIRTH_WAIT_TIME -1  # Updates incipiant orgs can wait for crossover
-MODULE_NUM 0            # number of modules in the genome
-CONT_REC_REGS 1         # are (modular) recombination regions continuous
-CORESPOND_REC_REGS 1    # are (modular) recombination regions swapped randomly
-                        #  or with corresponding positions?
-TWO_FOLD_COST_SEX 0     # 1 = only one recombined offspring is born.
-                        # 2 = both offspring are born
-SAME_LENGTH_SEX 0       # 0 = recombine with any genome
-                        # 1 = only recombine w/ same length
-
-### DIVIDE_GROUP ###
-# Divide Restrictions
-CHILD_SIZE_RANGE 2.0  # Maximal differential between child and parent sizes.
-MIN_COPIED_LINES 0.5  # Code fraction which must be copied before divide.
-MIN_EXE_LINES 0.5     # Code fraction which must be executed before divide.
-REQUIRE_ALLOCATE 1    # (Original CPU Only) Require allocate before divide?
-REQUIRED_TASK -1      # Task ID required for successful divide.
-IMMUNITY_TASK -1      # Task providing immunity from the required task.
-REQUIRED_REACTION -1  # Reaction ID required for successful divide.
-REQUIRED_BONUS 0      # The bonus that an organism must accumulate to divide.
-
-### MUTATION_GROUP ###
-# Mutations
-POINT_MUT_PROB 0.0    # Mutation rate (per-location per update)
-COPY_MUT_PROB 0.0025  # Mutation rate (per copy)
-INS_MUT_PROB 0.0      # Insertion rate (per site, applied on divide)
-DEL_MUT_PROB 0.0      # Deletion rate (per site, applied on divide)
-DIV_MUT_PROB 0.0      # Mutation rate (per site, applied on divide)
-DIVIDE_MUT_PROB 0.0   # Mutation rate (per divide)
-DIVIDE_INS_PROB 0.05  # Insertion rate (per divide)
-DIVIDE_DEL_PROB 0.05  # Deletion rate (per divide)
-PARENT_MUT_PROB 0.0   # Per-site, in parent, on divide
-SPECIAL_MUT_LINE -1   # If this is >= 0, ONLY this line is mutated
-INJECT_INS_PROB 0.0   # Insertion rate (per site, applied on inject)
-INJECT_DEL_PROB 0.0   # Deletion rate (per site, applied on inject)
-INJECT_MUT_PROB 0.0   # Mutation rate (per site, applied on inject)
-META_COPY_MUT 0.0     # Prob. of copy mutation rate changing (per gen)
-META_STD_DEV 0.0      # Standard deviation of meta mutation size.
-MUT_RATE_SOURCE 1     # 1 = Mutation rates determined by environment.
-                      # 2 = Mutation rates inherited from parent.
-
-### REVERSION_GROUP ###
-# Mutation Reversion
-# These slow down avida a lot, and should be set to 0.0 normally.
-REVERT_FATAL 0.0           # Should any mutations be reverted on birth?
-REVERT_DETRIMENTAL 0.0     #   0.0 to 1.0; Probability of reversion.
-REVERT_NEUTRAL 0.0         # 
-REVERT_BENEFICIAL 0.0      # 
-STERILIZE_FATAL 0.0        # Should any mutations clear (kill) the organism?
-STERILIZE_DETRIMENTAL 0.0  # 
-STERILIZE_NEUTRAL 0.0      # 
-STERILIZE_BENEFICIAL 0.0   # 
-FAIL_IMPLICIT 1            # Should copies that failed *not* due to mutations
-                           # be eliminated?
-NEUTRAL_MAX 0.0            # The percent benifical change from parent fitness to be considered neutral.
-NEUTRAL_MIN 0.0            # The percent deleterious change from parent fitness to be considered neutral.
-
-### TIME_GROUP ###
-# Time Slicing
-AVE_TIME_SLICE 30        # Ave number of insts per org per update
-SLICING_METHOD 1         # 0 = CONSTANT: all organisms get default...
-                         # 1 = PROBABILISTIC: Run _prob_ proportional to merit.
-                         # 2 = INTEGRATED: Perfectly integrated deterministic.
-BASE_MERIT_METHOD 4      # 0 = Constant (merit independent of size)
-                         # 1 = Merit proportional to copied size
-                         # 2 = Merit prop. to executed size
-                         # 3 = Merit prop. to full size
-                         # 4 = Merit prop. to min of executed or copied size
-                         # 5 = Merit prop. to sqrt of the minimum size
-BASE_CONST_MERIT 100     # Base merit when BASE_MERIT_METHOD set to 0
-DEFAULT_BONUS 1.0        # Initial bonus before any tasks
-MERIT_DEFAULT_BONUS 0    # Scale the merit of an offspring by the default bonus
-                         # rather than the accumulated bonus of the parent?
-MAX_CPU_THREADS 1        # Number of Threads a CPU can spawn
-THREAD_SLICING_METHOD 0  # Formula for and organism's thread slicing
-                         #   (num_threads-1) * THREAD_SLICING_METHOD + 1
-                         # 0 = One thread executed per time slice.
-                         # 1 = All threads executed each time slice.
-MAX_LABEL_EXE_SIZE 1     # Max nops marked as executed when labels are used
-DONATE_SIZE 5.0          # Amount of merit donated with 'donate' command
-DONATE_MULT 10.0         # Multiple of merit given that the target receives.
-MAX_DONATE_KIN_DIST -1   # Limit on distance of relation for donate; -1=no max
-MAX_DONATE_EDIT_DIST -1  # Limit on edit distance for donate; -1=no max
-MAX_DONATES 1000000      # Limit on number of donates organisms are allowed.
-
-### PROMOTER_GROUP ###
-# Promoters
-PROMOTERS_ENABLED 0        # Use the promoter/terminator execution scheme.
-                           # Certain instructions must also be included.
-PROMOTER_PROCESSIVITY 1.0  # Chance of not terminating before executing each instruction.
-PROMOTER_BG_STRENGTH 0     # Probability of positions that are not promoter
-                           # instructions initiating execution (promoters are 1).
-REGULATION_STRENGTH 1      # Strength added or subtracted to a promoter by regulation.
-REGULATION_DECAY_FRAC 0.1  # Fraction of regulation that decays away. 
-                           # (Max regulation = REGULATION_STRENGTH / REGULATION_DECAY_FRAC)
-
-### GENEOLOGY_GROUP ###
-# Geneology
-TRACK_MAIN_LINEAGE 1  # Keep all ancestors of the active population?
-                      # 0=no, 1=yes, 2=yes,w/sexual population
-THRESHOLD 3           # Number of organisms in a genotype needed for it
-                      #   to be considered viable.
-GENOTYPE_PRINT 0      # 0/1 (off/on) Print out all threshold genotypes?
-GENOTYPE_PRINT_DOM 0  # Print out a genotype if it stays dominant for
-                      #   this many updates. (0 = off)
-SPECIES_THRESHOLD 2   # max failure count for organisms to be same species
-SPECIES_RECORDING 0   # 1 = full, 2 = limited search (parent only)
-SPECIES_PRINT 0       # 0/1 (off/on) Print out all species?
-TEST_CPU_TIME_MOD 20  # Time allocated in test CPUs (multiple of length)
-
-### LOG_GROUP ###
-# Log Files
-LOG_CREATURES 0  # 0/1 (off/on) toggle to print file.
-LOG_GENOTYPES 0  # 0 = off, 1 = print ALL, 2 = print threshold ONLY.
-LOG_THRESHOLD 0  # 0/1 (off/on) toggle to print file.
-LOG_SPECIES 0    # 0/1 (off/on) toggle to print file.
-
-### LINEAGE_GROUP ###
-# Lineage
-# NOTE: This should probably be called "Clade"
-# This one can slow down avida a lot. It is used to get an idea of how
-# often an advantageous mutation arises, and where it goes afterwards.
-# Lineage creation options are.  Works only when LOG_LINEAGES is set to 1.
-#   0 = manual creation (on inject, use successive integers as lineage labels).
-#   1 = when a child's (potential) fitness is higher than that of its parent.
-#   2 = when a child's (potential) fitness is higher than max in population.
-#   3 = when a child's (potential) fitness is higher than max in dom. lineage
-# *and* the child is in the dominant lineage, or (2)
-#   4 = when a child's (potential) fitness is higher than max in dom. lineage
-# (and that of its own lineage)
-#   5 = same as child's (potential) fitness is higher than that of the
-#       currently dominant organism, and also than that of any organism
-#       currently in the same lineage.
-#   6 = when a child's (potential) fitness is higher than any organism
-#       currently in the same lineage.
-#   7 = when a child's (potential) fitness is higher than that of any
-#       organism in its line of descent
-LOG_LINEAGES 0             # 
-LINEAGE_CREATION_METHOD 0  # 
-
-### ORGANISM_NETWORK_GROUP ###
-# Organism Network Communication
-NET_ENABLED 0      # Enable Network Communication Support
-NET_DROP_PROB 0.0  # Message drop rate
-NET_MUT_PROB 0.0   # Message corruption probability
-NET_MUT_TYPE 0     # Type of message corruption.  0 = Random Single Bit, 1 = Always Flip Last
-NET_STYLE 0        # Communication Style.  0 = Random Next, 1 = Receiver Facing
-
-### BUY_SELL_GROUP ###
-# Buying and Selling Parameters
-SAVE_RECEIVED 0  # Enable storage of all inputs bought from other orgs
-BUY_PRICE 0      # price offered by organisms attempting to buy
-SELL_PRICE 0     # price offered by organisms attempting to sell
-
-### HOARD_RESOURCE_GROUP ###
-USE_RESOURCE_BINS 1
-ABSORB_RESOURCE_FRACTION .0025
-MULTI_ABSORB_TYPE 0
-USE_STORED_FRACTION 0.0
-RETURN_STORED_ON_DEATH 1
-
-### ANALYZE_GROUP ###
-# Analysis Settings
-MT_CONCURRENCY 1   # Number of concurrent analyze threads
-ANALYZE_OPTION_1   # String variable accessible from analysis scripts
-ANALYZE_OPTION_2   # String variable accessible from analysis scripts

Copied: branches/interrupt/tests/collect_specification_analyze/config/avida.cfg (from rev 3275, development/tests/collect_specification_analyze/config/avida.cfg)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/avida.cfg	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/avida.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,241 @@
+#############################################################################
+# This file includes all the basic run-time defines for Avida.
+# For more information, see doc/config.html
+#############################################################################
+
+VERSION_ID 2.7.0   # Do not change this value.
+
+### GENERAL_GROUP ###
+# General Settings
+ANALYZE_MODE 1  # 0 = Disabled
+                # 1 = Enabled
+                # 2 = Interactive
+VIEW_MODE 1     # Initial viewer screen
+CLONE_FILE -    # Clone file to load
+VERBOSITY 1     # Control output verbosity
+
+### ARCH_GROUP ###
+# Architecture Variables
+WORLD_X 60        # Width of the Avida world
+WORLD_Y 60        # Height of the Avida world
+WORLD_GEOMETRY 2  # 1 = Bounded Grid
+                  # 2 = Torus
+NUM_DEMES 0       # Number of independed groups in the population; 0=off
+RANDOM_SEED 0     # Random number seed (0 for based on time)
+HARDWARE_TYPE 0   # 0 = Original CPUs
+                  # 1 = New SMT CPUs
+                  # 2 = Transitional SMT
+
+### CONFIG_FILE_GROUP ###
+# Configuration Files
+DATA_DIR data                       # Directory in which config files are found
+INST_SET instset-destroy.cfg        # File containing instruction set
+EVENT_FILE events-collect.cfg       # File containing list of events during run
+ANALYZE_FILE analyze-spec.cfg            # File used for analysis mode
+ENVIRONMENT_FILE environment.9resource    # File that describes the environment
+START_CREATURE default-classic.org  # Organism to seed the soup
+
+### REPRODUCTION_GROUP ###
+# Birth and Death
+BIRTH_METHOD 0           # Which organism should be replaced on birth?
+                         # 0 = Random organism in neighborhood
+                         # 1 = Oldest in neighborhood
+                         # 2 = Largest Age/Merit in neighborhood
+                         # 3 = None (use only empty cells in neighborhood)
+                         # 4 = Random from population (Mass Action)
+                         # 5 = Oldest in entire population
+                         # 6 = Random within deme
+                         # 7 = Organism faced by parent
+                         # 8 = Next grid cell (id+1)
+                         # 9 = Largest energy used in entire population
+                         # 10 = Largest energy used in neighborhood
+PREFER_EMPTY 1           # Give empty cells preference in offsping placement?
+ALLOW_PARENT 1           # Allow births to replace the parent organism?
+DEATH_METHOD 2           # 0 = Never die of old age.
+                         # 1 = Die when inst executed = AGE_LIMIT (+deviation)
+                         # 2 = Die when inst executed = length*AGE_LIMIT (+dev)
+AGE_LIMIT 20             # Modifies DEATH_METHOD
+AGE_DEVIATION 0          # Creates a distribution around AGE_LIMIT
+ALLOC_METHOD 0           # (Orignal CPU Only)
+                         # 0 = Allocated space is set to default instruction.
+                         # 1 = Set to section of dead genome (Necrophilia)
+                         # 2 = Allocated space is set to random instruction.
+DIVIDE_METHOD 1          # 0 = Divide leaves state of mother untouched.
+                         # 1 = Divide resets state of mother
+                         #     (after the divide, we have 2 children)
+                         # 2 = Divide resets state of current thread only
+                         #     (does not touch possible parasite threads)
+GENERATION_INC_METHOD 1  # 0 = Only the generation of the child is
+                         #     increased on divide.
+                         # 1 = Both the generation of the mother and child are
+                         #     increased on divide (good with DIVIDE_METHOD 1).
+
+### RECOMBINATION_GROUP ###
+# Sexual Recombination and Modularity
+RECOMBINATION_PROB 1.0  # probability of recombination in div-sex
+MAX_BIRTH_WAIT_TIME -1  # Updates incipiant orgs can wait for crossover
+MODULE_NUM 0            # number of modules in the genome
+CONT_REC_REGS 1         # are (modular) recombination regions continuous
+CORESPOND_REC_REGS 1    # are (modular) recombination regions swapped randomly
+                        #  or with corresponding positions?
+TWO_FOLD_COST_SEX 0     # 1 = only one recombined offspring is born.
+                        # 2 = both offspring are born
+SAME_LENGTH_SEX 0       # 0 = recombine with any genome
+                        # 1 = only recombine w/ same length
+
+### DIVIDE_GROUP ###
+# Divide Restrictions
+CHILD_SIZE_RANGE 2.0  # Maximal differential between child and parent sizes.
+MIN_COPIED_LINES 0.5  # Code fraction which must be copied before divide.
+MIN_EXE_LINES 0.5     # Code fraction which must be executed before divide.
+REQUIRE_ALLOCATE 1    # (Original CPU Only) Require allocate before divide?
+REQUIRED_TASK -1      # Task ID required for successful divide.
+IMMUNITY_TASK -1      # Task providing immunity from the required task.
+REQUIRED_REACTION -1  # Reaction ID required for successful divide.
+REQUIRED_BONUS 0      # The bonus that an organism must accumulate to divide.
+
+### MUTATION_GROUP ###
+# Mutations
+POINT_MUT_PROB 0.0    # Mutation rate (per-location per update)
+COPY_MUT_PROB 0.0025  # Mutation rate (per copy)
+INS_MUT_PROB 0.0      # Insertion rate (per site, applied on divide)
+DEL_MUT_PROB 0.0      # Deletion rate (per site, applied on divide)
+DIV_MUT_PROB 0.0      # Mutation rate (per site, applied on divide)
+DIVIDE_MUT_PROB 0.0   # Mutation rate (per divide)
+DIVIDE_INS_PROB 0.05  # Insertion rate (per divide)
+DIVIDE_DEL_PROB 0.05  # Deletion rate (per divide)
+PARENT_MUT_PROB 0.0   # Per-site, in parent, on divide
+SPECIAL_MUT_LINE -1   # If this is >= 0, ONLY this line is mutated
+INJECT_INS_PROB 0.0   # Insertion rate (per site, applied on inject)
+INJECT_DEL_PROB 0.0   # Deletion rate (per site, applied on inject)
+INJECT_MUT_PROB 0.0   # Mutation rate (per site, applied on inject)
+META_COPY_MUT 0.0     # Prob. of copy mutation rate changing (per gen)
+META_STD_DEV 0.0      # Standard deviation of meta mutation size.
+MUT_RATE_SOURCE 1     # 1 = Mutation rates determined by environment.
+                      # 2 = Mutation rates inherited from parent.
+
+### REVERSION_GROUP ###
+# Mutation Reversion
+# These slow down avida a lot, and should be set to 0.0 normally.
+REVERT_FATAL 0.0           # Should any mutations be reverted on birth?
+REVERT_DETRIMENTAL 0.0     #   0.0 to 1.0; Probability of reversion.
+REVERT_NEUTRAL 0.0         # 
+REVERT_BENEFICIAL 0.0      # 
+STERILIZE_FATAL 0.0        # Should any mutations clear (kill) the organism?
+STERILIZE_DETRIMENTAL 0.0  # 
+STERILIZE_NEUTRAL 0.0      # 
+STERILIZE_BENEFICIAL 0.0   # 
+FAIL_IMPLICIT 1            # Should copies that failed *not* due to mutations
+                           # be eliminated?
+NEUTRAL_MAX 0.0            # The percent benifical change from parent fitness to be considered neutral.
+NEUTRAL_MIN 0.0            # The percent deleterious change from parent fitness to be considered neutral.
+
+### TIME_GROUP ###
+# Time Slicing
+AVE_TIME_SLICE 30        # Ave number of insts per org per update
+SLICING_METHOD 1         # 0 = CONSTANT: all organisms get default...
+                         # 1 = PROBABILISTIC: Run _prob_ proportional to merit.
+                         # 2 = INTEGRATED: Perfectly integrated deterministic.
+BASE_MERIT_METHOD 4      # 0 = Constant (merit independent of size)
+                         # 1 = Merit proportional to copied size
+                         # 2 = Merit prop. to executed size
+                         # 3 = Merit prop. to full size
+                         # 4 = Merit prop. to min of executed or copied size
+                         # 5 = Merit prop. to sqrt of the minimum size
+BASE_CONST_MERIT 100     # Base merit when BASE_MERIT_METHOD set to 0
+DEFAULT_BONUS 1.0        # Initial bonus before any tasks
+MERIT_DEFAULT_BONUS 0    # Scale the merit of an offspring by the default bonus
+                         # rather than the accumulated bonus of the parent?
+MAX_CPU_THREADS 1        # Number of Threads a CPU can spawn
+THREAD_SLICING_METHOD 0  # Formula for and organism's thread slicing
+                         #   (num_threads-1) * THREAD_SLICING_METHOD + 1
+                         # 0 = One thread executed per time slice.
+                         # 1 = All threads executed each time slice.
+MAX_LABEL_EXE_SIZE 1     # Max nops marked as executed when labels are used
+DONATE_SIZE 5.0          # Amount of merit donated with 'donate' command
+DONATE_MULT 10.0         # Multiple of merit given that the target receives.
+MAX_DONATE_KIN_DIST -1   # Limit on distance of relation for donate; -1=no max
+MAX_DONATE_EDIT_DIST -1  # Limit on edit distance for donate; -1=no max
+MAX_DONATES 1000000      # Limit on number of donates organisms are allowed.
+
+### PROMOTER_GROUP ###
+# Promoters
+PROMOTERS_ENABLED 0        # Use the promoter/terminator execution scheme.
+                           # Certain instructions must also be included.
+PROMOTER_PROCESSIVITY 1.0  # Chance of not terminating before executing each instruction.
+PROMOTER_BG_STRENGTH 0     # Probability of positions that are not promoter
+                           # instructions initiating execution (promoters are 1).
+REGULATION_STRENGTH 1      # Strength added or subtracted to a promoter by regulation.
+REGULATION_DECAY_FRAC 0.1  # Fraction of regulation that decays away. 
+                           # (Max regulation = REGULATION_STRENGTH / REGULATION_DECAY_FRAC)
+
+### GENEOLOGY_GROUP ###
+# Geneology
+TRACK_MAIN_LINEAGE 1  # Keep all ancestors of the active population?
+                      # 0=no, 1=yes, 2=yes,w/sexual population
+THRESHOLD 3           # Number of organisms in a genotype needed for it
+                      #   to be considered viable.
+GENOTYPE_PRINT 0      # 0/1 (off/on) Print out all threshold genotypes?
+GENOTYPE_PRINT_DOM 0  # Print out a genotype if it stays dominant for
+                      #   this many updates. (0 = off)
+SPECIES_THRESHOLD 2   # max failure count for organisms to be same species
+SPECIES_RECORDING 0   # 1 = full, 2 = limited search (parent only)
+SPECIES_PRINT 0       # 0/1 (off/on) Print out all species?
+TEST_CPU_TIME_MOD 20  # Time allocated in test CPUs (multiple of length)
+
+### LOG_GROUP ###
+# Log Files
+LOG_CREATURES 0  # 0/1 (off/on) toggle to print file.
+LOG_GENOTYPES 0  # 0 = off, 1 = print ALL, 2 = print threshold ONLY.
+LOG_THRESHOLD 0  # 0/1 (off/on) toggle to print file.
+LOG_SPECIES 0    # 0/1 (off/on) toggle to print file.
+
+### LINEAGE_GROUP ###
+# Lineage
+# NOTE: This should probably be called "Clade"
+# This one can slow down avida a lot. It is used to get an idea of how
+# often an advantageous mutation arises, and where it goes afterwards.
+# Lineage creation options are.  Works only when LOG_LINEAGES is set to 1.
+#   0 = manual creation (on inject, use successive integers as lineage labels).
+#   1 = when a child's (potential) fitness is higher than that of its parent.
+#   2 = when a child's (potential) fitness is higher than max in population.
+#   3 = when a child's (potential) fitness is higher than max in dom. lineage
+# *and* the child is in the dominant lineage, or (2)
+#   4 = when a child's (potential) fitness is higher than max in dom. lineage
+# (and that of its own lineage)
+#   5 = same as child's (potential) fitness is higher than that of the
+#       currently dominant organism, and also than that of any organism
+#       currently in the same lineage.
+#   6 = when a child's (potential) fitness is higher than any organism
+#       currently in the same lineage.
+#   7 = when a child's (potential) fitness is higher than that of any
+#       organism in its line of descent
+LOG_LINEAGES 0             # 
+LINEAGE_CREATION_METHOD 0  # 
+
+### ORGANISM_NETWORK_GROUP ###
+# Organism Network Communication
+NET_ENABLED 0      # Enable Network Communication Support
+NET_DROP_PROB 0.0  # Message drop rate
+NET_MUT_PROB 0.0   # Message corruption probability
+NET_MUT_TYPE 0     # Type of message corruption.  0 = Random Single Bit, 1 = Always Flip Last
+NET_STYLE 0        # Communication Style.  0 = Random Next, 1 = Receiver Facing
+
+### BUY_SELL_GROUP ###
+# Buying and Selling Parameters
+SAVE_RECEIVED 0  # Enable storage of all inputs bought from other orgs
+BUY_PRICE 0      # price offered by organisms attempting to buy
+SELL_PRICE 0     # price offered by organisms attempting to sell
+
+### HOARD_RESOURCE_GROUP ###
+USE_RESOURCE_BINS 1
+ABSORB_RESOURCE_FRACTION .0025
+MULTI_ABSORB_TYPE 0
+USE_STORED_FRACTION 0.0
+RETURN_STORED_ON_DEATH 1
+
+### ANALYZE_GROUP ###
+# Analysis Settings
+MT_CONCURRENCY 1   # Number of concurrent analyze threads
+ANALYZE_OPTION_1   # String variable accessible from analysis scripts
+ANALYZE_OPTION_2   # String variable accessible from analysis scripts

Deleted: branches/interrupt/tests/collect_specification_analyze/config/default-classic.org
===================================================================
--- development/tests/collect_specification_analyze/config/default-classic.org	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/default-classic.org	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,100 +0,0 @@
-h-alloc    # Allocate space for child
-h-search   # Locate the end of the organism
-nop-C      #
-nop-A      #
-mov-head   # Place write-head at beginning of offspring.
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-nop-C      #
-h-search   # Mark the beginning of the copy loop
-h-copy     # Do the copy
-if-label   # If we're done copying....
-nop-C      #
-nop-A      #
-h-divide   #    ...divide!
-mov-head   # Otherwise, loop back to the beginning of the copy loop.
-nop-A      # End label.
-nop-B      #

Copied: branches/interrupt/tests/collect_specification_analyze/config/default-classic.org (from rev 3275, development/tests/collect_specification_analyze/config/default-classic.org)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/default-classic.org	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/default-classic.org	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,100 @@
+h-alloc    # Allocate space for child
+h-search   # Locate the end of the organism
+nop-C      #
+nop-A      #
+mov-head   # Place write-head at beginning of offspring.
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+h-search   # Mark the beginning of the copy loop
+h-copy     # Do the copy
+if-label   # If we're done copying....
+nop-C      #
+nop-A      #
+h-divide   #    ...divide!
+mov-head   # Otherwise, loop back to the beginning of the copy loop.
+nop-A      # End label.
+nop-B      #

Deleted: branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop
===================================================================
--- development/tests/collect_specification_analyze/config/detail-200000.pop	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,23 +0,0 @@
-#filetype genotype_data
-#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence
-
-#  1: ID
-#  2: parent ID
-#  3: parent distance
-#  4: number of organisms currently alive
-#  5: total number of organisms that ever existed
-#  6: length of genome
-#  7: merit
-#  8: gestation time
-#  9: fitness
-# 10: update born
-# 11: update deactivated
-# 12: depth in phylogentic tree
-# 13: genome of organism
-
-4335143 4333347 -1 1043 887133 106 6907.63 1518 4.55048 99642 -1 393 rhuucavczebAqrjgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 
-4322574 4321310 -1 834 480241 102 6509.31 1436 4.53295 98644 -1 394 ArpucavczmnqrhAsnndlosimuqhcmptflqtlpwwaxkzunqqcdpqpclbtncogcAqchhmdfctpaoqcgqfmocloytpyaofahofycasvab 
-4333347 4325270 -1 759 916175 106 6906.83 1518 4.54995 99498 -1 392 rhuucavczebAqrbgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 
-4329568 4327105 -1 574 584475 119 10590.8 2334 4.53763 99200 -1 410 rxuczaagvcjzjkcdqeadffpmxpmomtqodpdbzitgiyshebinlzsnnygunqtppqpdlceqnccptgcqcAAacycgfckaqfigfcqdetqcfbjpbapccecfycasvab 
-4334827 4328326 -1 243 209369 112 9180.82 2045 4.4894 99619 -1 416 rxucajgvcczjkcAqkridrmbpmzAmtqodndhigftsuhebazfbylulnqtppqplceqncpbtgcqcAAacycgfckaqfigfcqdetqcfbjpbpccejycasvab 
-4325402 4310669 -1 147 194622 107 8886.23 1966 4.51995 98865 -1 400 rxucavcczykfctfnfjmzpsqtodfpchzbxjheyitznruulnqtppqpclceuncptgcqcAAacycefckaqigfcqAetqcfbkpkapcceaAycasvrab 

Copied: branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop (from rev 3275, development/tests/collect_specification_analyze/config/detail-200000.pop)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/detail-200000.pop	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,23 @@
+#filetype genotype_data
+#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence
+
+#  1: ID
+#  2: parent ID
+#  3: parent distance
+#  4: number of organisms currently alive
+#  5: total number of organisms that ever existed
+#  6: length of genome
+#  7: merit
+#  8: gestation time
+#  9: fitness
+# 10: update born
+# 11: update deactivated
+# 12: depth in phylogentic tree
+# 13: genome of organism
+
+4335143 4333347 -1 1043 887133 106 6907.63 1518 4.55048 99642 -1 393 rhuucavczebAqrjgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 
+4322574 4321310 -1 834 480241 102 6509.31 1436 4.53295 98644 -1 394 ArpucavczmnqrhAsnndlosimuqhcmptflqtlpwwaxkzunqqcdpqpclbtncogcAqchhmdfctpaoqcgqfmocloytpyaofahofycasvab 
+4333347 4325270 -1 759 916175 106 6906.83 1518 4.54995 99498 -1 392 rhuucavczebAqrbgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 
+4329568 4327105 -1 574 584475 119 10590.8 2334 4.53763 99200 -1 410 rxuczaagvcjzjkcdqeadffpmxpmomtqodpdbzitgiyshebinlzsnnygunqtppqpdlceqnccptgcqcAAacycgfckaqfigfcqdetqcfbjpbapccecfycasvab 
+4334827 4328326 -1 243 209369 112 9180.82 2045 4.4894 99619 -1 416 rxucajgvcczjkcAqkridrmbpmzAmtqodndhigftsuhebazfbylulnqtppqplceqncpbtgcqcAAacycgfckaqfigfcqdetqcfbjpbpccejycasvab 
+4325402 4310669 -1 147 194622 107 8886.23 1966 4.51995 98865 -1 400 rxucavcczykfctfnfjmzpsqtodfpchzbxjheyitznruulnqtppqpclceuncptgcqcAAacycefckaqigfcqAetqcfbkpkapcceaAycasvrab 

Deleted: branches/interrupt/tests/collect_specification_analyze/config/environment.9resource
===================================================================
--- development/tests/collect_specification_analyze/config/environment.9resource	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/environment.9resource	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,33 +0,0 @@
-##############################################################################
-#
-# This is the setup file for the task/resource system.  From here, you can
-# setup the available resources (including their inflow and outflow rates) as
-# well as the reactions that the organisms can trigger by performing tasks.
-#
-# This environmental setup is that of a chemostat with 9 resources, each
-# with a unique task corresponding to them.  All resources have a set inflow
-# of 100, and outflow rate of 0.01, setting their an equilibrium level at
-# 10,000.  Given a maximum population size of 3600 and neighborhood size of
-# 9, the fraction of the resource absorbable in each reaction is simply
-# 9/3600 or 0.0025.
-#
-# For information on how to use this file, see:  doc/environment.html
-# For other sample environments, see:  source/support/config/ 
-#
-##############################################################################
-
-RESOURCE  resNOT:inflow=100:outflow=0.01   resNAND:inflow=100:outflow=0.01
-RESOURCE  resAND:inflow=100:outflow=0.01   resORN:inflow=100:outflow=0.01
-RESOURCE  resOR:inflow=100:outflow=0.01    resANDN:inflow=100:outflow=0.01
-RESOURCE  resNOR:inflow=100:outflow=0.01   resXOR:inflow=100:outflow=0.01
-RESOURCE  resEQU:inflow=100:outflow=0.01
-
-REACTION  NOT  not   process:resource=resNOT:value=1.0:frac=0.0025:max=25
-REACTION  NAND nand  process:resource=resNAND:value=1.0:frac=0.0025:max=25
-REACTION  AND  and   process:resource=resAND:value=2.0:frac=0.0025:max=25
-REACTION  ORN  orn   process:resource=resORN:value=2.0:frac=0.0025:max=25
-REACTION  OR   or    process:resource=resOR:value=4.0:frac=0.0025:max=25
-REACTION  ANDN andn  process:resource=resANDN:value=4.0:frac=0.0025:max=25
-REACTION  NOR  nor   process:resource=resNOR:value=8.0:frac=0.0025:max=25
-REACTION  XOR  xor   process:resource=resXOR:value=8.0:frac=0.0025:max=25
-REACTION  EQU  equ   process:resource=resEQU:value=16.0:frac=0.0025:max=25

Copied: branches/interrupt/tests/collect_specification_analyze/config/environment.9resource (from rev 3275, development/tests/collect_specification_analyze/config/environment.9resource)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/environment.9resource	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/environment.9resource	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,33 @@
+##############################################################################
+#
+# This is the setup file for the task/resource system.  From here, you can
+# setup the available resources (including their inflow and outflow rates) as
+# well as the reactions that the organisms can trigger by performing tasks.
+#
+# This environmental setup is that of a chemostat with 9 resources, each
+# with a unique task corresponding to them.  All resources have a set inflow
+# of 100, and outflow rate of 0.01, setting their an equilibrium level at
+# 10,000.  Given a maximum population size of 3600 and neighborhood size of
+# 9, the fraction of the resource absorbable in each reaction is simply
+# 9/3600 or 0.0025.
+#
+# For information on how to use this file, see:  doc/environment.html
+# For other sample environments, see:  source/support/config/ 
+#
+##############################################################################
+
+RESOURCE  resNOT:inflow=100:outflow=0.01   resNAND:inflow=100:outflow=0.01
+RESOURCE  resAND:inflow=100:outflow=0.01   resORN:inflow=100:outflow=0.01
+RESOURCE  resOR:inflow=100:outflow=0.01    resANDN:inflow=100:outflow=0.01
+RESOURCE  resNOR:inflow=100:outflow=0.01   resXOR:inflow=100:outflow=0.01
+RESOURCE  resEQU:inflow=100:outflow=0.01
+
+REACTION  NOT  not   process:resource=resNOT:value=1.0:frac=0.0025:max=25
+REACTION  NAND nand  process:resource=resNAND:value=1.0:frac=0.0025:max=25
+REACTION  AND  and   process:resource=resAND:value=2.0:frac=0.0025:max=25
+REACTION  ORN  orn   process:resource=resORN:value=2.0:frac=0.0025:max=25
+REACTION  OR   or    process:resource=resOR:value=4.0:frac=0.0025:max=25
+REACTION  ANDN andn  process:resource=resANDN:value=4.0:frac=0.0025:max=25
+REACTION  NOR  nor   process:resource=resNOR:value=8.0:frac=0.0025:max=25
+REACTION  XOR  xor   process:resource=resXOR:value=8.0:frac=0.0025:max=25
+REACTION  EQU  equ   process:resource=resEQU:value=16.0:frac=0.0025:max=25

Deleted: branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg
===================================================================
--- development/tests/collect_specification_analyze/config/events-collect.cfg	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# This is the setup file for the events system.  From here, you can
-# configure any actions that you want to have happen during the course of
-# an experiment, including setting the times for data collection.
-#
-# basic syntax: [trigger] [start:interval:stop] [action/event] [arguments...]
-#
-# This file is currently setup to record key information every 100 updates.
-#
-# For information on how to use this file, see:  doc/events.html
-# For other sample event configurations, see:  support/config/
-#
-##############################################################################
-
-# Print all of the standard data files...
-u 0:100:end PrintAverageData       # Save info about they average genotypes
-u 0:100:end PrintDominantData      # Save info about most abundant genotypes
-u 0:100:end PrintStatsData         # Collect satistics about entire pop.
-u 0:100:end PrintCountData         # Count organisms, genotypes, species, etc.
-u 0:100:end PrintTasksData         # Save organisms counts for each task.
-u 0:100:end PrintTimeData          # Track time conversion (generations, etc.)
-u 0:100:end PrintResourceData      # Track resource abundance.
-
-u 100:100:end PrintTasksQualData   # Task quality information
-u 0:100:end PrintInternalTasksData
-u 0:100:end PrintInternalTasksQualData
-
-# Setup the full population data collection.
-u 50000:50000 SavePopulation         # Save current state of population.
-u 50000:50000 SaveHistoricPopulation # Save ancestors of current population.
-
-# Start the ecological period
-u 100000 ZeroMuts      				 # Set all mutation rates to 0, starting eco phase
-
-# Do final population data collection and exit
-u 200000 PrintDominantGenotype
-u 200000 exit                        # exit

Copied: branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg (from rev 3275, development/tests/collect_specification_analyze/config/events-collect.cfg)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/events-collect.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,38 @@
+##############################################################################
+#
+# This is the setup file for the events system.  From here, you can
+# configure any actions that you want to have happen during the course of
+# an experiment, including setting the times for data collection.
+#
+# basic syntax: [trigger] [start:interval:stop] [action/event] [arguments...]
+#
+# This file is currently setup to record key information every 100 updates.
+#
+# For information on how to use this file, see:  doc/events.html
+# For other sample event configurations, see:  support/config/
+#
+##############################################################################
+
+# Print all of the standard data files...
+u 0:100:end PrintAverageData       # Save info about they average genotypes
+u 0:100:end PrintDominantData      # Save info about most abundant genotypes
+u 0:100:end PrintStatsData         # Collect satistics about entire pop.
+u 0:100:end PrintCountData         # Count organisms, genotypes, species, etc.
+u 0:100:end PrintTasksData         # Save organisms counts for each task.
+u 0:100:end PrintTimeData          # Track time conversion (generations, etc.)
+u 0:100:end PrintResourceData      # Track resource abundance.
+
+u 100:100:end PrintTasksQualData   # Task quality information
+u 0:100:end PrintInternalTasksData
+u 0:100:end PrintInternalTasksQualData
+
+# Setup the full population data collection.
+u 50000:50000 SavePopulation         # Save current state of population.
+u 50000:50000 SaveHistoricPopulation # Save ancestors of current population.
+
+# Start the ecological period
+u 100000 ZeroMuts      				 # Set all mutation rates to 0, starting eco phase
+
+# Do final population data collection and exit
+u 200000 PrintDominantGenotype
+u 200000 exit                        # exit

Deleted: branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg
===================================================================
--- development/tests/collect_specification_analyze/config/instset-destroy.cfg	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,53 +0,0 @@
-nop-A      1   # a
-nop-B      1   # b
-nop-C      1   # c
-if-n-equ   1   # d
-if-less    1   # e
-pop        1   # f
-push       1   # g
-swap-stk   1   # h
-swap       1   # i 
-shift-r    1   # j
-shift-l    1   # k
-inc        1   # l
-dec        1   # m
-add        1   # n
-sub        1   # o
-nand       1   # p
-IO         1   # q   Puts current contents of register and gets new.
-h-alloc    1   # r   Allocate as much memory as organism can use.
-h-divide   1   # s   Cuts off everything between the read and write heads
-h-copy     1   # t   Combine h-read and h-write
-h-search   1   # u   Search for matching template, set flow head & return info
-               #   #   if no template, move flow-head here, set size&offset=0.
-mov-head   1   # v   Move ?IP? head to flow control.
-jmp-head   1   # w   Move ?IP? head by fixed amount in CX.  Set old pos in CX.
-get-head   1   # x   Get position of specified head in CX.
-if-label   1   # y
-set-flow   1   # z   Move flow-head to address in ?CX? 
-destroy 1
-
-#adv-head   1
-#jump-f     1
-#jump-b     1
-#call       1
-#return     1
-#if-bit-1   1
-#get        1
-#put        1
-#h-read     1
-#h-write    1
-#set-head   1
-#search-f   1
-#search-b   1
-
-
-# Works on multiple nops:  pop  push  inc  dec  IO  adv-head 
-
-# What if we add a new head.  Search will return the location of something,
-# and put the new head there.  Then set-head will move another head to that
-# point.  In the case of the copy loop, it only needs to be set once and
-# this will speed up the code quite a bit!
-
-# Search with no template returns current position (abs line number) in
-# genome.
\ No newline at end of file

Copied: branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg (from rev 3275, development/tests/collect_specification_analyze/config/instset-destroy.cfg)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/config/instset-destroy.cfg	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,53 @@
+nop-A      1   # a
+nop-B      1   # b
+nop-C      1   # c
+if-n-equ   1   # d
+if-less    1   # e
+pop        1   # f
+push       1   # g
+swap-stk   1   # h
+swap       1   # i 
+shift-r    1   # j
+shift-l    1   # k
+inc        1   # l
+dec        1   # m
+add        1   # n
+sub        1   # o
+nand       1   # p
+IO         1   # q   Puts current contents of register and gets new.
+h-alloc    1   # r   Allocate as much memory as organism can use.
+h-divide   1   # s   Cuts off everything between the read and write heads
+h-copy     1   # t   Combine h-read and h-write
+h-search   1   # u   Search for matching template, set flow head & return info
+               #   #   if no template, move flow-head here, set size&offset=0.
+mov-head   1   # v   Move ?IP? head to flow control.
+jmp-head   1   # w   Move ?IP? head by fixed amount in CX.  Set old pos in CX.
+get-head   1   # x   Get position of specified head in CX.
+if-label   1   # y
+set-flow   1   # z   Move flow-head to address in ?CX? 
+destroy 1
+
+#adv-head   1
+#jump-f     1
+#jump-b     1
+#call       1
+#return     1
+#if-bit-1   1
+#get        1
+#put        1
+#h-read     1
+#h-write    1
+#set-head   1
+#search-f   1
+#search-b   1
+
+
+# Works on multiple nops:  pop  push  inc  dec  IO  adv-head 
+
+# What if we add a new head.  Search will return the location of something,
+# and put the new head there.  Then set-head will move another head to that
+# point.  In the case of the copy loop, it only needs to be set once and
+# this will speed up the code quite a bit!
+
+# Search with no template returns current position (abs line number) in
+# genome.
\ No newline at end of file

Copied: branches/interrupt/tests/collect_specification_analyze/expected (from rev 3275, development/tests/collect_specification_analyze/expected)

Copied: branches/interrupt/tests/collect_specification_analyze/expected/data (from rev 3275, development/tests/collect_specification_analyze/expected/data)

Deleted: branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat
===================================================================
--- development/tests/collect_specification_analyze/expected/data/executed.dat	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,41 +0,0 @@
-#filetype genotype_data
-#format inst task task task task task task task task task sequence num_cpus length merit exe_length gest_time fitness r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec 
-
-# Legend:
-# 1: # Times destroy Executed
-# 2: Not
-# 3: Nand
-# 4: And
-# 5: OrNot
-# 6: Or
-# 7: AndNot
-# 8: Nor
-# 9: Xor
-# 10: Equals
-# 11: Genome Sequence
-# 12: Number of CPUs
-# 13: Genome Length
-# 14: Merit
-# 15: Executed Length
-# 16: Gestation Time
-# 17: Fitness
-# 18: # times specification 0 used
-# 19: # times specification 1 used
-# 20: # times specification 2 used
-# 21: # times specification 3 used
-# 22: # times specification 4 used
-# 23: # times specification 5 used
-# 24: # times specification 6 used
-# 25: # times specification 7 used
-# 26: # times specification 8 used
-# 27: # times specification 9 used
-# 28: # times specification 10 used
-# 29: # times specification 11 used
-# 30: # times specification 12 used
-
-112 0 0 0 37 0 74 0 36 36 rhuucavczebAqrjgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 1043 106 102 102 1518 0.0671937 75 0 37 0 0 0 0 0 0 0 0 0 0 
-37 0 35 0 0 0 70 0 0 68 ArpucavczmnqrhAsnndlosimuqhcmptflqtlpwwaxkzunqqcdpqpclbtncogcAqchhmdfctpaoqcgqfmocloytpyaofahofycasvab 834 102 99 99 1436 0.0689415 37 0 0 0 0 0 0 0 0 0 0 0 0 
-112 0 0 0 37 0 74 0 36 36 rhuucavczebAqrbgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 759 106 102 102 1518 0.0671937 75 0 37 0 0 0 0 0 0 0 0 0 0 
-114 56 0 0 0 116 0 164 0 0 rxuczaagvcjzjkcdqeadffpmxpmomtqodpdbzitgiyshebinlzsnnygunqtppqpdlceqnccptgcqcAAacycgfckaqfigfcqdetqcfbjpbapccecfycasvab 574 119 116 116 2334 0.0497001 57 0 0 0 0 0 57 0 0 0 0 0 0 
-110 54 0 0 0 108 0 157 0 0 rxucajgvcczjkcAqkridrmbpmzAmtqodndhigftsuhebazfbylulnqtppqplceqncpbtgcqcAAacycgfckaqfigfcqdetqcfbjpbpccejycasvab 243 112 106 106 2045 0.0518337 56 0 0 0 0 0 54 0 0 0 0 0 0 
-159 52 51 153 0 51 0 0 0 0 rxucavcczykfctfnfjmzpsqtodfpchzbxjheyitznruulnqtppqpclceuncptgcqcAAacycefckaqigfcqAetqcfbkpkapcceaAycasvrab 147 107 99 99 1966 0.0503561 107 0 0 0 0 0 52 0 0 0 0 0 0 

Copied: branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat (from rev 3275, development/tests/collect_specification_analyze/expected/data/executed.dat)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/expected/data/executed.dat	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,41 @@
+#filetype genotype_data
+#format inst task task task task task task task task task sequence num_cpus length merit exe_length gest_time fitness r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec r_spec 
+
+# Legend:
+# 1: # Times destroy Executed
+# 2: Not
+# 3: Nand
+# 4: And
+# 5: OrNot
+# 6: Or
+# 7: AndNot
+# 8: Nor
+# 9: Xor
+# 10: Equals
+# 11: Genome Sequence
+# 12: Number of CPUs
+# 13: Genome Length
+# 14: Merit
+# 15: Executed Length
+# 16: Gestation Time
+# 17: Fitness
+# 18: # times specification 0 used
+# 19: # times specification 1 used
+# 20: # times specification 2 used
+# 21: # times specification 3 used
+# 22: # times specification 4 used
+# 23: # times specification 5 used
+# 24: # times specification 6 used
+# 25: # times specification 7 used
+# 26: # times specification 8 used
+# 27: # times specification 9 used
+# 28: # times specification 10 used
+# 29: # times specification 11 used
+# 30: # times specification 12 used
+
+112 0 0 0 37 0 74 0 36 36 rhuucavczebAqrjgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 1043 106 102 102 1518 0.0671937 75 0 37 0 0 0 0 0 0 0 0 0 0 
+37 0 35 0 0 0 70 0 0 68 ArpucavczmnqrhAsnndlosimuqhcmptflqtlpwwaxkzunqqcdpqpclbtncogcAqchhmdfctpaoqcgqfmocloytpyaofahofycasvab 834 102 99 99 1436 0.0689415 37 0 0 0 0 0 0 0 0 0 0 0 0 
+112 0 0 0 37 0 74 0 36 36 rhuucavczebAqrbgjkslAdpsomfuhhpawxxeyrspgigtcszuuqqcppqpclAtncogcAqchhmdfctkaoqcgqfmoclythyamfomhAbycasvab 759 106 102 102 1518 0.0671937 75 0 37 0 0 0 0 0 0 0 0 0 0 
+114 56 0 0 0 116 0 164 0 0 rxuczaagvcjzjkcdqeadffpmxpmomtqodpdbzitgiyshebinlzsnnygunqtppqpdlceqnccptgcqcAAacycgfckaqfigfcqdetqcfbjpbapccecfycasvab 574 119 116 116 2334 0.0497001 57 0 0 0 0 0 57 0 0 0 0 0 0 
+110 54 0 0 0 108 0 157 0 0 rxucajgvcczjkcAqkridrmbpmzAmtqodndhigftsuhebazfbylulnqtppqplceqncpbtgcqcAAacycgfckaqfigfcqdetqcfbjpbpccejycasvab 243 112 106 106 2045 0.0518337 56 0 0 0 0 0 54 0 0 0 0 0 0 
+159 52 51 153 0 51 0 0 0 0 rxucavcczykfctfnfjmzpsqtodfpchzbxjheyitznruulnqtppqpclceuncptgcqcAAacycefckaqigfcqAetqcfbkpkapcceaAycasvrab 147 107 99 99 1966 0.0503561 107 0 0 0 0 0 52 0 0 0 0 0 0 

Deleted: branches/interrupt/tests/collect_specification_analyze/test_list
===================================================================
--- development/tests/collect_specification_analyze/test_list	2009-06-02 21:33:05 UTC (rev 3275)
+++ branches/interrupt/tests/collect_specification_analyze/test_list	2009-06-25 20:57:37 UTC (rev 3338)
@@ -1,37 +0,0 @@
-;--- Begin Test Configuration File (test_list) ---
-[main]
-; Command line arguments to pass to the application
-args = -s 4927 -a                  
-
-app = %(default_app)s            ; Application path to test
-nonzeroexit = disallow   ; Exit code handling (disallow, allow, or require)
-                         ;  disallow - treat non-zero exit codes as failures
-                         ;  allow - all exit codes are acceptable
-                         ;  require - treat zero exit codes as failures, useful
-                         ;            for creating tests for app error checking
-createdby = blw          ; Who created the test
-email = blwalker at egr.msu.edu  ; Email address for the test's creator
-
-[consistency]
-enabled = yes            ; Is this test a consistency test?
-long = no                ; Is this test a long test?
-
-[performance]
-enabled = no             ; Is this test a performance test?
-long = no                ; Is this test a long test?
-
-; The following variables can be used in constructing setting values by calling
-; them with %(variable_name)s.  For example see 'app' above.
-;
-; builddir 
-; cpus 
-; default_app 
-; mode 
-; perf_repeat 
-; perf_user_margin 
-; perf_wall_margin 
-; svn 
-; svnmetadir 
-; svnversion 
-; testdir 
-;--- End Test Configuration File ---

Copied: branches/interrupt/tests/collect_specification_analyze/test_list (from rev 3275, development/tests/collect_specification_analyze/test_list)
===================================================================
--- branches/interrupt/tests/collect_specification_analyze/test_list	                        (rev 0)
+++ branches/interrupt/tests/collect_specification_analyze/test_list	2009-06-25 20:57:37 UTC (rev 3338)
@@ -0,0 +1,37 @@
+;--- Begin Test Configuration File (test_list) ---
+[main]
+; Command line arguments to pass to the application
+args = -s 4927 -a                  
+
+app = %(default_app)s            ; Application path to test
+nonzeroexit = disallow   ; Exit code handling (disallow, allow, or require)
+                         ;  disallow - treat non-zero exit codes as failures
+                         ;  allow - all exit codes are acceptable
+                         ;  require - treat zero exit codes as failures, useful
+                         ;            for creating tests for app error checking
+createdby = blw          ; Who created the test
+email = blwalker at egr.msu.edu  ; Email address for the test's creator
+
+[consistency]
+enabled = yes            ; Is this test a consistency test?
+long = no                ; Is this test a long test?
+
+[performance]
+enabled = no             ; Is this test a performance test?
+long = no                ; Is this test a long test?
+
+; The following variables can be used in constructing setting values by calling
+; them with %(variable_name)s.  For example see 'app' above.
+;
+; builddir 
+; cpus 
+; default_app 
+; mode 
+; perf_repeat 
+; perf_user_margin 
+; perf_wall_margin 
+; svn 
+; svnmetadir 
+; svnversion 
+; testdir 
+;--- End Test Configuration File ---




More information about the Avida-cvs mailing list