[Avida-SVN] r2775 - in branches/interrupt: documentation/glossary documentation/notes source/actions source/analyze source/cpu source/main source/platform source/tools

beckma24 at myxo.css.msu.edu beckma24 at myxo.css.msu.edu
Fri Sep 12 08:53:01 PDT 2008


Author: beckma24
Date: 2008-09-12 11:53:00 -0400 (Fri, 12 Sep 2008)
New Revision: 2775

Modified:
   branches/interrupt/documentation/glossary/help.Registers.html
   branches/interrupt/documentation/glossary/help.Stack.html
   branches/interrupt/documentation/glossary/help.add.html
   branches/interrupt/documentation/notes/release-milestones.txt
   branches/interrupt/source/actions/EnvironmentActions.cc
   branches/interrupt/source/actions/PrintActions.cc
   branches/interrupt/source/analyze/cAnalyze.cc
   branches/interrupt/source/analyze/cAnalyzeGenotype.cc
   branches/interrupt/source/analyze/cAnalyzeGenotype.h
   branches/interrupt/source/cpu/cCPUTestInfo.cc
   branches/interrupt/source/cpu/cCPUTestInfo.h
   branches/interrupt/source/cpu/cHardwareCPU.cc
   branches/interrupt/source/cpu/cHardwareExperimental.cc
   branches/interrupt/source/cpu/cHardwareExperimental.h
   branches/interrupt/source/cpu/cHardwareManager.cc
   branches/interrupt/source/cpu/cHardwareManager.h
   branches/interrupt/source/cpu/cTestCPU.cc
   branches/interrupt/source/main/cDemeCellEvent.cc
   branches/interrupt/source/main/cEnvironment.cc
   branches/interrupt/source/main/cEventList.cc
   branches/interrupt/source/main/cEventList.h
   branches/interrupt/source/main/cLandscape.cc
   branches/interrupt/source/main/cOrganism.cc
   branches/interrupt/source/main/cOrganism.h
   branches/interrupt/source/main/cPhenPlastGenotype.cc
   branches/interrupt/source/main/cPhenPlastGenotype.h
   branches/interrupt/source/main/cPhenotype.cc
   branches/interrupt/source/main/cPhenotype.h
   branches/interrupt/source/main/cStats.cc
   branches/interrupt/source/main/cTaskLib.cc
   branches/interrupt/source/platform/platform.h
   branches/interrupt/source/tools/cDataFileManager.cc
Log:
Merged development into interrupt

Modified: branches/interrupt/documentation/glossary/help.Registers.html
===================================================================
--- branches/interrupt/documentation/glossary/help.Registers.html	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/documentation/glossary/help.Registers.html	2008-09-12 15:53:00 UTC (rev 2775)
@@ -3,4 +3,8 @@
 
 <h1>Registers</h1>
 
-Each <a href="help.CPU.html">CPU</a>  in avida contains three registers, each of which is made up of 32 bits. All math-based <a href="help.Instruction.html">instructions</a>  opperate on the registers, and various instruction will move the values in the registers around.
+<p>
+A register is a storage space for a single number. 
+Each classic <a href="help.CPU.html">CPU</a> in Avida contains three registers, each of which is made up of 32 bits. All math-based <a href="help.Instruction.html">instructions</a>  opperate on the registers, and various instruction will move the values in the registers around.
+</p>
+</html>

Modified: branches/interrupt/documentation/glossary/help.Stack.html
===================================================================
--- branches/interrupt/documentation/glossary/help.Stack.html	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/documentation/glossary/help.Stack.html	2008-09-12 15:53:00 UTC (rev 2775)
@@ -2,5 +2,7 @@
 <title>CPU Components : Stack</title>
 
 <h1>Stack</h1>
-
-Each <a href="help.CPU.html">CPU</a>  in avida has two stacks used for storage of numbers. The <a href="help.push.html">push</a>  and <a href="help.pop.html">pop</a>  instructions are used to move numbers between the <a href="help.Registers.html">registers</a>  and the stack, and the <a href="help.swap-stk.html">swap-stk</a>  instruction toggles the active stack in use.
+<P>
+Each classic <a href="help.CPU.html">CPU</a> in Avida has two stacks used for storage of numbers. The <a href="help.push.html">push</a>  and <a href="help.pop.html">pop</a>  instructions are used to move numbers between the <a href="help.Registers.html">registers</a>  and the stack, and the <a href="help.swap-stk.html">swap-stk</a>  instruction toggles the active stack in use.
+</P>
+</html>

Modified: branches/interrupt/documentation/glossary/help.add.html
===================================================================
--- branches/interrupt/documentation/glossary/help.add.html	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/documentation/glossary/help.add.html	2008-09-12 15:53:00 UTC (rev 2775)
@@ -3,4 +3,5 @@
 
 <h1>add</h1>
 
-This instruction reads in the contents of the BX and CX <a href="help.Registers.html">registers</a>  and sums them together. The result of this operation is then placed in the <a href="help.Nop-Register-Notation.html">?BX?</a>  register.
+<p>This instruction reads in the contents of the BX and CX <a href="help.Registers.html">registers</a>  and sums them together. The result of this operation is then placed in the <a href="help.Nop-Register-Notation.html">?BX?</a>  register.</p>
+</html>

Modified: branches/interrupt/documentation/notes/release-milestones.txt
===================================================================
--- branches/interrupt/documentation/notes/release-milestones.txt	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/documentation/notes/release-milestones.txt	2008-09-12 15:53:00 UTC (rev 2775)
@@ -1,67 +1,3 @@
 Avida Release Milestones
 
-Feature Key:
-- Planned feature, to be implemented
-+ Feature currently in development
-* Feature completed, ready for release
-? Planned feature, but possibly delayed to next milestone
-
-
-Visualized development/support timeline (* current):
---2.6----
-  --2.7--
-         *-2.8----
-           --2.9--
-                  --3.0----
-                    --3.1--
-                           --3.2----
-                             --3.3--
-                                    --3.4----
-                                      --3.5--
-                                             --3.6----
-                                               --3.7--
-                                                      --3.8----
-                                                        --3.9--
-                                                               --4.0----
-
-
-Version 2.6 - stable      - Status: End of Life
-Version 2.7 - development - Status: Wrapping Up
-Version 2.8 - stable      - Status: Pre-release preparation
-
-Version 2.9 - development - Target: August 2008    - Status: Soon
-
-David:
-- Completed AvidaScript
-  - Merged 'avida' and 'avida-s' functionality
-- Cleanup Landscaping tools
-+ Error reporting, input validation
-
-Dave K:
-- Topology manager
-  + environment named regions
-
-Charles:
-- Completed Viewers based on Core Viewer/GUI frameworks
-
-Bess:
-+ Consistency test coverage
-
-Unassigned:
-- New Mutation framework
-- Schedulable object framework (organism threads scheduled rather than organisms, events, etc.) 
-- Serialization
-
-All:
-- Update documentation
-- Code release cleanup
-
-
-**** NOTE: Backwards compatibility breaks at this point ****
-
-
-Version 3.0 - stable      - Target: Ongoing        - Status: Planned, pending version 2.9 completion
-
-Version 3.1 - development - Target: tbd            - Status: feature set tdb
-
-- Basic OS X native GUI
+See http://avida.devosoft.org/trac/roadmap

Modified: branches/interrupt/source/actions/EnvironmentActions.cc
===================================================================
--- branches/interrupt/source/actions/EnvironmentActions.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/actions/EnvironmentActions.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -536,6 +536,95 @@
 };
 
 /**
+ Sets resource availiblity to seasonal
+ */
+class cActionSetSeasonalResource : public cAction {
+private:
+	cString m_res_name;
+
+public:
+	cActionSetSeasonalResource(cWorld* world, const cString& args): cAction(world, args), m_res_name("")
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+	}
+		
+	static const cString GetDescription() { return "Arguments: <string reaction_name>"; }
+		
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -1*(0.4*tanh((time-182500)/50000)+0.5)*(0.5*sin(time/58.091)+0.5)+1;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count);
+	}
+};
+
+/**
+ Sets resource availiblity to seasonal 1 to -1 for 1K years of 365 updates
+ */
+class cActionSetSeasonalResource1Kyears_1To_1 : public cAction {
+private:
+	cString m_res_name;
+	double m_scale;
+		
+public:
+	cActionSetSeasonalResource1Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
+	}
+		
+	static const cString GetDescription() { return "Arguments: <string reaction_name> <double scale>"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -1*(tanh((time-182500)/50000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count * m_scale);			
+	}
+};
+
+
+/**
+ Sets resource availiblity to seasonal 1 to -1 for 10K years of 365 updates
+ */
+class cActionSetSeasonalResource10Kyears_1To_1 : public cAction {
+private:
+	cString m_res_name;
+	double m_scale;
+	
+public:
+	cActionSetSeasonalResource10Kyears_1To_1(cWorld* world, const cString& args): cAction(world, args), m_res_name(""), m_scale(1.0)
+	{
+		cString largs(args);
+		if (largs.GetSize()) m_res_name = largs.PopWord();
+		if (largs.GetSize()) m_scale = largs.PopWord().AsDouble();
+
+	}
+	
+	static const cString GetDescription() { return "Arguments: <string reaction_name> <double scale>"; }
+	
+	void Process(cAvidaContext& ctx)
+	{
+		int time = m_world->GetStats().GetUpdate();
+		double m_res_count = -1*(tanh((time-1825000)/500000)+1)*(0.5*sin(time/58.091)+0.5)+1;
+		if(m_res_count < 0.0)
+			m_res_count = 0.0;
+		cResource* res = m_world->GetEnvironment().GetResourceLib().GetResource(m_res_name);
+		if (res != NULL)
+			m_world->GetPopulation().SetResource(res->GetID(), m_res_count* m_scale);			
+	}
+};
+
+
+/**
 Sets resource availiblity to periodic
  */
 class cActionSetPeriodicResource : public cAction
@@ -850,6 +939,9 @@
   action_lib->Register<cActionSetEnvironmentInputs>("SetEnvironmentInputs");
   action_lib->Register<cActionSetEnvironmentRandomMask>("SetEnvironmentRandomMask");
 
+	action_lib->Register<cActionSetSeasonalResource>("SetSeasonalResource");
+	action_lib->Register<cActionSetSeasonalResource1Kyears_1To_1>("SetSeasonalResource1Kyears_1To_1");
+	action_lib->Register<cActionSetSeasonalResource10Kyears_1To_1>("SetSeasonalResource10Kyears_1To_1");
   action_lib->Register<cActionSetPeriodicResource>("SetPeriodicResource");
   action_lib->Register<cActionSetNumInstBefore0Energy>("SetNumInstBefore0Energy");
 

Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/actions/PrintActions.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -1579,6 +1579,8 @@
     
     void Process(cAvidaContext& ctx)
     {
+      cCPUTestInfo test_info;
+      
       if (ctx.GetAnalyzeMode()){ // Analyze mode
         cString this_path = m_filename;
         ofstream& fot = m_world->GetDataFileOFStream(this_path);
@@ -1586,7 +1588,7 @@
         tListIterator<cAnalyzeGenotype> batch_it(m_world->GetAnalyze().GetCurrentBatch().List());
         cAnalyzeGenotype* genotype = NULL;
         while((genotype = batch_it.Next())){
-          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, m_world, ctx);
+          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, test_info, m_world, ctx);
           PrintPPG(fot, ppgen, genotype->GetID(), genotype->GetParentID());
           delete ppgen;
         }
@@ -1597,7 +1599,7 @@
         PrintHeader(fot);
         cGenotype* genotype = m_world->GetClassificationManager().GetBestGenotype();
         for (int k = 0; k < m_world->GetClassificationManager().GetGenotypeCount(); k++){
-          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, m_world, ctx);
+          const cPhenPlastGenotype* ppgen = new cPhenPlastGenotype(genotype->GetGenome(), m_num_trials, test_info, m_world, ctx);
           PrintPPG(fot, ppgen, genotype->GetID(), genotype->GetParentID());
           delete ppgen;
           genotype = genotype->GetNext();

Modified: branches/interrupt/source/analyze/cAnalyze.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyze.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/analyze/cAnalyze.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -4723,7 +4723,7 @@
       fp << endl;
       
     } else { // if (file_type == FILE_TYPE_HTML) {
-             // Mark file as html
+      // Mark file as html
       fp << "<html>" << endl;
       
       // Setup any javascript macros needed...
@@ -4743,16 +4743,10 @@
       fp << "</head>" << endl;
       
       // Setup the body...
-      fp << "<body bgcolor=\"#FFFFFF\"" << endl
-        << " text=\"#000000\"" << endl
-        << " link=\"#0000AA\"" << endl
-        << " alink=\"#0000FF\"" << endl
-        << " vlink=\"#000044\">" << endl
-        << endl
-        << "<h1 align=center>Run " << batch[cur_batch].Name()
-        << ", ID " << genotype->GetID() << "</h1>" << endl
-        << "<center>" << endl
-        << endl;
+      fp << "<body>" << endl
+      << "<div align=\"center\">" << endl
+      << "<h1 align=\"center\">Run " << batch[cur_batch].Name() << ", ID " << genotype->GetID() << "</h1>" << endl
+      << endl;
       
       // Links?
       fp << "<table width=90%><tr><td align=left>";
@@ -4836,7 +4830,7 @@
       
       // Print the individual columns...
       output_it.Reset();
-      tDataEntryCommand<cAnalyzeGenotype> * data_command = NULL;
+      tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL;
       int cur_col = 0;
       while ((data_command = output_it.Next()) != NULL) {
         data_command->SetTarget(&test_genotype);
@@ -4844,9 +4838,6 @@
         const cFlexVar test_value = data_command->GetValue();
         int compare = CompareFlexStat(test_value, data_command->GetValue(genotype), data_command->GetCompareType());
         
-        // BUG! Either of the next two conditional print commands can
-        // cause landscaping to be triggered in a context that causes a crash, 
-        // notably, if you don't provide any column parameters to MapTasks.. @JEB
         if (file_type == FILE_TYPE_HTML) {
           HTMLPrintStat(test_value, fp, compare, data_command->GetHtmlCellFlags(), data_command->GetNull(),
                         !(data_command->HasArg("blank")));
@@ -4882,14 +4873,14 @@
       
       // And close everything up...
       fp << "</table>" << endl
-        << "</center>" << endl;
+      << "</div>" << endl;
     }
     
     delete [] col_pass_count;
     delete [] col_fail_count;
     m_world->GetDataFileManager().Remove(filename);  // Close the data file object
-    }
-    }
+  }
+}
 
 void cAnalyze::CommandAverageModularity(cString cur_string)
 {

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -40,13 +40,15 @@
 #include "cWorld.h"
 #include "cWorldDriver.h"
 
+#include "tAutoRelease.h"
+
 #include <cmath>
 using namespace std;
 
 cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, cString symbol_string, cInstSet& in_inst_set)
   : m_world(world)
   , genome(symbol_string)
-  , inst_set(in_inst_set)
+  , m_inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
   , tag("")
@@ -81,11 +83,11 @@
     
   // Make sure that the sequences jive with the inst_set
   for (int i = 0; i < genome.GetSize(); i++) {
-    if (genome[i].GetOp() >= inst_set.GetSize()) {
+    if (genome[i].GetOp() >= m_inst_set.GetSize()) {
       cString msg("Trying to load instruction ");
       msg += genome[i].GetOp();
       msg += ".  Max in set is";
-      msg += (inst_set.GetSize() - 1);
+      msg += (m_inst_set.GetSize() - 1);
       m_world->GetDriver().RaiseException(msg);
     }
   }
@@ -94,7 +96,7 @@
 cAnalyzeGenotype::cAnalyzeGenotype(cWorld* world, const cGenome& _genome, cInstSet& in_inst_set)
   : m_world(world)
   , genome(_genome)
-  , inst_set(in_inst_set)
+  , m_inst_set(in_inst_set)
   , name("")
   , aligned_sequence("")
   , tag("")
@@ -131,7 +133,7 @@
 cAnalyzeGenotype::cAnalyzeGenotype(const cAnalyzeGenotype& _gen)
   : m_world(_gen.m_world)
   , genome(_gen.genome)
-  , inst_set(_gen.inst_set)
+  , m_inst_set(_gen.m_inst_set)
   , name(_gen.name)
   , aligned_sequence(_gen.aligned_sequence)
   , tag(_gen.tag)
@@ -212,7 +214,7 @@
   // Calculate the base fitness for the genotype we're working with...
   // (This may not have been run already, and cost negligiably more time
   // considering the number of knockouts we need to do.
-  cAnalyzeGenotype base_genotype(m_world, genome, inst_set);
+  cAnalyzeGenotype base_genotype(m_world, genome, m_inst_set);
   base_genotype.Recalculate(ctx);
   double base_fitness = base_genotype.GetFitness();
   const tArray<int> base_task_counts( base_genotype.GetTaskCounts() );
@@ -227,7 +229,7 @@
   cGenome mod_genome(genome);
   
   // Setup a NULL instruction in a special inst set.
-  cInstSet ko_inst_set(inst_set);
+  cInstSet ko_inst_set(m_inst_set);
   const cInstruction null_inst = ko_inst_set.ActivateNullInst();
   
   // If we are keeping track of the specific effects on tasks from the
@@ -347,7 +349,7 @@
 void cAnalyzeGenotype::CheckLand() const
 {
   if (m_land == NULL) {
-    m_land = new cLandscape(m_world, genome, inst_set);
+    m_land = new cLandscape(m_world, genome, m_inst_set);
     m_land->SetDistance(1);
     m_land->Process(m_world->GetDefaultContext());
   }
@@ -356,8 +358,11 @@
 void cAnalyzeGenotype::CheckPhenPlast() const
 {
   // Implicit genotype recalculation if required
-  if (m_phenplast_stats == NULL){
-    cPhenPlastGenotype pp(genome, 1000, m_world, m_world->GetDefaultContext());
+  if (m_phenplast_stats == NULL) {
+    cCPUTestInfo test_info;
+    test_info.SetInstSet(&m_inst_set);
+    
+    cPhenPlastGenotype pp(genome, 1000, test_info, m_world, m_world->GetDefaultContext());
     SummarizePhenotypicPlasticity(pp);
   }
 }
@@ -381,34 +386,26 @@
 
 void cAnalyzeGenotype::CalcLandscape(cAvidaContext& ctx)
 {
-  if (m_land == NULL) m_land = new cLandscape(m_world, genome, inst_set);
+  if (m_land == NULL) m_land = new cLandscape(m_world, genome, m_inst_set);
   m_land->SetDistance(1);
   m_land->Process(ctx);
 }
 
 void cAnalyzeGenotype::Recalculate(cAvidaContext& ctx, cCPUTestInfo* test_info, cAnalyzeGenotype* parent_genotype, int num_trials)
 {  
-  //Allocate our own test info if it wasn't provided
-  cCPUTestInfo* temp_test_info = NULL;
+  // Allocate our own test info if it wasn't provided
+  tAutoRelease<cCPUTestInfo> local_test_info;
   if (!test_info)
   {
-      temp_test_info = new cCPUTestInfo();
-      test_info = temp_test_info;
+    test_info = new cCPUTestInfo();
+    local_test_info.Set(test_info);
   }
 
-  // @DMB - This does some 'interesting' things with the instruction set
-  // Use the inst lib for this genotype... and syncrhonize environment
-  
-  // Backup old instruction set, update with new
-  cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
-  m_world->GetHardwareManager().GetInstSet() = inst_set;
+  test_info->SetInstSet(&m_inst_set);
 
   // Handling recalculation here
   cPhenPlastGenotype recalc_data(genome, num_trials, *test_info, m_world, ctx);
  
-  // Restore the instruction set
-  m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
-  
   // The most likely phenotype will be assigned to the phenotype stats
   const cPlasticPhenotype* likely_phenotype = recalc_data.GetMostLikelyPhenotype();
   
@@ -432,17 +429,12 @@
     fitness_ratio = GetFitness() / parent_genotype->GetFitness();
     efficiency_ratio = GetEfficiency() / parent_genotype->GetEfficiency();
     comp_merit_ratio = GetCompMerit() / parent_genotype->GetCompMerit();
-    parent_dist = cStringUtil::EditDistance(genome.AsString(),
-        parent_genotype->GetGenome().AsString(), parent_muts);
+    parent_dist = cStringUtil::EditDistance(genome.AsString(), parent_genotype->GetGenome().AsString(), parent_muts);
     ancestor_dist = parent_genotype->GetAncestorDist() + parent_dist;
   }
 
   // Summarize plasticity information if multiple recalculations performed
-  if (num_trials > 1)
-    SummarizePhenotypicPlasticity(recalc_data);
-  
-  //Deallocate if we created
-  if (temp_test_info) delete temp_test_info;
+  if (num_trials > 1) SummarizePhenotypicPlasticity(recalc_data);
 }
 
 

Modified: branches/interrupt/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/interrupt/source/analyze/cAnalyzeGenotype.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/analyze/cAnalyzeGenotype.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -103,7 +103,7 @@
 private:
   cWorld* m_world;
   cGenome genome;            // Full Genome
-  cInstSet& inst_set;       // Instruction set used in this genome
+  cInstSet& m_inst_set;       // Instruction set used in this genome
   cString name;              // Name, if one was provided in loading
   cString aligned_sequence;  // Sequence (in ASCII) after alignment
   cString tag;               // All genotypes in a batch can be tagged

Modified: branches/interrupt/source/cpu/cCPUTestInfo.cc
===================================================================
--- branches/interrupt/source/cpu/cCPUTestInfo.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cCPUTestInfo.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -33,11 +33,11 @@
 
 cCPUTestInfo::cCPUTestInfo(int max_tests)
   : generation_tests(max_tests)  // These vars not reset on Clear()
-  , trace_execution(false)
   , trace_task_order(false)
   , use_random_inputs(false)
   , use_manual_inputs(false)
   , m_tracer(NULL)
+  , m_inst_set(NULL)
   , org_array(max_tests)
   , m_res_method(RES_INITIAL)
   , m_res(NULL)
@@ -73,13 +73,6 @@
 }
  
 
-void cCPUTestInfo::SetTraceExecution(cHardwareTracer *tracer)
-{
-  trace_execution = (tracer)?(true):(false);
-  m_tracer = tracer;
-}
-
-
 double cCPUTestInfo::GetGenotypeFitness()
 {
   if (org_array[0] != NULL) return org_array[0]->GetPhenotype().GetFitness();

Modified: branches/interrupt/source/cpu/cCPUTestInfo.h
===================================================================
--- branches/interrupt/source/cpu/cCPUTestInfo.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cCPUTestInfo.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -39,6 +39,7 @@
 #endif
 
 class cHardwareTracer;
+class cInstSet;
 class cOrganism;
 class cPhenotype;
 class cString;
@@ -57,12 +58,12 @@
 private:
   // Inputs...
   const int generation_tests; // Maximum depth in generations to test
-  bool trace_execution;       // Should we trace this CPU?
   bool trace_task_order;      // Should we keep track of ordering of tasks?
   bool use_random_inputs;     // Should we give the organism random inputs?
 	bool use_manual_inputs;     // Do we have inputs that we must use?
 	tArray<int> manual_inputs;  //   if so, use these.
   cHardwareTracer* m_tracer;
+  cInstSet* m_inst_set;
 
   // Outputs...
   bool is_viable;         // Is this organism colony forming?
@@ -94,7 +95,8 @@
   void UseRandomInputs(bool _rand=true) { use_random_inputs = _rand; use_manual_inputs = false; }
 	void UseManualInputs(tArray<int> inputs) {use_manual_inputs = true; use_random_inputs = false; manual_inputs = inputs;}
 	void ResetInputMode() {use_manual_inputs = false; use_random_inputs = false;}
-  void SetTraceExecution(cHardwareTracer *tracer = NULL);
+  void SetTraceExecution(cHardwareTracer* tracer = NULL) { m_tracer = tracer; }
+  void SetInstSet(cInstSet* inst_set = NULL) { m_inst_set = inst_set; }
   void SetResourceOptions(int res_method = RES_INITIAL, std::vector<std::pair<int, std::vector<double> > > * res = NULL, int update = 0, int cpu_cycle_offset = 0)
     { m_res_method = (eTestCPUResourceMethod)res_method; m_res = res; m_res_update = update; m_res_cpu_cycle_offset = cpu_cycle_offset; }
 
@@ -103,7 +105,8 @@
   int GetGenerationTests() const { return generation_tests; }
   bool GetTraceTaskOrder() const { return trace_task_order; }
   bool GetUseRandomInputs() const { return use_random_inputs; }
-  bool GetTraceExecution() const { return trace_execution; }
+  bool GetTraceExecution() const { return (m_tracer); }
+  cInstSet* GetInstSet() const { return m_inst_set; }
 	bool GetUseManualInputs() const { return use_manual_inputs; }
 	tArray<int> GetTestCPUInputs() const { return used_inputs; }
   cHardwareTracer *GetTracer() { return m_tracer; }

Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -4106,6 +4106,12 @@
   // Declarations
   int fromcellID, destcellID; //, actualNeighborhoodSize, fromFacing, destFacing, currentFacing;
 
+  fromcellID = organism->GetCellID(); //absolute id of current cell
+	
+  if(fromcellID == -1) {
+    return false;
+  }
+	
   // Get population
   cPopulation& pop = m_world->GetPopulation();
   cDeme &deme = pop.GetDeme(pop.GetCell(organism->GetCellID()).GetDemeID());
@@ -4121,7 +4127,7 @@
   // Code
   if (0 < stepsize) {
     // Current cell
-    fromcellID = organism->GetCellID();
+    //fromcellID = organism->GetCellID();
     // With sanity check
     if (-1  == fromcellID) return false;
     // Destination cell
@@ -5312,9 +5318,15 @@
 // Sense if the organism is on a target -- put 1 in reg is so, 0 otherwise
 bool cHardwareCPU::Inst_SenseTarget(cAvidaContext& ctx) {
   int reg_to_set = FindModifiedRegister(REG_CX);
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID();
+
+  if(cellid == -1) {
+    return false;
+  }
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
   int val = 0;
-
+	
   if(cell_data > 0) {
     val = 1;
   }
@@ -5328,11 +5340,17 @@
   int reg_to_set = FindModifiedRegister(REG_CX);
 
   cPopulation& pop = m_world->GetPopulation();
-  cPopulationCell& mycell = pop.GetCell(organism->GetCellID());
-
+  int cellid = organism->GetCellID();
+	
+  if(cellid == -1) {
+    return true;
+  }
+	
+  cPopulationCell& mycell = pop.GetCell(cellid);
+	
   int cell_data = mycell.GetCellFaced().GetCellData(); //absolute id of faced cell
   int val = 0;
-
+	
   if(cell_data > 0) {
     val = 1;
   }
@@ -5347,6 +5365,10 @@
 {
   int reg_to_set = FindModifiedRegister(REG_BX);
 
+  if(cellid == -1) {
+    return false;
+  }
+
   cPopulation& pop = m_world->GetPopulation();
   cDeme &deme = pop.GetDeme(pop.GetCell(cellid).GetDemeID());
   int relative_cell_id = deme.GetRelativeCellID(cellid);
@@ -6454,7 +6476,13 @@
 
 bool cHardwareCPU::Inst_IfTarget(cAvidaContext& ctx)
 {
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID(); //absolute id of current cell
+	
+  if(cellid == -1) {
+	return true;
+  }		
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
 
   if(cell_data == -1) {
     IP().Advance();
@@ -6466,7 +6494,13 @@
 
 bool cHardwareCPU::Inst_IfNotTarget(cAvidaContext& ctx)
 {
-  int cell_data = m_world->GetPopulation().GetCell(organism->GetCellID()).GetCellData();
+  int cellid = organism->GetCellID(); //absolute id of current cell
+	
+  if(cellid == -1) {
+    return true;
+  }	
+	
+  int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
 
   if(cell_data > 0) {
     IP().Advance();

Modified: branches/interrupt/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareExperimental.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cHardwareExperimental.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -503,9 +503,12 @@
   fp << organism->GetPhenotype().GetCPUCyclesUsed() << " ";
   fp << "IP:" << IP().GetPosition() << "    ";
   
+  
   for (int i = 0; i < NUM_REGISTERS; i++) {
+    sInternalValue& reg = m_threads[m_cur_thread].reg[i];
     fp << static_cast<char>('A' + i) << "X:" << GetRegister(i) << " ";
-    fp << setbase(16) << "[0x" << GetRegister(i) << "]  " << setbase(10);
+    fp << setbase(16) << "[0x" << reg.value <<  "] " << setbase(10);
+    fp << "(" << reg.from_env << " " << reg.env_component << " " << reg.originated << " " << reg.oldest_component << ")  ";
   }
   
   // Add some extra information if additional time costs are used for instructions,
@@ -520,6 +523,7 @@
     << "W-Head:" << GetHead(nHardware::HEAD_WRITE).GetPosition()  << " "
     << "F-Head:" << GetHead(nHardware::HEAD_FLOW).GetPosition()   << "  "
     << "RL:" << GetReadLabel().AsString() << "   "
+    << "Ex:" << m_last_output
     << endl;
     
   int number_of_stacks = GetNumStacks();

Modified: branches/interrupt/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareExperimental.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cHardwareExperimental.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -530,7 +530,7 @@
   dest.from_env = false;
   dest.originated = m_cycle_count;
   dest.oldest_component = src.oldest_component;
-  dest.env_component = src.from_env;  
+  dest.env_component = src.env_component;
 }
 
 

Modified: branches/interrupt/source/cpu/cHardwareManager.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareManager.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cHardwareManager.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -82,22 +82,22 @@
   
 }
 
-cHardwareBase* cHardwareManager::Create(cOrganism* in_org)
+cHardwareBase* cHardwareManager::Create(cOrganism* in_org, cInstSet* inst_set)
 {
   assert(in_org != NULL);
   
   switch (m_type)
   {
     case HARDWARE_TYPE_CPU_ORIGINAL:
-      return new cHardwareCPU(m_world, in_org, m_inst_set);
+      return new cHardwareCPU(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_SMT:
-      return new cHardwareSMT(m_world, in_org, m_inst_set);
+      return new cHardwareSMT(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_TRANSSMT:
-      return new cHardwareTransSMT(m_world, in_org, m_inst_set);
+      return new cHardwareTransSMT(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_EXPERIMENTAL:
-      return new cHardwareExperimental(m_world, in_org, m_inst_set);
+      return new cHardwareExperimental(m_world, in_org, inst_set);
     case HARDWARE_TYPE_CPU_GX:
-      return new cHardwareGX(m_world, in_org, m_inst_set);
+      return new cHardwareGX(m_world, in_org, inst_set);
     default:
       return NULL;
   }

Modified: branches/interrupt/source/cpu/cHardwareManager.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareManager.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cHardwareManager.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -61,7 +61,8 @@
   cHardwareManager(cWorld* world);
   ~cHardwareManager() { ; }
   
-  cHardwareBase* Create(cOrganism* in_org);
+  cHardwareBase* Create(cOrganism* in_org, cInstSet* inst_set);
+  inline cHardwareBase* Create(cOrganism* in_org) { return Create(in_org, m_inst_set); }
   cTestCPU* CreateTestCPU() { return new cTestCPU(m_world); }
 
   const cInstSet& GetInstSet() const { return *m_inst_set; }

Modified: branches/interrupt/source/cpu/cTestCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cTestCPU.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/cpu/cTestCPU.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -359,10 +359,13 @@
   if (test_info.org_array[cur_depth] != NULL) {
     delete test_info.org_array[cur_depth];
   }
-  test_info.org_array[cur_depth] = new cOrganism(m_world, ctx, genome);
-  cOrganism & organism = *( test_info.org_array[cur_depth] );
-  organism.SetOrgInterface(new cTestCPUInterface(this));
-  organism.GetPhenotype().SetupInject(genome);
+  cOrganism* organism = NULL;
+  
+  if (test_info.GetInstSet()) organism = new cOrganism(m_world, ctx, genome, test_info.GetInstSet());
+  else organism = new cOrganism(m_world, ctx, genome);
+  test_info.org_array[cur_depth] = organism;
+  organism->SetOrgInterface(new cTestCPUInterface(this));
+  organism->GetPhenotype().SetupInject(genome);
 
   // Run the current organism.
   ProcessGestation(ctx, test_info, cur_depth);
@@ -377,10 +380,10 @@
   //  4: It copied false => we must check the child.
 
   // Case 1:  ////////////////////////////////////
-  if (organism.GetPhenotype().GetNumDivides() == 0)  return false;
+  if (organism->GetPhenotype().GetNumDivides() == 0)  return false;
 
   // Case 2:  ////////////////////////////////////
-  if (organism.GetPhenotype().CopyTrue() == true) {
+  if (organism->GetPhenotype().CopyTrue() == true) {
     test_info.depth_found = cur_depth;
     test_info.is_viable = true;
     return true;
@@ -389,7 +392,7 @@
   // Case 3:  ////////////////////////////////////
   bool is_ancestor = false;
   for (int anc_depth = 0; anc_depth < cur_depth; anc_depth++) {
-    if (organism.ChildGenome() == test_info.org_array[anc_depth]->GetGenome()){
+    if (organism->ChildGenome() == test_info.org_array[anc_depth]->GetGenome()){
       is_ancestor = true;
       const int cur_cycle = cur_depth - anc_depth;
       if (test_info.max_cycle < cur_cycle) test_info.max_cycle = cur_cycle;
@@ -406,7 +409,7 @@
   // If we haven't reached maximum depth yet, check out the child.
   if (cur_depth+1 < test_info.generation_tests) {
     // Run the child's genome.
-    return TestGenome_Body(ctx, test_info, organism.ChildGenome(), cur_depth+1);
+    return TestGenome_Body(ctx, test_info, organism->ChildGenome(), cur_depth+1);
   }
 
   // All options have failed; just return false.

Modified: branches/interrupt/source/main/cDemeCellEvent.cc
===================================================================
--- branches/interrupt/source/main/cDemeCellEvent.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cDemeCellEvent.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -11,11 +11,11 @@
   , m_event_width(x2-x1)
   , m_event_height(y2-y1)
   , m_active(false)
+  , m_static_pos(static_pos)
   , m_dead(false)
-  , m_static_pos(static_pos)
+  , m_id_set(false)
   , m_deme(deme)
   , m_world(world)
-  , m_id_set(false)
 {
   assert(x1 <= x2);
   assert(y1 <= y2);

Modified: branches/interrupt/source/main/cEnvironment.cc
===================================================================
--- branches/interrupt/source/main/cEnvironment.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cEnvironment.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -1043,7 +1043,7 @@
       if (cur_process->GetDemeFraction()) {
         deme_bonus = cur_process->GetDemeFraction() * bonus;
         bonus = (1-cur_process->GetDemeFraction()) * bonus;
-      }
+        }
       
       // Take care of the organism's bonus:
       switch (cur_process->GetType()) {

Modified: branches/interrupt/source/main/cEventList.cc
===================================================================
--- branches/interrupt/source/main/cEventList.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cEventList.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -133,6 +133,9 @@
   case GENERATION:
     t_val = m_world->GetStats().SumGeneration().Average();
     break;
+  case BIRTHS:
+    t_val = m_world->GetStats().GetTotCreatures();
+    break;
   case UNDEFINED:
     break;
   }
@@ -251,6 +254,9 @@
       case IMMEDIATE:
         os << "immediate ";
         break;
+      case BIRTHS:
+        os << "births ";
+        break;
       default:
         os << "undefined ";
     }
@@ -306,6 +312,9 @@
   } else if( cur_word == "g" || cur_word == "generation") {
     trigger = GENERATION;
     cur_word = cur_line.PopWord();
+  } else if (cur_word == "b" || cur_word == "births") {
+    trigger = BIRTHS;
+    cur_word = cur_line.PopWord();
   } else {
     // If Trigger is skipped so assume IMMEDIATE
     trigger = IMMEDIATE;

Modified: branches/interrupt/source/main/cEventList.h
===================================================================
--- branches/interrupt/source/main/cEventList.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cEventList.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -52,7 +52,7 @@
   tMemTrack<cEventList> mt;
 #endif
 public:
-  enum eTriggerType { UPDATE, GENERATION, IMMEDIATE, UNDEFINED };
+  enum eTriggerType { UPDATE, GENERATION, IMMEDIATE, BIRTHS, UNDEFINED };
   
   static const double TRIGGER_BEGIN;
   static const double TRIGGER_END;

Modified: branches/interrupt/source/main/cLandscape.cc
===================================================================
--- branches/interrupt/source/main/cLandscape.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cLandscape.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -38,11 +38,12 @@
 #include "cWorld.h"
 
 
-cLandscape::cLandscape(cWorld* world, const cGenome & in_genome, const cInstSet & in_inst_set)
+cLandscape::cLandscape(cWorld* world, const cGenome& in_genome, const cInstSet& in_inst_set)
 : m_world(world), inst_set(in_inst_set), base_genome(1), peak_genome(1), trials(1), m_min_found(0),
   m_max_trials(0), site_count(NULL)
 {
   Reset(in_genome);
+  test_info.SetInstSet(const_cast<cInstSet*>(&inst_set));
 }
 
 cLandscape::~cLandscape()
@@ -777,7 +778,6 @@
     pos_frac = GetProbPos();
     
     // Print the information on the current best.
-    cCPUTestInfo test_info;
     testcpu->TestGenome(ctx, test_info, cur_genome);
     cPhenotype& colony_phenotype = test_info.GetColonyOrganism()->GetPhenotype();
     df.Write(gen, "Generation");

Modified: branches/interrupt/source/main/cOrganism.cc
===================================================================
--- branches/interrupt/source/main/cOrganism.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cOrganism.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -77,10 +77,47 @@
   , m_msg(0)
   , m_opinion(0)
 {
-  // Initialization of structures...
   m_hardware = m_world->GetHardwareManager().Create(this);
-//  m_cpu_stats.Setup();
 
+  initialize(ctx);
+}
+
+cOrganism::cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set)
+  : m_world(world)
+  , m_genotype(NULL)
+  , m_phenotype(world)
+  , m_initial_genome(in_genome)
+  , m_mut_info(world->GetEnvironment().GetMutationLib(), in_genome.GetSize())
+  , m_interface(NULL)
+  , m_lineage_label(-1)
+  , m_lineage(NULL)
+  , m_input_pointer(0)
+  , m_input_buf(world->GetEnvironment().GetInputSize())
+  , m_output_buf(world->GetEnvironment().GetOutputSize())
+  , m_received_messages(RECEIVED_MESSAGES_SIZE)
+  , m_sent_value(0)
+  , m_sent_active(false)
+  , m_test_receive_pos(0)
+  , m_pher_drop(false)
+  , m_max_executed(-1)
+  , m_is_running(false)
+  , m_is_sleeping(false)
+  , m_is_dead(false)
+  , killed_event(false)
+  , m_net(NULL)
+  , m_msg(0)
+  , m_opinion(0)
+{
+  m_hardware = m_world->GetHardwareManager().Create(this, inst_set);
+  
+  initialize(ctx);
+}
+
+
+void cOrganism::initialize(cAvidaContext& ctx)
+{
+  m_phenotype.SetInstSetSize(m_hardware->GetInstSet().GetSize());
+  
   if (m_world->GetConfig().DEATH_METHOD.Get() > DEATH_METHOD_OFF) {
     m_max_executed = m_world->GetConfig().AGE_LIMIT.Get();
     if (m_world->GetConfig().AGE_DEVIATION.Get() > 0.0) {
@@ -89,13 +126,13 @@
     if (m_world->GetConfig().DEATH_METHOD.Get() == DEATH_METHOD_MULTIPLE) {
       m_max_executed *= m_initial_genome.GetSize();
     }
-
+    
     // m_max_executed must be positive or an organism will not die!
     if (m_max_executed < 1) m_max_executed = 1;
   }
   
   if (m_world->GetConfig().NET_ENABLED.Get()) m_net = new cNetSupport();
-  m_id = m_world->GetStats().GetTotCreatures();
+  m_id = m_world->GetStats().GetTotCreatures();  
 }
 
 

Modified: branches/interrupt/source/main/cOrganism.h
===================================================================
--- branches/interrupt/source/main/cOrganism.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cOrganism.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -80,6 +80,7 @@
 class cGenotype;
 class cHardwareBase;
 class cInjectGenotype;
+class cInstSet;
 class cLineage;
 class cOrgSinkMessage;
 class cSaleItem;
@@ -104,8 +105,7 @@
 	int cclade_id;				                  // @MRR Coalescence clade information (set in cPopulation)
  
 	// Other stats
-  cCPUMemory m_child_genome; // Child genome, while under construction.
-//  sCPUStats m_cpu_stats;     // Info for statistics
+  cCPUMemory m_child_genome;              // Child genome, while under construction.
 
   // Input and Output with the environment
   int m_input_pointer;
@@ -143,12 +143,16 @@
   };
   cNetSupport* m_net;
   
+  
+  void initialize(cAvidaContext& ctx);
+  
   cOrganism(); // @not_implemented
   cOrganism(const cOrganism&); // @not_implemented
   cOrganism& operator=(const cOrganism&); // @not_implemented
   
 public:
   cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome);
+  cOrganism(cWorld* world, cAvidaContext& ctx, const cGenome& in_genome, cInstSet* inst_set);
   ~cOrganism();
 
   // --------  Accessor Methods  --------
@@ -181,7 +185,6 @@
   int GetMaxExecuted() const { return m_max_executed; }
   
   cCPUMemory& ChildGenome() { return m_child_genome; }
-//  sCPUStats& CPUStats() { return m_cpu_stats; }
 
   void SetRunning(bool in_running) { m_is_running = in_running; }
   bool IsRunning() { return m_is_running; }
@@ -432,16 +435,5 @@
 };
 
 
-#ifdef ENABLE_UNIT_TESTS
-namespace nOrganism {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
-}
-#endif  
-
 #endif
 

Modified: branches/interrupt/source/main/cPhenPlastGenotype.cc
===================================================================
--- branches/interrupt/source/main/cPhenPlastGenotype.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cPhenPlastGenotype.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -26,14 +26,6 @@
 #include <iostream>
 #include <cmath>
 
-cPhenPlastGenotype::cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cWorld* world, cAvidaContext& ctx)
-: m_genome(in_genome), m_num_trials(num_trials), m_world(world)
-{
-  cCPUTestInfo test_info;
-  test_info.UseRandomInputs(true);
-  Process(test_info, world, ctx);
-}
-
 cPhenPlastGenotype::cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cCPUTestInfo& test_info,  cWorld* world, cAvidaContext& ctx)
 : m_genome(in_genome), m_num_trials(num_trials), m_world(world)
 {

Modified: branches/interrupt/source/main/cPhenPlastGenotype.h
===================================================================
--- branches/interrupt/source/main/cPhenPlastGenotype.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cPhenPlastGenotype.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -82,7 +82,6 @@
     void Process(cCPUTestInfo& test_info, cWorld* world, cAvidaContext& ctx);
 
   public:
-      cPhenPlastGenotype(const cGenome& in_genome, int num_trials, cWorld* world, cAvidaContext& ctx);
     cPhenPlastGenotype(const cGenome& in_genome, int num_trails, cCPUTestInfo& test_info,  cWorld* world, cAvidaContext& ctx);
     ~cPhenPlastGenotype();
     

Modified: branches/interrupt/source/main/cPhenotype.cc
===================================================================
--- branches/interrupt/source/main/cPhenotype.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cPhenotype.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -28,7 +28,6 @@
 #include "cEnvironment.h"
 #include "cDeme.h"
 #include "cHardwareManager.h"
-#include "cInstSet.h"
 #include "cReactionResult.h"
 #include "cTaskState.h"
 #include "cTools.h"
@@ -49,7 +48,6 @@
   , cur_task_value(m_world->GetEnvironment().GetNumTasks())  
   , cur_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , cur_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())
-  , cur_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
   , cur_sense_count(m_world->GetStats().GetSenseSize())
   , sensed_resources(m_world->GetEnvironment().GetResourceLib().GetSize())
   , cur_task_time(m_world->GetEnvironment().GetNumTasks())   // Added for tracking time; WRE 03-18-07
@@ -58,7 +56,6 @@
   , last_task_value(m_world->GetEnvironment().GetNumTasks())
   , last_reaction_count(m_world->GetEnvironment().GetReactionLib().GetSize())
   , last_reaction_add_reward(m_world->GetEnvironment().GetReactionLib().GetSize())  
-  , last_inst_count(world->GetHardwareManager().GetInstSet().GetSize())
   , last_sense_count(m_world->GetStats().GetSenseSize())
 {
 }
@@ -244,7 +241,7 @@
   assert(age >= 0);
   assert(child_copied_size >= 0);
   // assert(to_die == false);
-  return true;
+  return (m_world);
 }
 
 
@@ -1087,222 +1084,8 @@
 }
 
 
-///// For Loading and Saving State: /////
 
 
-bool cPhenotype::SaveState(ofstream& fp)
-{
-  assert(fp.good());
-  fp << "cPhenotype" << endl;
-
-  fp << merit.GetDouble()   << " ";
-  fp << genome_length       << " ";
-  fp << copied_size         << " ";
-  fp << executed_size       << " ";
-  fp << gestation_time      << " ";
-  fp << gestation_start     << " ";
-  fp << fitness             << " ";
-  fp << div_type            << " ";
-
-  fp << cur_bonus           << " ";
-  fp << cur_num_errors      << " ";
-  fp << cur_num_donates      << " ";
-  for (int i = 0; i < cur_task_count.GetSize(); i++) {
-    fp << cur_task_count[i] << " ";
-  }
-  for (int i = 0; i < cur_reaction_count.GetSize(); i++) {
-    fp << cur_reaction_count[i] << " ";
-  }
-  for (int i = 0; i < cur_inst_count.GetSize(); i++) {
-    fp << cur_inst_count[i] << " ";
-  }
-
-  fp << last_merit_base     << " ";
-  fp << last_bonus          << " ";
-  fp << last_num_errors     << " ";
-  fp << last_num_donates    << " ";
-  for (int i = 0; i < last_task_count.GetSize(); i++) {
-    fp << last_task_count[i] << " ";
-  }
-  for (int i = 0; i < last_reaction_count.GetSize(); i++) {
-    fp << last_reaction_count[i] << " ";
-  }
-  for (int i = 0; i < last_inst_count.GetSize(); i++) {
-    fp << last_inst_count[i] << " ";
-  }
-
-  fp << num_divides         << " ";
-  fp << generation          << " ";
-  fp << cpu_cycles_used     << " ";
-  fp << time_used           << " ";
-  fp << age                 << " ";
-  fp << neutral_metric      << " ";
-  fp << life_fitness        << " ";
-
-  fp << is_injected         << " ";
-  fp << is_donor_last       << " ";
-  fp << is_donor_cur        << " ";
-  fp << is_donor_rand_last       << " ";
-  fp << is_donor_rand        << " ";
-  fp << is_donor_null_last       << " ";
-  fp << is_donor_null        << " ";
-  fp << is_donor_kin_last       << " ";
-  fp << is_donor_kin        << " ";
-  fp << is_donor_edit_last       << " ";
-  fp << is_donor_edit        << " ";
-  fp << is_donor_gbg_last       << " ";
-  fp << is_donor_gbg        << " ";
-  fp << is_donor_truegb_last       << " ";
-  fp << is_donor_truegb        << " ";
-  fp << is_donor_threshgb_last       << " ";
-  fp << is_donor_threshgb        << " ";
-  fp << is_donor_quanta_threshgb_last       << " ";
-  fp << is_donor_quanta_threshgb        << " ";
-  fp << num_thresh_gb_donations_last       << " ";
-  fp << num_thresh_gb_donations        << " ";
-  fp << num_quanta_thresh_gb_donations_last       << " ";
-  fp << num_quanta_thresh_gb_donations        << " ";
-
-  fp << is_receiver_last         << " ";
-  fp << is_receiver         << " ";
-  fp << is_receiver_rand         << " ";
-  fp << is_receiver_kin         << " ";
-  fp << is_receiver_kin_last         << " ";
-  fp << is_receiver_edit         << " ";
-  fp << is_receiver_edit_last         << " ";
-  fp << is_receiver_gbg         << " ";
-  fp << is_receiver_truegb_last         << " ";
-  fp << is_receiver_truegb         << " ";
-  fp << is_receiver_threshgb_last         << " ";
-  fp << is_receiver_threshgb         << " ";
-  fp << is_receiver_quanta_threshgb_last         << " ";
-  fp << is_receiver_quanta_threshgb         << " ";
-  fp << is_modifier         << " ";
-  fp << is_modified         << " ";
-  fp << is_fertile          << " ";
-  fp << is_mutated          << " ";
-  fp << parent_true         << " ";
-  fp << parent_sex          << " ";
-  fp << parent_cross_num    << " ";
-
-  fp << copy_true           << " ";
-  fp << divide_sex          << " ";
-  fp << mate_select_id      << " ";
-  fp << cross_num           << " ";
-  fp << child_fertile       << " ";
-  fp << last_child_fertile  << " ";
-
-  fp << endl;
-  return true;
-}
-
-
-bool cPhenotype::LoadState(ifstream & fp)
-{
-  double tmp_merit;
-  assert(fp.good());
-  if( !fp.good() ) return false;
-
-  fp >> tmp_merit;  merit = tmp_merit;
-  fp >> genome_length;
-  fp >> copied_size;
-  fp >> executed_size;
-  fp >> gestation_time;
-  fp >> gestation_start;
-  fp >> fitness;
-  fp >> div_type;
-
-  fp >> cur_bonus;
-  fp >> cur_num_errors;
-  fp >> cur_num_donates;
-
-  for (int i = 0; i < cur_task_count.GetSize(); i++) {
-    fp >> cur_task_count[i];
-  }
-  for (int i = 0; i < cur_reaction_count.GetSize(); i++) {
-    fp >> cur_reaction_count[i];
-  }
-  for (int i = 0; i < cur_inst_count.GetSize(); i++) {
-    fp >> cur_inst_count[i];
-  }
-
-  fp >> last_merit_base;
-  fp >> last_bonus;
-  fp >> last_num_errors;
-  fp >> last_num_donates;
-  for (int i = 0; i < last_task_count.GetSize(); i++) {
-    fp >> last_task_count[i];
-  }
-  for (int i = 0; i < last_reaction_count.GetSize(); i++) {
-    fp >> last_reaction_count[i];
-  }
-  for (int i = 0; i < last_inst_count.GetSize(); i++) {
-    fp >> last_inst_count[i];
-  }
-
-  fp >> num_divides;
-  fp >> generation;
-  fp >> cpu_cycles_used;
-  fp >> time_used;
-  fp >> age;
-  fp >> neutral_metric;
-  fp >> life_fitness;
-
-  fp >> is_injected;
-  fp >> is_donor_last;
-  fp >> is_donor_cur;
-  fp >> is_donor_rand_last;
-  fp >> is_donor_rand;
-  fp >> is_donor_null_last;
-  fp >> is_donor_null;
-  fp >> is_donor_kin_last;
-  fp >> is_donor_kin;
-  fp >> is_donor_edit_last;
-  fp >> is_donor_edit;
-  fp >> is_donor_gbg_last;
-  fp >> is_donor_gbg;
-  fp >> is_donor_truegb_last;
-  fp >> is_donor_truegb;
-  fp >> is_donor_threshgb_last;
-  fp >> is_donor_threshgb;
-  fp >> is_donor_quanta_threshgb_last;
-  fp >> is_donor_quanta_threshgb;
-  fp >> num_thresh_gb_donations_last;
-  fp >> num_thresh_gb_donations;
-  fp >> num_quanta_thresh_gb_donations_last;
-  fp >> num_quanta_thresh_gb_donations;
-  fp >> is_receiver_last;
-  fp >> is_receiver;
-  fp >> is_receiver_rand;
-  fp >> is_receiver_kin;
-  fp >> is_receiver_kin_last;
-  fp >> is_receiver_edit;
-  fp >> is_receiver_edit_last;
-  fp >> is_receiver_gbg;
-  fp >> is_receiver_truegb_last;
-  fp >> is_receiver_truegb;
-  fp >> is_receiver_threshgb_last;
-  fp >> is_receiver_threshgb;
-  fp >> is_receiver_quanta_threshgb_last;
-  fp >> is_receiver_quanta_threshgb;
-  fp >> is_modifier;
-  fp >> is_modified;
-  fp >> is_fertile;
-  fp >> is_mutated;
-  fp >> parent_true;
-  fp >> parent_sex;
-  fp >> parent_cross_num;
-
-  fp >> copy_true;
-  fp >> divide_sex;
-  fp >> mate_select_id;
-  fp >> cross_num;
-  fp >> child_fertile;
-  fp >> last_child_fertile;
-
-  return true;
-}
-
 void cPhenotype::PrintStatus(ostream& fp) const
 {
   fp << "  MeritBase:"

Modified: branches/interrupt/source/main/cPhenotype.h
===================================================================
--- branches/interrupt/source/main/cPhenotype.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cPhenotype.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -86,6 +86,7 @@
 
 class cPhenotype
 {
+  friend class cOrganism;
 private:
   cWorld* m_world;
   bool initialized;
@@ -218,12 +219,20 @@
   // 7. Information that is set once (when organism was born)
   double permanent_germline_propensity;
   
+
+  inline void SetInstSetSize(int inst_set_size);
+
+  
+  cPhenotype(cWorld* world);
+
+  
 public:
-  cPhenotype() { ; } // @not_implemented
-  cPhenotype(cWorld* world);
+  cPhenotype() : m_world(NULL) { ; } // Will not construct a valid cPhenotype! Only exists to support incorrect cDeme tArray usage.
+
   cPhenotype(const cPhenotype&); 
   cPhenotype& operator=(const cPhenotype&); 
   ~cPhenotype();
+  
 
   bool OK();
 
@@ -250,8 +259,6 @@
                   tArray<int>& insts_triggered);
 
   // State saving and loading, and printing...
-  bool SaveState(std::ofstream& fp);
-  bool LoadState(std::ifstream & fp);
   void PrintStatus(std::ostream& fp) const;
 
   // Some useful methods...
@@ -480,15 +487,10 @@
 };
 
 
-#ifdef ENABLE_UNIT_TESTS
-namespace nPhenotype {
-  /**
-   * Run unit tests
-   *
-   * @param full Run full test suite; if false, just the fast tests.
-   **/
-  void UnitTests(bool full = false);
+inline void cPhenotype::SetInstSetSize(int inst_set_size)
+{
+  cur_inst_count.Resize(inst_set_size, 0);
+  last_inst_count.Resize(inst_set_size, 0);
 }
-#endif  
 
 #endif

Modified: branches/interrupt/source/main/cStats.cc
===================================================================
--- branches/interrupt/source/main/cStats.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cStats.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -169,6 +169,9 @@
   resource_count.Resize( m_world->GetNumResources() );
   resource_count.SetAll(0);
 
+  resource_geometry.Resize( m_world->GetNumResources() );
+  resource_geometry.SetAll(nGeometry::GLOBAL);
+
   task_names.Resize(num_tasks);
   for (int i = 0; i < num_tasks; i++)
     task_names[i] = env.GetTask(i).GetDesc();

Modified: branches/interrupt/source/main/cTaskLib.cc
===================================================================
--- branches/interrupt/source/main/cTaskLib.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/main/cTaskLib.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -49,6 +49,11 @@
 # define log2(x) (log(x)/log(2.0))
 #endif
 
+// Various workarounds for FreeBSD
+#if AVIDA_PLATFORM(FREEBSD)
+# define log2(x) (log(x)/log(2.0))
+#endif
+
 static const double dCastPrecision = 100000.0;
 
 
@@ -2893,7 +2898,7 @@
   return 1.0;
 }
 
-double cTaskLib::Task_MoveToRightSide(cTaskContext& ctx) const {
+double cTaskLib::Task_MoveToRightSide(cTaskContext& ctx) const {	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   std::pair<int, int> location = deme.GetCellPosition(ctx.GetOrgInterface()->GetCellID());
   
@@ -2926,6 +2931,11 @@
 //Note - a generic version of this is now at - Task_MoveToMovementEvent
 {
   cOrgInterface* iface = ctx.GetOrgInterface();
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int celldata = m_world->GetPopulation().GetCell(iface->GetCellID()).GetCellData();
 
@@ -2953,6 +2963,11 @@
 } //End cTaskLib::TaskMoveToTarget()
 
 double cTaskLib::Task_MoveToMovementEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int cell_data = m_world->GetPopulation().GetCell(ctx.GetOrgInterface()->GetCellID()).GetCellData();
   cOrgInterface* iface = ctx.GetOrgInterface();
@@ -2972,6 +2987,11 @@
 
 
 double cTaskLib::Task_MoveBetweenMovementEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme& deme = m_world->GetPopulation().GetDeme(ctx.GetOrgInterface()->GetDemeID());
   int cell_data = m_world->GetPopulation().GetCell(ctx.GetOrgInterface()->GetCellID()).GetCellData();
   cOrgInterface* iface = ctx.GetOrgInterface();
@@ -3014,6 +3034,11 @@
 }
 
 double cTaskLib::Task_MoveToEvent(cTaskContext& ctx) const {
+	
+  if(ctx.GetOrganism()->GetCellID() == -1) {
+    return 0.0;		
+  }	
+	
   cDeme* deme = ctx.GetOrganism()->GetOrgInterface().GetDeme();
   int cell_data = ctx.GetOrganism()->GetOrgInterface().GetCellData();
   if(cell_data <= 0)

Modified: branches/interrupt/source/platform/platform.h
===================================================================
--- branches/interrupt/source/platform/platform.h	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/platform/platform.h	2008-09-12 15:53:00 UTC (rev 2775)
@@ -39,11 +39,15 @@
 # pragma warning( disable : 4355 )
 #endif
 
-#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX)
+#if defined(__APPLE__) || defined(unix) || defined(__unix) || defined(__unix__) || defined (__NetBSD__) || defined(_AIX) || defined(__FreeBSD__)
 # define AVIDA_PLATFORM_UNIX 1
 # define AVIDA_PLATFORM_THREADS 1
 #endif
 
+#if defined(__FreeBSD__)
+# define AVIDA_PLATFORM_FREEBSD 1
+#endif
+
 #if defined(__APPLE__)
 # define AVIDA_PLATFORM_APPLE 1
 #endif

Modified: branches/interrupt/source/tools/cDataFileManager.cc
===================================================================
--- branches/interrupt/source/tools/cDataFileManager.cc	2008-09-12 15:28:01 UTC (rev 2774)
+++ branches/interrupt/source/tools/cDataFileManager.cc	2008-09-12 15:53:00 UTC (rev 2775)
@@ -96,7 +96,11 @@
     if (d == -1) break;
     
     // If directory name is not null
-    if (d - i > 0) cTools::MkDir(dir_prefix + target.Substring(0, d - i), false);
+    if (d - i > 0) {
+      cString dir = target.Substring(i, d - i);
+      // Create if  that this directory is not a relative path component
+      if (dir.GetSize() > 2 || (dir != "." && dir != "..")) cTools::MkDir(dir_prefix + target.Substring(0, d), false);
+    }
     
     // Adjust next directory name starting point
     i = d + 1;




More information about the Avida-cvs mailing list