[Avida-SVN] r1451 - in branches/collect: . Avida.xcodeproj source source/analyze source/cpu source/main source/targets/avida-viewer support/config support/scripts tests/_testrunner tests/midrun_classsic_30u/config

blwalker at myxo.css.msu.edu blwalker at myxo.css.msu.edu
Mon Apr 2 12:23:51 PDT 2007


Author: blwalker
Date: 2007-04-02 15:23:51 -0400 (Mon, 02 Apr 2007)
New Revision: 1451

Added:
   branches/collect/CONTRIBUTORS
   branches/collect/run_tests
   branches/collect/source/cpu/cHardwareGX.cc
   branches/collect/source/cpu/cHardwareGX.h
   branches/collect/source/targets/avida-viewer/NOTES
   branches/collect/tests/
Modified:
   branches/collect/Avida.xcodeproj/project.pbxproj
   branches/collect/source/analyze/cAnalyze.cc
   branches/collect/source/analyze/cAnalyze.h
   branches/collect/source/analyze/cAnalyzeGenotype.cc
   branches/collect/source/analyze/cAnalyzeGenotype.h
   branches/collect/source/cpu/CMakeLists.txt
   branches/collect/source/cpu/SConscript
   branches/collect/source/cpu/cHardwareCPU.cc
   branches/collect/source/cpu/cHardwareCPU.h
   branches/collect/source/cpu/cHardwareExperimental.cc
   branches/collect/source/cpu/cHardwareExperimental.h
   branches/collect/source/cpu/cHardwareManager.cc
   branches/collect/source/cpu/cTestCPU.cc
   branches/collect/source/cpu/cTestCPUInterface.cc
   branches/collect/source/defs.h
   branches/collect/source/main/avida.cc
   branches/collect/source/main/cAvidaConfig.h
   branches/collect/source/main/cInstruction.cc
   branches/collect/source/main/cOrganism.cc
   branches/collect/source/main/cPhenotype.cc
   branches/collect/source/main/cPhenotype.h
   branches/collect/source/main/cPopulation.cc
   branches/collect/source/main/cStats.cc
   branches/collect/source/main/cTaskLib.cc
   branches/collect/source/main/cTaskLib.h
   branches/collect/source/targets/avida-viewer/cSymbolUtil.h
   branches/collect/support/config/avida.cfg
   branches/collect/support/config/instset-experimental.cfg
   branches/collect/support/scripts/trace_movie.pl
   branches/collect/tests/_testrunner/testrunner.py
   branches/collect/tests/midrun_classsic_30u/config/detail-50000.pop
Log:
Ported r1412:1450 from development.


Modified: branches/collect/Avida.xcodeproj/project.pbxproj
===================================================================
--- branches/collect/Avida.xcodeproj/project.pbxproj	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/Avida.xcodeproj/project.pbxproj	2007-04-02 19:23:51 UTC (rev 1451)
@@ -10,6 +10,8 @@
 		1097463F0AE9606E00929ED6 /* cDeme.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1097463D0AE9606E00929ED6 /* cDeme.cc */; };
 		109746410AE9606E00929ED6 /* cDeme.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1097463D0AE9606E00929ED6 /* cDeme.cc */; };
 		109746430AE9606E00929ED6 /* cDeme.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1097463D0AE9606E00929ED6 /* cDeme.cc */; };
+		4233358A0BC067E3000DF681 /* cHardwareGX.cc in Sources */ = {isa = PBXBuildFile; fileRef = 423335880BC067E3000DF681 /* cHardwareGX.cc */; };
+		4233358B0BC067E3000DF681 /* cHardwareGX.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 423335890BC067E3000DF681 /* cHardwareGX.h */; };
 		7005A70409BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
 		7005A70609BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
 		7005A70809BA0FA90007E16E /* cTestCPUInterface.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */; };
@@ -422,6 +424,7 @@
 				7049F3730A66AD7E00640512 /* default-transsmt.org in CopyFiles */,
 				70B1A7430B7E3FFD00067486 /* instset-experimental.cfg in CopyFiles */,
 				70B1A75A0B7E431F00067486 /* experimental.org in CopyFiles */,
+				4233358B0BC067E3000DF681 /* cHardwareGX.h in CopyFiles */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -440,6 +443,8 @@
 /* Begin PBXFileReference section */
 		1097463D0AE9606E00929ED6 /* cDeme.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cDeme.cc; sourceTree = "<group>"; };
 		1097463E0AE9606E00929ED6 /* cDeme.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cDeme.h; sourceTree = "<group>"; };
+		423335880BC067E3000DF681 /* cHardwareGX.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = cHardwareGX.cc; sourceTree = "<group>"; };
+		423335890BC067E3000DF681 /* cHardwareGX.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = cHardwareGX.h; sourceTree = "<group>"; };
 		7005A70109BA0FA90007E16E /* cTestCPUInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cTestCPUInterface.h; sourceTree = "<group>"; };
 		7005A70209BA0FA90007E16E /* cTestCPUInterface.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cTestCPUInterface.cc; sourceTree = "<group>"; };
 		7005A70909BA0FBE0007E16E /* cOrgInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cOrgInterface.h; sourceTree = "<group>"; };
@@ -1366,6 +1371,8 @@
 				70C1EF9E08C39F0E00F50912 /* cHardwareBase.h */,
 				70C1EFA508C39F2100F50912 /* cHardwareCPU.cc */,
 				70C1EFA008C39F0E00F50912 /* cHardwareCPU.h */,
+				423335880BC067E3000DF681 /* cHardwareGX.cc */,
+				423335890BC067E3000DF681 /* cHardwareGX.h */,
 				70C5BD690905CE5F0028A785 /* cHardwareManager.cc */,
 				70C5BD6A0905CE5F0028A785 /* cHardwareManager.h */,
 				70C1F02308C3C71300F50912 /* cHardwareSMT.cc */,
@@ -2176,6 +2183,7 @@
 				1097463F0AE9606E00929ED6 /* cDeme.cc in Sources */,
 				70B1A6500B7E237F00067486 /* cHardwareExperimental.cc in Sources */,
 				706C6FFF0B83F265003174C1 /* cInstSet.cc in Sources */,
+				4233358A0BC067E3000DF681 /* cHardwareGX.cc in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Copied: branches/collect/CONTRIBUTORS (from rev 1450, development/CONTRIBUTORS)

Copied: branches/collect/run_tests (from rev 1450, development/run_tests)


Property changes on: branches/collect/run_tests
___________________________________________________________________
Name: svn:executable
   + *

Modified: branches/collect/source/analyze/cAnalyze.cc
===================================================================
--- branches/collect/source/analyze/cAnalyze.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/analyze/cAnalyze.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -1709,6 +1709,27 @@
   }
 }
 
+void cAnalyze::CommandPrintTasksQuality(cString cur_string)
+{
+  if (m_world->GetVerbosity() >= VERBOSE_ON) cout << "Printing task qualities in batch " << cur_batch << endl;
+  else cout << "Printing task qualities..." << endl;
+  
+  // Load in the variables...
+  cString filename("tasksquality.dat");
+  if (cur_string.GetSize() != 0) filename = cur_string.PopWord();
+  
+  ofstream& fp = m_world->GetDataFileOFStream(filename);
+  
+  // Loop through all of the genotypes in this batch...
+  tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
+  cAnalyzeGenotype * genotype = NULL;
+  while ((genotype = batch_it.Next()) != NULL) {
+    fp << genotype->GetID() << " ";
+    genotype->PrintTasksQuality(fp);
+    fp << endl;
+  }
+}
+
 void cAnalyze::CommandDetail(cString cur_string)
 {
   if (m_world->GetVerbosity() >= VERBOSE_ON) cout << "Detailing batch " << cur_batch << endl;
@@ -7981,6 +8002,7 @@
   AddLibraryDef("PRINT", &cAnalyze::CommandPrint);
   AddLibraryDef("TRACE", &cAnalyze::CommandTrace);
   AddLibraryDef("PRINT_TASKS", &cAnalyze::CommandPrintTasks);
+  AddLibraryDef("PRINT_TASKS_QUALITY", &cAnalyze::CommandPrintTasksQuality);
   AddLibraryDef("DETAIL", &cAnalyze::CommandDetail);
   AddLibraryDef("DETAIL_TIMELINE", &cAnalyze::CommandDetailTimeline);
   AddLibraryDef("DETAIL_BATCHES", &cAnalyze::CommandDetailBatches);

Modified: branches/collect/source/analyze/cAnalyze.h
===================================================================
--- branches/collect/source/analyze/cAnalyze.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/analyze/cAnalyze.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -198,6 +198,7 @@
   void CommandTrace(cString cur_string);
   void CommandTraceWithResources(cString cur_string);
   void CommandPrintTasks(cString cur_string);
+  void CommandPrintTasksQuality(cString cur_string);
   void CommandDetail(cString cur_string);
   void CommandDetailTimeline(cString cur_string);
   void CommandDetailBatches(cString cur_string);

Modified: branches/collect/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/analyze/cAnalyzeGenotype.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -64,6 +64,7 @@
   , fitness(0.0)
   , errors(0)
   , task_counts(0)
+  , task_qualities(0)
   , fitness_ratio(0.0)
   , efficiency_ratio(0.0)
   , comp_merit_ratio(0.0)
@@ -109,6 +110,7 @@
   , fitness(0.0)
   , errors(0)
   , task_counts(0)
+  , task_qualities(0)
   , fitness_ratio(0.0)
   , efficiency_ratio(0.0)
   , comp_merit_ratio(0.0)
@@ -144,6 +146,7 @@
   , fitness(_gen.fitness)
   , errors(_gen.errors)
   , task_counts(_gen.task_counts)
+  , task_qualities(_gen.task_qualities)
   , fitness_ratio(_gen.fitness_ratio)
   , efficiency_ratio(_gen.efficiency_ratio)
   , comp_merit_ratio(_gen.comp_merit_ratio)
@@ -400,6 +403,7 @@
   div_type = test_phenotype.GetDivType();
   mate_id = test_phenotype.MateSelectID();
   task_counts = test_phenotype.GetLastTaskCount();
+  task_qualities = test_phenotype.GetLastTaskQuality();
 
   // Setup a new parent stats if we have a parent to work with.
   if (parent_genotype != NULL) {
@@ -425,6 +429,15 @@
   }
 }
 
+void cAnalyzeGenotype::PrintTasksQuality(ofstream& fp, int min_task, int max_task)
+{
+  if (max_task == -1) max_task = task_counts.GetSize();
+
+  for (int i = min_task; i < max_task; i++) {
+    fp << task_qualities[i] << " ";
+  }
+}
+
 void cAnalyzeGenotype::SetSequence(cString _sequence)
 {
   cGenome new_genome(_sequence);

Modified: branches/collect/source/analyze/cAnalyzeGenotype.h
===================================================================
--- branches/collect/source/analyze/cAnalyzeGenotype.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/analyze/cAnalyzeGenotype.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -129,6 +129,7 @@
   int mate_id;
   cString executed_flags; // converted into a string
   tArray<int> task_counts;
+  tArray<double> task_qualities;
 
   // Group 3 : Stats requiring parental genotype (Also from test CPUs)
   double fitness_ratio;
@@ -210,6 +211,7 @@
 
   void Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype = NULL, cCPUTestInfo* test_info = NULL);
   void PrintTasks(std::ofstream& fp, int min_task = 0, int max_task = -1);
+  void PrintTasksQuality(std::ofstream& fp, int min_task = 0, int max_task = -1);
   void CalcLandscape(cAvidaContext& ctx);
 
   // Set...
@@ -331,6 +333,14 @@
     return task_counts;
   }
 
+  double GetTaskQuality(int task_id) const {
+	  if (task_id >= task_counts.GetSize()) return 0;
+	  return task_qualities[task_id];
+  }
+  const tArray<double> & GetTaskQualities() const {
+	  return task_qualities;
+  }
+
   // Comparisons...  Compares a genotype to the "previous" one, which is
   // passed in, in one specified phenotype.
   // Return values are:

Modified: branches/collect/source/cpu/CMakeLists.txt
===================================================================
--- branches/collect/source/cpu/CMakeLists.txt	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/CMakeLists.txt	2007-04-02 19:23:51 UTC (rev 1451)
@@ -6,6 +6,7 @@
   cHardwareBase.cc
   cHardwareCPU.cc
   cHardwareExperimental.cc
+  cHardwareGX.cc
   cHardwareManager.cc
   cHardwareSMT.cc
   cHardwareStatusPrinter.cc

Modified: branches/collect/source/cpu/SConscript
===================================================================
--- branches/collect/source/cpu/SConscript	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/SConscript	2007-04-02 19:23:51 UTC (rev 1451)
@@ -11,6 +11,7 @@
   'cHardwareBase.h',
   'cHardwareCPU.h',
   'cHardwareExperimental.h',
+  'cHardwareGX.h',
   'cHardwareManager.h',
   'cHardwareSMT.h',
   'cHardwareStatusPrinter.h',
@@ -34,6 +35,7 @@
   'cHardwareBase.cc',
   'cHardwareCPU.cc',
   'cHardwareExperimental.cc',
+  'cHardwareGX.cc',
   'cHardwareManager.cc',
   'cHardwareSMT.cc',
   'cHardwareStatusPrinter.cc',

Modified: branches/collect/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cHardwareCPU.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -224,6 +224,7 @@
     
     // Head-based instructions
     tInstLibEntry<tMethod>("h-alloc", &cHardwareCPU::Inst_MaxAlloc, nInstFlag::DEFAULT, "Allocate maximum allowed space"),
+    tInstLibEntry<tMethod>("h-alloc-mw", &cHardwareCPU::Inst_MaxAllocMoveWriteHead),
     tInstLibEntry<tMethod>("h-divide", &cHardwareCPU::Inst_HeadDivide, nInstFlag::DEFAULT, "Divide code between read and write heads."),
     tInstLibEntry<tMethod>("h-divide1RS", &cHardwareCPU::Inst_HeadDivide1RS, 0, "Divide code between read and write heads, at most one mutation on divide, resample if reverted."),
     tInstLibEntry<tMethod>("h-divide2RS", &cHardwareCPU::Inst_HeadDivide2RS, 0, "Divide code between read and write heads, at most two mutations on divide, resample if reverted."),
@@ -324,9 +325,19 @@
     tInstLibEntry<tMethod>("kazi",	&cHardwareCPU::Inst_Kazi),
     tInstLibEntry<tMethod>("kazi5", &cHardwareCPU::Inst_Kazi5),
     tInstLibEntry<tMethod>("die", &cHardwareCPU::Inst_Die),
-	    
+
+    // Promoter Model
+    tInstLibEntry<tMethod>("up-reg-*", &cHardwareCPU::Inst_UpRegulatePromoter),
+    tInstLibEntry<tMethod>("down-reg-*", &cHardwareCPU::Inst_DownRegulatePromoter),
+    tInstLibEntry<tMethod>("up-reg", &cHardwareCPU::Inst_UpRegulatePromoterNop),
+    tInstLibEntry<tMethod>("down-reg", &cHardwareCPU::Inst_DownRegulatePromoterNop),
+    tInstLibEntry<tMethod>("terminate", &cHardwareCPU::Inst_Terminate),
+    tInstLibEntry<tMethod>("promoter", &cHardwareCPU::Inst_Promoter),
+    tInstLibEntry<tMethod>("decay-reg", &cHardwareCPU::Inst_DecayRegulation),
+    
     // Placebo instructions
-    tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip)
+    tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip),
+
   };
   
   const int n_size = sizeof(s_n_array)/sizeof(cNOPEntryCPU);
@@ -440,6 +451,13 @@
   organism->SetRunning(true);
   
   cPhenotype & phenotype = organism->GetPhenotype();
+  
+  //First instruction - check whether we should be starting at a promoter.
+  if (phenotype.GetTimeUsed() == 0)
+  {
+    if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1) Inst_Terminate(m_world->GetDefaultContext());
+  }
+  
   phenotype.IncTimeUsed();
   phenotype.IncCPUCyclesUsed();
 
@@ -453,6 +471,15 @@
   for (int i = 0; i < num_inst_exec; i++) {
     // Setup the hardware for the next instruction to be executed.
     ThreadNext();
+    
+    // In the promoter model, there may be a chance of termination
+    // that causes execution to start at a new instruction
+    const double processivity = m_world->GetConfig().PROMOTER_PROCESSIVITY.Get();
+    if (processivity < 1)
+    {
+      if ( ctx.GetRandom().P(1-processivity) ) Inst_Terminate(ctx);
+    }
+    
     m_advance_ip = true;
     IP().Adjust();
     
@@ -535,8 +562,8 @@
   return true;
 }
 
-// This method will handle the actuall execution of an instruction
-// within single process, once that function has been finalized.
+// This method will handle the actual execution of an instruction
+// within a single process, once that function has been finalized.
 bool cHardwareCPU::SingleProcess_ExecuteInst(cAvidaContext& ctx, const cInstruction& cur_inst) 
 {
   // Copy Instruction locally to handle stochastic effects
@@ -547,7 +574,7 @@
   if (organism->TestExeErr()) actual_inst = m_inst_set->GetRandomInst(ctx);
 #endif /* EXECUTION_ERRORS */
   
-  // Get a pointer to the corrisponding method...
+  // Get a pointer to the corresponding method...
   int inst_idx = m_inst_set->GetLibFunctionIndex(actual_inst);
   
   // Mark the instruction as executed
@@ -555,7 +582,7 @@
 	
   
 #if INSTRUCTION_COUNT
-  // instruction execution count incremeneted
+  // instruction execution count incremented
   organism->GetPhenotype().IncCurInstCount(actual_inst.GetOp());
 #endif
 	
@@ -563,7 +590,7 @@
   const bool exec_success = (this->*(m_functions[inst_idx]))(ctx);
 	
 #if INSTRUCTION_COUNT
-  // decremenet if the instruction was not executed successfully
+  // decrement if the instruction was not executed successfully
   if (exec_success == false) {
     organism->GetPhenotype().DecCurInstCount(actual_inst.GetOp());
   }
@@ -1097,7 +1124,7 @@
 bool cHardwareCPU::Allocate_Random(cAvidaContext& ctx, const int old_size, const int new_size)
 {
   GetMemory().Resize(new_size);
-  
+
   for (int i = old_size; i < new_size; i++) {
     GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
   }
@@ -1167,7 +1194,7 @@
   }
   
   m_mal_active = true;
-  
+
   return true;
 }
 
@@ -2386,6 +2413,20 @@
   } else return false;
 }
 
+// Alloc and move write head if we're successful
+bool cHardwareCPU::Inst_MaxAllocMoveWriteHead(cAvidaContext& ctx)   // Allocate maximal more
+{
+  const int dst = REG_AX;
+  const int cur_size = GetMemory().GetSize();
+  const int alloc_size = Min((int) (m_world->GetConfig().CHILD_SIZE_RANGE.Get() * cur_size),
+                             MAX_CREATURE_SIZE - cur_size);
+  if (Allocate_Main(ctx, alloc_size)) {
+    GetRegister(dst) = cur_size;
+    GetHead(nHardware::HEAD_WRITE).Set(cur_size);
+    return true;
+  } else return false;
+}
+
 bool cHardwareCPU::Inst_Transposon(cAvidaContext& ctx)
 {
   ReadLabel();
@@ -2679,8 +2720,7 @@
 }
 
 
-// @JEB - this instruction does more than two "gets" together
-// it also (1) resets the inputs and (2) resets an organisms task counts
+// @JEB - this instruction does more than two "gets" together, it also resets the inputs
 bool cHardwareCPU::Inst_TaskGet2(cAvidaContext& ctx)
 {
   // Randomize the inputs so they can't save numbers
@@ -2700,7 +2740,7 @@
   organism->DoInput(value2);
   
   // Clear the task number
-  organism->GetPhenotype().ClearEffTaskCount();
+  //organism->GetPhenotype().ClearEffTaskCount();
   
   return true;
 }
@@ -3381,7 +3421,7 @@
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
   GetHead(head_used).Jump(GetRegister(REG_CX) );
-  // JEB - probably shouldn't advance inst ptr after jumping here?
+  // @JEB - probably shouldn't advance IP after jumping here?
   // Any negative number jumps to the beginning of the genome (pos 0)
   // and then we immediately advance past that first instruction.
   return true;
@@ -3679,6 +3719,220 @@
 return true; 
 }
 
+//// Promoter Model ////
+
+// Starting at the current position reads a promoter pattern
+bool cHardwareCPU::GetPromoterPattern(tArray<int>& promoter)
+{
+  // For now a constant that defines behavior
+  const int max_size = 6;
+  int count = 0;
+  
+  cHeadCPU& inst_ptr = IP();
+    
+  while ( (inst_ptr.GetNextInst().GetOp() != m_inst_set->GetNumNops() - 1) &&
+         (count < max_size) ) {
+    count++;
+    inst_ptr++;
+    promoter.Push(inst_ptr.GetInst().GetOp());
+    // If this is the first line of the template, mark it executed.
+    //if (GetLabel().GetSize() <=	m_world->GetConfig().MAX_LABEL_EXE_SIZE.Get()) {
+    //  inst_ptr->SetFlagExecuted();
+    //}
+  }
+
+}
+
+
+// Adjust the weight at promoter positions that match the downstream pattern
+// allowing wildcards and matching of instructions
+bool cHardwareCPU::RegulatePromoter(cAvidaContext& ctx, bool up)
+{
+  static cInstruction promoter_inst = GetInstSet().GetInst(cStringUtil::Stringf("promoter"));
+
+  // Save the initial site so we don't match our own pattern
+  cHeadCPU inst_ptr(IP());
+
+  tArray<int> promoter;
+  GetPromoterPattern(promoter);
+  if (promoter.GetSize() == 0) return true;
+
+  // nop-A is a wildcard of length 1
+  // nop-B is a wildcard of length 1
+  // nop-C (the final nop) terminates the matching pattern, and is not included
+  
+  cHeadCPU search_head(IP());  
+  while (search_head.GetPosition() != inst_ptr.GetPosition()) 
+  {
+    cHeadCPU match_head(search_head);
+    int matched_pos = 0;
+    while (matched_pos < promoter.GetSize())
+    {
+      // Unless the promoter pattern has a nop, we must match the instruction exactly
+      if ( (promoter[matched_pos] > m_inst_set->GetNumNops())
+        && (promoter[matched_pos] != match_head.GetInst().GetOp()) )
+      {
+        break;
+      }
+      matched_pos++;
+      match_head++;
+    }
+    
+    // Successfully matched, change this promoter position weight
+    if (matched_pos == promoter.GetSize())
+    {
+      cHeadCPU change_head(search_head);
+      for (int j=0; j < 5; j++)
+      {
+        change_head++;
+        if (change_head.GetInst() == promoter_inst) {
+          organism->GetPhenotype().RegulatePromoter(change_head.GetPosition(), up);
+        }
+      }
+    }
+    search_head++;
+  }
+  
+  // Debugging code
+  /*
+  tArray<double> w = organism->GetPhenotype().GetPromoterWeights();
+  cerr << "Promoter Weights..." << endl;
+  for (int i = 0; i < w.GetSize(); i++) {
+    cerr << i << " " << w[i] << endl;
+  }
+  */
+}
+
+// Adjust the weight at promoter positions that match the downstream nop pattern
+bool cHardwareCPU::RegulatePromoterNop(cAvidaContext& ctx, bool up)
+{
+  static cInstruction promoter_inst = GetInstSet().GetInst(cStringUtil::Stringf("promoter"));
+
+  // Look for the label directly (no complement)
+  // Save the position before the label, so we don't count it as a regulatory site
+  int start_pos = IP().GetPosition(); 
+  ReadLabel();
+  
+  // Don't allow zero-length label matches. These are too powerful.
+  if (GetLabel().GetSize() == 0) return true;
+ 
+  cHeadCPU search_head(IP());
+  do {
+    search_head++;
+    cHeadCPU match_head(search_head);
+
+    // See whether a matching label is here
+    int i;
+    for (i=0; i < GetLabel().GetSize(); i++)
+    {
+      match_head++;
+      if ( !m_inst_set->IsNop(match_head.GetInst() ) 
+        || (GetLabel()[i] != m_inst_set->GetNopMod( match_head.GetInst())) ) break;
+    }
+  
+    // Matching label found
+    if (i == GetLabel().GetSize())
+    {
+      cHeadCPU change_head(match_head);
+      for (int j=0; j < 5; j++)
+      {
+        change_head++;
+        if (change_head.GetInst() == promoter_inst) {
+         
+          
+          if (change_head.GetPosition() < organism->GetPhenotype().GetCurPromoterWeights().GetSize())
+          {
+            organism->GetPhenotype().RegulatePromoter(change_head.GetPosition(), up);
+          }
+          /*
+          else
+          {
+            // I can't seem to get resizing promoter arrays on allocate to work
+            // promoter weights still get unsynched from the genome size somewhere.
+            cout << change_head.GetPosition() << endl;
+            cout << organism->GetPhenotype().GetCurPromoterWeights().GetSize() << endl;
+            cout << GetMemory().GetSize() << endl;
+            cout << GetMemory().AsString() << endl;
+          }
+          */
+        }
+      }
+    }
+  } while ( start_pos != search_head.GetPosition() );
+  
+  // Debugging code
+  /*
+  tArray<double> w = organism->GetPhenotype().GetPromoterWeights();
+  cerr << "Promoter Weights..." << endl;
+  for (int i = 0; i < w.GetSize(); i++) {
+    cerr << i << " " << w[i] << endl;
+  }
+  */
+}
+
+
+// Move execution to a new promoter
+bool cHardwareCPU::Inst_Terminate(cAvidaContext& ctx)
+{
+  // Reset the CPU, clearing everything except R/W head positions.
+  const int write_head_pos = GetHead(nHardware::HEAD_WRITE).GetPosition();
+  const int read_head_pos = GetHead(nHardware::HEAD_READ).GetPosition();
+  m_threads[m_cur_thread].Reset(this, m_threads[m_cur_thread].GetID());
+  GetHead(nHardware::HEAD_WRITE).Set(write_head_pos);
+  GetHead(nHardware::HEAD_READ).Set(read_head_pos);
+
+  // We want to execute the promoter that we land on.
+  m_advance_ip = false;
+  
+  //organism->ClearInput();
+  
+  // Get the promoter weight list
+  double total_weight = 0;
+  tArray<double> w = organism->GetPhenotype().GetCurPromoterWeights();
+  for (int i = 0; i < w.GetSize(); i++) {
+    total_weight += w[i];
+  }
+ 
+   
+  // If there is no weight (for example if there are no promoters)
+  // then randomly choose a starting position
+  if (total_weight==0)
+  {
+    // Or we could kill the organism...
+    //organism->Die();
+    //return true;
+    
+    int i = m_world->GetRandom().GetInt(w.GetSize());
+    IP().Set(i);
+    return true;
+  }
+  
+  // Add together all of the promoter weights
+  double promoter_choice = (double) m_world->GetRandom().GetDouble(total_weight);
+  double test_total = 0;
+  for (int i = 0; i < w.GetSize(); i++) {
+    test_total += w[i];
+    if (promoter_choice < test_total) {
+      IP().Set(i);
+      break;
+    }
+  }  
+  return true;
+}
+
+bool cHardwareCPU::Inst_Promoter(cAvidaContext& ctx)
+{
+  // Promoters don't do anything themselves
+  return true;
+}
+
+
+bool cHardwareCPU::Inst_DecayRegulation(cAvidaContext& ctx)
+{
+  organism->GetPhenotype().DecayAllPromoterRegulation();
+  return true;
+}
+
 //// Placebo insts ////
 bool cHardwareCPU::Inst_Skip(cAvidaContext& ctx)
 {

Modified: branches/collect/source/cpu/cHardwareCPU.h
===================================================================
--- branches/collect/source/cpu/cHardwareCPU.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cHardwareCPU.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -392,6 +392,7 @@
   bool Inst_CAlloc(cAvidaContext& ctx);
   bool Inst_CDivide(cAvidaContext& ctx);
   bool Inst_MaxAlloc(cAvidaContext& ctx);
+  bool Inst_MaxAllocMoveWriteHead(cAvidaContext& ctx);
   bool Inst_Inject(cAvidaContext& ctx);
   bool Inst_InjectRand(cAvidaContext& ctx);
   bool Inst_InjectThread(cAvidaContext& ctx);
@@ -513,6 +514,20 @@
   bool Inst_HeadDivide0_01(cAvidaContext& ctx);
   bool Inst_HeadDivide0_001(cAvidaContext& ctx);
 
+  //// Promoter Model ////
+  bool GetPromoterPattern(tArray<int>& promoter);
+  bool RegulatePromoter(cAvidaContext& ctx, bool up);
+  bool Inst_UpRegulatePromoter(cAvidaContext& ctx) { RegulatePromoter(ctx, true); }
+  bool Inst_DownRegulatePromoter(cAvidaContext& ctx) { RegulatePromoter(ctx, false); }
+  bool RegulatePromoterNop(cAvidaContext& ctx, bool up);
+  bool Inst_UpRegulatePromoterNop(cAvidaContext& ctx) { RegulatePromoterNop(ctx, true); }
+  bool Inst_DownRegulatePromoterNop(cAvidaContext& ctx) { RegulatePromoterNop(ctx, false); }  
+  bool Inst_UpRegulatePromoterNopDecay(cAvidaContext& ctx);
+  bool Inst_DownRegulatePromoterNopDecay(cAvidaContext& ctx);
+  bool Inst_Terminate(cAvidaContext& ctx);
+  bool Inst_Promoter(cAvidaContext& ctx);
+  bool Inst_DecayRegulation(cAvidaContext& ctx);
+  
   //// Placebo ////
   bool Inst_Skip(cAvidaContext& ctx);
 };

Modified: branches/collect/source/cpu/cHardwareExperimental.cc
===================================================================
--- branches/collect/source/cpu/cHardwareExperimental.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cHardwareExperimental.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -109,15 +109,15 @@
     tInstLibEntry<tMethod>("IO", &cHardwareExperimental::Inst_TaskIO, nInstFlag::DEFAULT, "Output ?BX?, and input new number back into ?BX?"),
     
     // Head-based instructions
-    tInstLibEntry<tMethod>("h-alloc", &cHardwareExperimental::Inst_MaxAlloc, nInstFlag::DEFAULT, "Allocate maximum allowed space"),
+    tInstLibEntry<tMethod>("h-alloc", &cHardwareExperimental::Inst_HeadAlloc, nInstFlag::DEFAULT, "Allocate maximum allowed space"),
     tInstLibEntry<tMethod>("h-divide", &cHardwareExperimental::Inst_HeadDivide, nInstFlag::DEFAULT, "Divide code between read and write heads."),
     tInstLibEntry<tMethod>("h-read", &cHardwareExperimental::Inst_HeadRead),
     tInstLibEntry<tMethod>("h-write", &cHardwareExperimental::Inst_HeadWrite),
     tInstLibEntry<tMethod>("h-copy", &cHardwareExperimental::Inst_HeadCopy, nInstFlag::DEFAULT, "Copy from read-head to write-head; advance both"),
     tInstLibEntry<tMethod>("h-search", &cHardwareExperimental::Inst_HeadSearch, nInstFlag::DEFAULT, "Find complement template and make with flow head"),
     tInstLibEntry<tMethod>("mov-head", &cHardwareExperimental::Inst_MoveHead, nInstFlag::DEFAULT, "Move head ?IP? to the flow head"),
-    tInstLibEntry<tMethod>("jmp-head", &cHardwareExperimental::Inst_JumpHead, nInstFlag::DEFAULT, "Move head ?IP? by amount in CX register; CX = old pos."),
-    tInstLibEntry<tMethod>("get-head", &cHardwareExperimental::Inst_GetHead, nInstFlag::DEFAULT, "Copy the position of the ?IP? head into CX"),
+    tInstLibEntry<tMethod>("jmp-head", &cHardwareExperimental::Inst_JumpHead, nInstFlag::DEFAULT, "Move head ?Flow? by amount in ?CX? register"),
+    tInstLibEntry<tMethod>("get-head", &cHardwareExperimental::Inst_GetHead, nInstFlag::DEFAULT, "Copy the position of the ?IP? head into ?CX?"),
     tInstLibEntry<tMethod>("if-label", &cHardwareExperimental::Inst_IfLabel, nInstFlag::DEFAULT, "Execute next if we copied complement of attached label"),
     tInstLibEntry<tMethod>("set-flow", &cHardwareExperimental::Inst_SetFlow, nInstFlag::DEFAULT, "Set flow-head to position in ?CX?"),
     tInstLibEntry<tMethod>("goto", &cHardwareExperimental::Inst_Goto, nInstFlag::DEFAULT, "Move IP to labeled position matching the label that follows")
@@ -1033,7 +1033,7 @@
 
 
 
-bool cHardwareExperimental::Inst_MaxAlloc(cAvidaContext& ctx)   // Allocate maximal more
+bool cHardwareExperimental::Inst_HeadAlloc(cAvidaContext& ctx)   // Allocate maximal more
 {
   const int dst = FindModifiedRegister(REG_AX);
   const int cur_size = GetMemory().GetSize();
@@ -1073,18 +1073,18 @@
 
 bool cHardwareExperimental::Inst_JumpHead(cAvidaContext& ctx)
 {
-  const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  GetHead(head_used).Jump(GetRegister(REG_CX) );
-  // JEB - probably shouldn't advance inst ptr after jumping here?
-  // Any negative number jumps to the beginning of the genome (pos 0)
-  // and then we immediately advance past that first instruction.
+  const int head_used = FindModifiedHead(nHardware::HEAD_FLOW);
+  const int reg = FindModifiedRegister(REG_CX);
+  GetHead(head_used).Jump(GetRegister(reg));
+  if (head_used == nHardware::HEAD_IP) m_advance_ip = false;
   return true;
 }
 
 bool cHardwareExperimental::Inst_GetHead(cAvidaContext& ctx)
 {
   const int head_used = FindModifiedHead(nHardware::HEAD_IP);
-  GetRegister(REG_CX) = GetHead(head_used).GetPosition();
+  const int reg = FindModifiedRegister(REG_CX);
+  GetRegister(reg) = GetHead(head_used).GetPosition();
   return true;
 }
 

Modified: branches/collect/source/cpu/cHardwareExperimental.h
===================================================================
--- branches/collect/source/cpu/cHardwareExperimental.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cHardwareExperimental.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -304,7 +304,7 @@
   bool Inst_TaskIO(cAvidaContext& ctx);
 
   // Head-based instructions...
-  bool Inst_MaxAlloc(cAvidaContext& ctx);
+  bool Inst_HeadAlloc(cAvidaContext& ctx);
   bool Inst_MoveHead(cAvidaContext& ctx);
   bool Inst_JumpHead(cAvidaContext& ctx);
   bool Inst_GetHead(cAvidaContext& ctx);

Copied: branches/collect/source/cpu/cHardwareGX.cc (from rev 1450, development/source/cpu/cHardwareGX.cc)

Copied: branches/collect/source/cpu/cHardwareGX.h (from rev 1450, development/source/cpu/cHardwareGX.h)

Modified: branches/collect/source/cpu/cHardwareManager.cc
===================================================================
--- branches/collect/source/cpu/cHardwareManager.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cHardwareManager.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -28,6 +28,7 @@
 #include "cHardwareExperimental.h"
 #include "cHardwareSMT.h"
 #include "cHardwareTransSMT.h"
+#include "cHardwareGX.h"
 #include "cInitFile.h"
 #include "cInstSet.h"
 #include "cWorld.h"
@@ -59,6 +60,10 @@
       m_inst_set = new cInstSet(world, cHardwareExperimental::GetInstLib());
 			default_filename = cHardwareExperimental::GetDefaultInstFilename();
 			break;
+    case HARDWARE_TYPE_CPU_GX:
+      m_inst_set = new cInstSet(world, cHardwareGX::GetInstLib());
+			default_filename = cHardwareGX::GetDefaultInstFilename();
+			break;      
 		default:
       m_world->GetDriver().RaiseFatalException(1, "Unknown/Unsupported HARDWARE_TYPE specified");
   }
@@ -129,6 +134,8 @@
       return new cHardwareTransSMT(m_world, in_org, m_inst_set);
     case HARDWARE_TYPE_CPU_EXPERIMENTAL:
       return new cHardwareExperimental(m_world, in_org, m_inst_set);
+    case HARDWARE_TYPE_CPU_GX:
+      return new cHardwareGX(m_world, in_org, m_inst_set);
     default:
       return NULL;
   }

Modified: branches/collect/source/cpu/cTestCPU.cc
===================================================================
--- branches/collect/source/cpu/cTestCPU.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cTestCPU.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -342,7 +342,7 @@
   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.GetSize());
+  organism.GetPhenotype().SetupInject(genome);
 
   // Run the current organism.
   ProcessGestation(ctx, test_info, cur_depth);

Modified: branches/collect/source/cpu/cTestCPUInterface.cc
===================================================================
--- branches/collect/source/cpu/cTestCPUInterface.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/cpu/cTestCPUInterface.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -31,7 +31,7 @@
 
 bool cTestCPUInterface::Divide(cAvidaContext& ctx, cOrganism* parent, cGenome& child_genome)
 {
-  parent->GetPhenotype().TestDivideReset(parent->GetGenome().GetSize());
+  parent->GetPhenotype().TestDivideReset(parent->GetGenome());
   // @CAO in the future, we probably want to pass this child the test_cpu!
   return true;
 }

Modified: branches/collect/source/defs.h
===================================================================
--- branches/collect/source/defs.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/defs.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -87,7 +87,8 @@
 	HARDWARE_TYPE_CPU_ORIGINAL = 0,
 	HARDWARE_TYPE_CPU_SMT,
 	HARDWARE_TYPE_CPU_TRANSSMT,
-	HARDWARE_TYPE_CPU_EXPERIMENTAL
+	HARDWARE_TYPE_CPU_EXPERIMENTAL,
+	HARDWARE_TYPE_CPU_GX
 };
 
 enum tTIMESLICE

Modified: branches/collect/source/main/avida.cc
===================================================================
--- branches/collect/source/main/avida.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/avida.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -82,18 +82,19 @@
   // output copyright message
   cout << "----------------------------------------------------------------------" << endl;
   cout << getAvidaVersion() << endl << endl;
+
   cout << "by Charles Ofria" << endl << endl;
+
   cout << "Lead Developers: David Bryson (Avida) and Kaben Nanlohy (Avida-ED)" << endl << endl;
-  cout << "Portions by Brian Baer, Jeffrey Barrick, Benjamin Beckmann, Jeffrey Clune," << endl
-       << "Travis Collier, Art Covert, Evan Dorn, Sherri Goings, George Hagstrom," << endl
-       << "Dehua Hang, Wei Huang, David Knoester, Dusan Misevic, Elizabeth Ostrowski," << endl
-       << "Matthew Rupp, Jason Stredwick, Bess Walker, Claus Wilke, and Larry Wisne" << endl << endl;
 
-  cout << "With design help from Christoph Adami, C. Titus Brown, Timothy Cooper," << endl
-       << "Santiago Elena, Richard Lenski, Philip McKinley, Robert Pennock, Thomas" << endl
-       << "Schmidt, Robert Schwartz, Eric Torng, Jialan Wang, Daniel Weise, and Gabriel" << endl
-       << "Yedid" << endl;
+  cout << "Active contributors include:  Christoph Adami, Brian Baer, Jeffrey Barrick," << endl
+       << "Benjamin Beckmann, Jeffrey Clune, Art Covert, Santiago Elena, Sherri Goings," << endl
+       << "Heather Goldsby, David Knoester, Richard Lenski, Philip McKinley," << endl
+       << "Dusan Misevic, Elizabeth Ostrowski, Robert Pennock, Matthew Rupp, Eric Torng," << endl
+       << "Bess Walker, and Gabriel Yedid" << endl << endl;
 
+  cout << "For a more complete list of contributors, see the CONTRIBUTORS file." << endl;
+
   cout << endl;
 
   cout << "Copyright (C) 1999-2007 Michigan State University." << endl;

Modified: branches/collect/source/main/cAvidaConfig.h
===================================================================
--- branches/collect/source/main/cAvidaConfig.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cAvidaConfig.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -209,7 +209,7 @@
   CONFIG_ADD_VAR(START_CREATURE, cString, "default-classic.org", "Organism to seed the soup");
   
   CONFIG_ADD_GROUP(REPRODUCTION_GROUP, "Birth and Death");
-  CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent\n8 = Next grid cell (id+1)\n9= Largest energy used in entire population\n10= Largest energy used in neighborhood");
+  CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent\n8 = Next grid cell (id+1)\n9 = Largest energy used in entire population\n10 = Largest energy used in neighborhood");
   CONFIG_ADD_VAR(PREFER_EMPTY, int, 1, "Give empty cells preference in offsping placement?");
   CONFIG_ADD_VAR(ALLOW_PARENT, int, 1, "Allow births to replace the parent organism?");
   CONFIG_ADD_VAR(DEATH_METHOD, int, 2, "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
@@ -285,6 +285,13 @@
   CONFIG_ADD_VAR(MAX_DONATE_EDIT_DIST, int, -1, "Limit on edit distance for donate; -1=no max");
   CONFIG_ADD_VAR(MAX_DONATES, int, 1000000, "Limit on number of donates organisms are allowed.");
   
+  CONFIG_ADD_GROUP(PROMOTER_GROUP, "Promoters");
+  CONFIG_ADD_VAR(PROMOTERS_ENABLED, int, 0, "Use the promoter/terminator execution scheme.\nCertain instructions must also be included.");
+  CONFIG_ADD_VAR(PROMOTER_PROCESSIVITY, double, 1.0, "Chance of not terminating before executing each instruction.");
+  CONFIG_ADD_VAR(PROMOTER_BG_STRENGTH, double, 0, "Probability of positions that are not promoter\ninstructions initiating execution (promoters are 1).");
+  CONFIG_ADD_VAR(REGULATION_STRENGTH, double, 1, "Strength added or subtracted to a promoter by regulation.");
+  CONFIG_ADD_VAR(REGULATION_DECAY_FRAC, double, 0.1, "Fraction of regulation that decays away. \n(Max regulation = REGULATION_STRENGTH / REGULATION_DECAY_FRAC)");
+
   CONFIG_ADD_GROUP(GENEOLOGY_GROUP, "Geneology");
   CONFIG_ADD_VAR(TRACK_MAIN_LINEAGE, int, 1, "Keep all ancestors of the active population?\n0=no, 1=yes, 2=yes,w/sexual population");
   CONFIG_ADD_VAR(THRESHOLD, int, 3, "Number of organisms in a genotype needed for it\n  to be considered viable.");

Modified: branches/collect/source/main/cInstruction.cc
===================================================================
--- branches/collect/source/main/cInstruction.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cInstruction.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -51,4 +51,4 @@
   else if (symbol >= '0' && symbol <= '9') retval = symbol - '0' + 52;
   else retval = 254;
 	return retval;
-}
\ No newline at end of file
+}

Modified: branches/collect/source/main/cOrganism.cc
===================================================================
--- branches/collect/source/main/cOrganism.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cOrganism.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -459,7 +459,6 @@
   for (int i = 0; i < m_output_buf.GetNumStored(); i++) fp << " 0x" << setw(8) << m_output_buf[i];
   fp << endl;
   
-  
   fp << setfill(' ') << setbase(10);
     
   fp << "---------------------------" << endl;

Modified: branches/collect/source/main/cPhenotype.cc
===================================================================
--- branches/collect/source/main/cPhenotype.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cPhenotype.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -104,13 +104,15 @@
  **/
 
 void cPhenotype::SetupOffspring(const cPhenotype & parent_phenotype,
-				int _length)
+				const cGenome & _genome)
 {
   // Copy divide values from parent, which should already be setup.
   merit           = parent_phenotype.merit;
-  genome_length   = _length;
+  genome_length   = _genome.GetSize();
   copied_size     = parent_phenotype.child_copied_size;
   executed_size   = parent_phenotype.executed_size;
+  assert (executed_size > 0);
+  
   gestation_time  = parent_phenotype.gestation_time;
   gestation_start = 0;
   fitness         = parent_phenotype.fitness;
@@ -135,7 +137,8 @@
   cur_sense_count.SetAll(0);  
   for (int j = 0; j < sensed_resources.GetSize(); j++)
 	      sensed_resources[j] =  parent_phenotype.sensed_resources[j];
-
+  SetupPromoterWeights(_genome, true);
+  
   // Copy last values from parent
   last_merit_base           = parent_phenotype.last_merit_base;
   last_bonus                = parent_phenotype.last_bonus;
@@ -199,13 +202,13 @@
  *     - This is the first method run on an otherwise freshly built phenotype.
  **/
 
-void cPhenotype::SetupInject(int _length)
+void cPhenotype::SetupInject(const cGenome & _genome)
 {
   // Setup reasonable initial values injected organism...
-  merit           = _length;
-  genome_length   = _length;
-  copied_size     = _length;
-  executed_size   = _length;
+  genome_length   = _genome.GetSize();
+  merit           = genome_length;
+  copied_size     = genome_length;
+  executed_size   = genome_length;
   gestation_time  = 0;
   gestation_start = 0;
   fitness         = 0;
@@ -223,9 +226,10 @@
   cur_inst_count.SetAll(0);
   sensed_resources.SetAll(0);
   cur_sense_count.SetAll(0);
-
+  SetupPromoterWeights(_genome, true);
+  
   // Copy last values from parent
-  last_merit_base = _length;
+  last_merit_base = genome_length;
   last_bonus      = 1;
   last_num_errors = 0;
   last_num_donates = 0;
@@ -279,7 +283,7 @@
  * This function is run whenever an organism executes a successful divide.
  **/
 
-void cPhenotype::DivideReset(int _length)
+void cPhenotype::DivideReset(const cGenome & _genome)
 {
   assert(time_used > 0);
   assert(initialized == true);
@@ -297,7 +301,7 @@
     merit = cur_merit_base * cur_bonus;
   }
   
-  genome_length   = _length;
+  genome_length   = _genome.GetSize();
   (void) copied_size;          // Unchanged
   (void) executed_size;        // Unchanged
   gestation_time  = time_used - gestation_start;
@@ -368,6 +372,7 @@
     cpu_cycles_used = 0;
     time_used = 0;
     neutral_metric += m_world->GetRandom().GetRandNormal();
+    SetupPromoterWeights(_genome, true);
   }
 
   if (m_world->GetConfig().GENERATION_INC_METHOD.Get() == GENERATION_INC_BOTH) generation++;
@@ -386,7 +391,7 @@
  * and copied size in its merit.
  **/
 
-void cPhenotype::TestDivideReset(int _length)
+void cPhenotype::TestDivideReset(const cGenome & _genome)
 {
   assert(time_used > 0);
   assert(initialized == true);
@@ -395,7 +400,7 @@
   int cur_merit_base = CalcSizeMerit();
   merit           = cur_merit_base * cur_bonus;
 
-  genome_length   = _length;
+  genome_length   = _genome.GetSize();
   (void) copied_size;                            // Unchanged
   (void) executed_size;                          // Unchanged
   gestation_time  = time_used - gestation_start;
@@ -427,7 +432,8 @@
   cur_inst_count.SetAll(0);
   cur_sense_count.SetAll(0); 
   sensed_resources.SetAll(-1.0);
-
+  SetupPromoterWeights(_genome, true);
+  
   // Setup other miscellaneous values...
   num_divides++;
   generation++;
@@ -484,6 +490,10 @@
   gestation_start = 0;
   fitness         = clone_phenotype.fitness;
   div_type        = clone_phenotype.div_type;
+  cur_promoter_weights = clone_phenotype.cur_promoter_weights; // @JEB Not correct if clone is not of fresh phenotype 
+  base_promoter_weights = clone_phenotype.base_promoter_weights; // @JEB Not correct if clone is not of fresh phenotype 
+  promoter_repression = clone_phenotype.promoter_repression; // @JEB Not correct if clone is not of fresh phenotype 
+  promoter_activation = clone_phenotype.promoter_activation; // @JEB Not correct if clone is not of fresh phenotype 
 
   assert(genome_length > 0);
   assert(copied_size > 0);
@@ -503,8 +513,8 @@
   cur_sense_count.SetAll(0);  
   for (int j = 0; j < sensed_resources.GetSize(); j++)
 	      sensed_resources[j] =  clone_phenotype.sensed_resources[j];
+  //SetupPromoterWeights(_genome); Do we reset here?
 
-
   // Copy last values from parent
   last_merit_base          = clone_phenotype.last_merit_base;
   last_bonus               = clone_phenotype.last_bonus;
@@ -794,6 +804,17 @@
   for (int i = 0; i < cur_task_count.GetSize(); i++)
     fp << " " << cur_task_count[i] << " (" << cur_task_quality[i] << ")";
   fp << endl;
+  
+  if (m_world->GetConfig().PROMOTERS_ENABLED.Get() == 1)
+  {
+    fp << "Promoters:     ";
+    for (int i=0; i<cur_promoter_weights.GetSize(); i++)
+    {
+      if (cur_promoter_weights[i] != m_world->GetConfig().PROMOTER_BG_STRENGTH.Get()) fp << i << " (" << cur_promoter_weights[i] << ") ";
+    }
+    fp << endl;
+  }
+
 }
 
 int cPhenotype::CalcSizeMerit() const
@@ -832,4 +853,61 @@
   }
 
   return out_size;
+} 
+
+void cPhenotype::SetupPromoterWeights(const cGenome & _genome, const bool clear)
+{
+  if (!m_world->GetConfig().PROMOTERS_ENABLED.Get()) return;
+
+  // Ideally, this wouldn't be hard-coded
+  static cInstruction promoter_inst = m_world->GetHardwareManager().GetInstSet().GetInst(cStringUtil::Stringf("promoter"));
+
+  int old_size = base_promoter_weights.GetSize();
+  cur_promoter_weights.Resize(_genome.GetSize());
+  base_promoter_weights.Resize(_genome.GetSize());
+  promoter_repression.Resize(_genome.GetSize());
+  promoter_activation.Resize(_genome.GetSize());
+
+  // Only change new regions of the genome (that might have been allocated since this was last called)
+  for ( int i = (clear ? 0 : old_size); i<_genome.GetSize(); i++)
+  {
+    base_promoter_weights[i] = 1;
+    promoter_repression[i] = 1;
+    promoter_activation[i] = 1;
+
+    // Now change the weights at instructions that are not promoters if called for
+    if ( _genome[i] != promoter_inst)
+    {
+      base_promoter_weights[i] *= m_world->GetConfig().PROMOTER_BG_STRENGTH.Get(); 
+    }
+    cur_promoter_weights[i] = base_promoter_weights[i];
+  }
 }
+
+void cPhenotype::DecayAllPromoterRegulation()
+{
+  for ( int i=0; i<cur_promoter_weights.GetSize(); i++)
+  {
+    promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
+    promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
+    cur_promoter_weights[i] = base_promoter_weights[i] * promoter_activation[i] / promoter_repression[i];
+  }
+}
+
+void cPhenotype::RegulatePromoter(const int i, const bool up )
+{
+  // Make sure we were initialized
+  assert ( (promoter_activation.GetSize() > 0) && (promoter_activation.GetSize() > 0) );
+  
+  if (up) {
+    promoter_activation[i] += m_world->GetConfig().REGULATION_STRENGTH.Get(); 
+    promoter_activation[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
+  }
+  else {
+    promoter_repression[i] += m_world->GetConfig().REGULATION_STRENGTH.Get(); 
+    promoter_repression[i] *= (1 - m_world->GetConfig().REGULATION_DECAY_FRAC.Get());
+  }
+  
+ cur_promoter_weights[i] = base_promoter_weights[i] * promoter_activation[i] / promoter_repression[i];
+}
+

Modified: branches/collect/source/main/cPhenotype.h
===================================================================
--- branches/collect/source/main/cPhenotype.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cPhenotype.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -28,6 +28,9 @@
 
 #include <fstream>
 
+#ifndef cGenome_h
+#include "cGenome.h"
+#endif
 #ifndef cMerit_h
 #include "cMerit.h"
 #endif
@@ -97,19 +100,25 @@
   double div_type;          // Type of the divide command used
 
   // 2. These are "in progress" variables, updated as the organism operates
-  double cur_bonus;               // Current Bonus
-  int cur_num_errors;             // Total instructions executed illeagally.
-  int cur_num_donates;            // Number of donations so far
-  tArray<int> cur_task_count;     // Total times each task was performed
-  tArray<int> eff_task_count;     // Total times each task was performed (resetable during the life of the organism)
-  tArray<double> cur_task_quality;	  // Average (total?) quality with which each task was performed
-  tArray<int> cur_reaction_count; // Total times each reaction was triggered.  
-  tArray<double> cur_reaction_add_reward; // Bonus change from triggering each reaction.
-  tArray<int> cur_inst_count;	    // Intsruction exection counter
-  tArray<int> cur_sense_count;     // Total times resource combinations have been sensed; @JEB 
-  tArray<double> sensed_resources; // Resources of which the organism is explictly aware
-  tArray<cCodeLabel> active_transposons; // Transposons that are active
+  double cur_bonus;                           // Current Bonus
+  int cur_num_errors;                         // Total instructions executed illeagally.
+  int cur_num_donates;                        // Number of donations so far
+  tArray<int> cur_task_count;                 // Total times each task was performed
+  tArray<int> eff_task_count;                 // Total times each task was performed (resetable during the life of the organism)
+  tArray<double> cur_task_quality;            // Average (total?) quality with which each task was performed
+  tArray<int> cur_reaction_count;             // Total times each reaction was triggered.  
+  tArray<double> cur_reaction_add_reward;     // Bonus change from triggering each reaction.
+  tArray<int> cur_inst_count;                 // Instruction exection counter
+  tArray<int> cur_sense_count;                // Total times resource combinations have been sensed; @JEB 
+  tArray<double> sensed_resources;            // Resources which the organism has sensed; @JEB 
+  tArray<cCodeLabel> active_transposons;      // Transposons that are active; @JEB
+  tArray<double> base_promoter_weights;       // Baseline chance of starting execution from each position; @JEB 
+  tArray<double> cur_promoter_weights;        // Current of starting execution from each position, adjusted for regulation; @JEB 
+  tArray<double> promoter_activation;         // Amount of positive regulation in play at each site; @JEB 
+  tArray<double> promoter_repression;         // Amount of negative regulation in play at each site; @JEB 
+  
   tHashTable<void*, cTaskState*> m_task_states;
+
   
   // 3. These mark the status of "in progess" variables at the last divide.
   double last_merit_base;         // Either constant or based on genome length.
@@ -132,7 +141,7 @@
   int age;               // Number of updates organism has survived for.
   cString fault_desc;    // A description of the most recent error.
   double neutral_metric; // Undergoes drift (gausian 0,1) per generation
-  double life_fitness; 	 // Organism fitness during it's lifetime, 
+  double life_fitness; 	 // Organism fitness during its lifetime, 
 		         // calculated based on merit just before the divide
 
   // 5. Status Flags...  (updated at each divide)
@@ -173,16 +182,16 @@
   bool OK();
 
   // Run when being setup *as* and offspring.
-  void SetupOffspring(const cPhenotype & parent_phenotype, int _length);
+  void SetupOffspring(const cPhenotype & parent_phenotype, const cGenome & _genome);
 
   // Run when being setup as an injected organism.
-  void SetupInject(int _length);
+  void SetupInject(const cGenome & _genome);
 
   // Run when this organism successfully executes a divide.
-  void DivideReset(int _length);
+  void DivideReset(const cGenome & _genome);
   
   // Same as DivideReset(), but only run in test CPUs.
-  void TestDivideReset(int _length);
+  void TestDivideReset(const cGenome & _genome);
 
   // Run when an organism is being forced to replicate, but not at the end
   // of its replication cycle.  Assume exact clone with no mutations.
@@ -231,6 +240,7 @@
   const tArray<int>& GetCurSenseCount() const { assert(initialized == true); return cur_sense_count; }
   double GetSensedResource(int _in) { assert(initialized == true); return sensed_resources[_in]; }
   const tArray<cCodeLabel>& GetActiveTransposons() { assert(initialized == true); return active_transposons; }
+  const tArray<double>& GetCurPromoterWeights() { assert(initialized == true); return cur_promoter_weights; }
 
   double GetLastMeritBase() const { assert(initialized == true); return last_merit_base; }
   double GetLastBonus() const { assert(initialized == true); return last_bonus; }
@@ -283,7 +293,7 @@
   void SetFault(const cString& in_fault) { fault_desc = in_fault; }
   void SetNeutralMetric(double _in){ neutral_metric = _in; }
   void SetLifeFitness(double _in){ life_fitness = _in; }
-  void SetLinesExecuted(int _exe_size) { executed_size = _exe_size; }
+  void SetLinesExecuted(int _exe_size) { executed_size = _exe_size;   assert(executed_size > 0); }
   void SetLinesCopied(int _copied_size) { child_copied_size = _copied_size; }
   void SetDivType(double _div_type) { div_type = _div_type; }  
   void SetDivideSex(bool _divide_sex) { divide_sex = _divide_sex; }  
@@ -301,7 +311,10 @@
   void DecCurInstCount(int _inst_num)  { assert(initialized == true); cur_inst_count[_inst_num]--; } 
   
   void ActivateTransposon(cCodeLabel & in_label) { assert(initialized == true); active_transposons.Push(in_label); }
-
+  void SetupPromoterWeights(const cGenome & _genome, const bool clear = false);
+  void DecayAllPromoterRegulation();
+  void RegulatePromoter(const int i, const bool up );
+  
   void IncAge()      { assert(initialized == true); age++; }
   void IncCPUCyclesUsed() { assert(initialized == true); cpu_cycles_used++; }
   void IncTimeUsed(int i=1) { assert(initialized == true); time_used+=i; }

Modified: branches/collect/source/main/cPopulation.cc
===================================================================
--- branches/collect/source/main/cPopulation.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cPopulation.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -33,6 +33,7 @@
 #include "cDataFile.h"
 #include "cEnvironment.h"
 #include "functions.h"
+#include "cGenome.h"
 #include "cGenomeUtil.h"
 #include "cGenotype.h"
 #include "cHardwareBase.h"
@@ -291,10 +292,10 @@
   tArray<cMerit> merit_array;
   
   // Update the parent's phenotype.
-  // This needs to be done before the parent goes into the brith chamber
+  // This needs to be done before the parent goes into the birth chamber
   // or the merit doesn't get passed onto the child correctly
   cPhenotype& parent_phenotype = parent_organism.GetPhenotype();
-  parent_phenotype.DivideReset(parent_organism.GetGenome().GetSize());
+  parent_phenotype.DivideReset(parent_organism.GetGenome());
   
   birth_chamber.SubmitOffspring(ctx, child_genome, parent_organism, child_array, merit_array);
   
@@ -328,8 +329,8 @@
     }
     
     // Update the phenotypes of each child....
-    const int child_length = child_array[i]->GetGenome().GetSize();
-    child_array[i]->GetPhenotype().SetupOffspring(parent_phenotype,child_length);
+    const cGenome & child_genome = child_array[i]->GetGenome();
+    child_array[i]->GetPhenotype().SetupOffspring(parent_phenotype,child_genome);
     
     child_array[i]->GetPhenotype().SetMerit(merit_array[i]);
     
@@ -1600,8 +1601,11 @@
     stats.SumSize().Add(cur_genotype->GetLength(), abundance);
     
     // Calculate this genotype's contribution to entropy
+    // - when p = 1.0, partial_ent calculation would return -0.0. This may propagate
+    //   to the output stage, but behavior is dependent on compiler used and optimization
+    //   level.  For consistent output, ensures that 0.0 is returned.
     const double p = ((double) abundance) / (double) num_organisms;
-    const double partial_ent = -(p * Log(p));
+    const double partial_ent = (p == 1.0) ? 0.0 : -(p * Log(p)); 
     entropy += partial_ent;
     
     // Do any special calculations for threshold genotypes.
@@ -1651,9 +1655,12 @@
     stats.SumSpeciesAge().Add(species_age, abundance);
     
     // Caculate entropy on the species level...
+    // - when p = 1.0, partial_ent calculation would return -0.0. This may propagate
+    //   to the output stage, but behavior is dependent on compiler used and optimization
+    //   level.  For consistent output, ensures that 0.0 is returned.
     if (abundance > 0) {
       double p = ((double) abundance) / (double) num_organisms;
-      double partial_ent = -(p * Log(p));
+      double partial_ent = (p == 1.0) ? 0.0 : -(p * Log(p));
       species_entropy += partial_ent;
     }
     
@@ -1939,15 +1946,13 @@
         current_cell += 1;
       }
     }
-    cout << (*it).id_num << " "
-    << (*it).parent_id << " "
-    << (*it).genotype->GetParentID() << " "
-    << (*it).genotype->GetNumOffspringGenotypes() << " "
-    << (*it).num_cpus << " "
-    << (*it).genotype->GetNumOrganisms() << endl;
-    if (soup_full){
-      cout << "cPopulation::LoadDumpFile: You are trying to load more organisms than there is space!" << endl;
-      cout << "cPopulation::LoadDumpFile: Remaining organisms are ignored." << endl;
+
+// @DMB - This seems to be debugging output...
+//    cout << (*it).id_num << " " << (*it).parent_id << " " << (*it).genotype->GetParentID() << " "
+//         << (*it).genotype->GetNumOffspringGenotypes() << " " << (*it).num_cpus << " " << (*it).genotype->GetNumOrganisms() << endl;
+    
+    if (soup_full) {
+      cout << "Warning: Too many organisms in population file, remainder ignored" << endl;
       break;
     }
   }
@@ -2207,7 +2212,7 @@
   
   // Setup the phenotype...
   cPhenotype & phenotype = new_organism->GetPhenotype();
-  phenotype.SetupInject(new_genotype->GetLength());
+  phenotype.SetupInject(new_genotype->GetGenome());
   phenotype.SetMerit( cMerit(new_genotype->GetTestMerit(ctx)) );
   
   // @CAO are these really needed?

Modified: branches/collect/source/main/cStats.cc
===================================================================
--- branches/collect/source/main/cStats.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cStats.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -47,11 +47,11 @@
   , avida_time(0)
   , data_manager(this, "population_data")
   , rave_true_replication_rate( 500 )
-  , entropy(0)
-  , species_entropy(0)
-  , energy(0)
-  , dom_fidelity(0)
-  , ave_fidelity(0)
+  , entropy(0.0)
+  , species_entropy(0.0)
+  , energy(0.0)
+  , dom_fidelity(0.0)
+  , ave_fidelity(0.0)
   , max_viable_fitness(0)
   , dom_genotype(NULL)
   , dom_merit(0)
@@ -101,6 +101,8 @@
   , tot_thresh_species(0)
   , tot_lineages(0)
   , tot_executed(0)
+  , num_resamplings(0)
+  , num_failedResamplings(0)
   , last_update(0)
   , num_bought(0)
   , num_sold(0)

Modified: branches/collect/source/main/cTaskLib.cc
===================================================================
--- branches/collect/source/main/cTaskLib.cc	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cTaskLib.cc	2007-04-02 19:23:51 UTC (rev 1451)
@@ -345,6 +345,9 @@
   else if (name == "fibonacci_seq")
     Load_FibonacciSequence(name, info, envreqs, errors);
 
+   // Optimization Tasks
+  if (name == "optimize")
+	  Load_Optimize(name, info, envreqs, errors);
 
   if (name == "mult")
     Load_Mult(name, info, envreqs, errors);
@@ -2111,8 +2114,83 @@
   return 0.0;
 }
 
+void cTaskLib::Load_Optimize(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors)
+{
+	cArgSchema schema;
 
+	// Integer Arguments
+	schema.AddEntry("function", 0, cArgSchema::SCHEMA_INT);
 
+	cArgContainer* args = cArgContainer::Load(argstr, schema, errors);
+	if (args) 
+	{
+		switch (args->GetInt(0))
+		{
+		case 1:
+			envreqs.SetMinOutputs(1);
+		case 2:
+			envreqs.SetMinOutputs(2);
+		case 3:
+			envreqs.SetMinOutputs(2);
+		};
+
+		NewTask(name, "Optimize", &cTaskLib::Task_Optimize, 0, args);
+	}
+}
+
+double cTaskLib::Task_Optimize(cTaskContext& ctx) const
+{
+	// if the org hasn't output yet enough numbers, just return without completing any tasks
+	if (ctx.GetOutputBuffer().GetNumStored() < ctx.GetOutputBuffer().GetCapacity()) 
+		return 0;
+
+	double quality = 0.0;
+
+	// which function are we currently checking?
+	const int function = ctx.GetTaskEntry()->GetArguments().GetInt(0);
+	
+	// always need x, at least for now, turn it into a double between 0 and 1
+	unsigned outy, outx = ctx.GetOutputBuffer()[0];
+	double y, x = (double)outx / 0xffffffff;
+	
+	switch(function)
+	{
+	case 1:
+		quality = 1 - x;
+		break;
+
+	case 2:
+		// for F2 need y as well
+		outy = ctx.GetOutputBuffer()[1];
+		y = (double)outy / 0xffff;
+		quality = 1 - ((1+y)*(1-sqrt(x/(1+y))))/2.0;	// F2
+		break;
+
+	case 3:
+		// for F3 need y as well
+		outy = ctx.GetOutputBuffer()[1];
+		y = (double)outy / 0xffff;
+		quality = 1 - ((1+y)*(1-pow(x/(1+y),2)))/2.0;	// F3
+		break;
+
+	default:
+		quality = .001;
+	}
+
+	// because want org to only have 1 shot to use outputs for all functions at once, even if they
+	// output numbers that give a quality of 0 on a function, still want to mark it as completed
+	// so give it a very low quality instead of 0 (if using limited resources they still will get
+	// no reward because set the minimum consumed to max*.001, meaning even if they get the max
+	// possible fraction they'll be below minimum allowed consumed and will consume nothing
+	
+	if (quality < .001)
+		return .001;
+	else
+		return quality;
+	
+	return 0;
+}
+
 void cTaskLib::Load_Mult(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors)
 {
   cArgSchema schema;

Modified: branches/collect/source/main/cTaskLib.h
===================================================================
--- branches/collect/source/main/cTaskLib.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/main/cTaskLib.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -246,6 +246,10 @@
   void Load_FibonacciSequence(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);
   double Task_FibonacciSequence(cTaskContext& ctx) const;
   
+   // Optimization Tasks
+  void Load_Optimize(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);
+  double Task_Optimize(cTaskContext& ctx) const;
+
   void Load_Mult(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);
   double Task_Mult(cTaskContext& ctx) const;
   void Load_Div(const cString& name, const cString& argstr, cEnvReqs& envreqs, tList<cString>* errors);

Copied: branches/collect/source/targets/avida-viewer/NOTES (from rev 1450, development/source/targets/avida-viewer/NOTES)

Modified: branches/collect/source/targets/avida-viewer/cSymbolUtil.h
===================================================================
--- branches/collect/source/targets/avida-viewer/cSymbolUtil.h	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/source/targets/avida-viewer/cSymbolUtil.h	2007-04-02 19:23:51 UTC (rev 1451)
@@ -20,7 +20,7 @@
   static char GetBreedSymbol(    const cPopulationCell & cell );
   static char GetParasiteSymbol( const cPopulationCell & cell );
   static char GetMutSymbol(      const cPopulationCell & cell );
-  static char GetThreadSymbol(const cPopulationCell & cell);
+  static char GetThreadSymbol(   const cPopulationCell & cell );
   static char GetLineageSymbol(  const cPopulationCell & cell );
 };
 

Modified: branches/collect/support/config/avida.cfg
===================================================================
--- branches/collect/support/config/avida.cfg	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/support/config/avida.cfg	2007-04-02 19:23:51 UTC (rev 1451)
@@ -17,7 +17,7 @@
 ### ARCH_GROUP ###
 # Architecture Variables
 WORLD_X 60        # Width of the Avida world
-WORLD_Y 60       # Height 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
@@ -47,7 +47,10 @@
                          # 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)
@@ -106,6 +109,10 @@
 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
@@ -151,6 +158,17 @@
 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?

Modified: branches/collect/support/config/instset-experimental.cfg
===================================================================
--- branches/collect/support/config/instset-experimental.cfg	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/support/config/instset-experimental.cfg	2007-04-02 19:23:51 UTC (rev 1451)
@@ -25,10 +25,11 @@
 jmp-head   1   # x   Move ?IP? head by fixed amount in CX.  Set old pos in CX.
 get-head   1   # y   Get position of specified head in CX.
 if-label   1   # z
-set-flow   1   # A   Move flow-head to address in ?CX?
-label      1   # B   delineate labeled regions of the genome
-goto       1   # C   Move IP to the labeled position in the genome
+label      1   # A   delineate labeled regions of the genome
+#goto       1   # B   Move IP to the labeled position in the genome
 
+#set-flow   1   # C   Move flow-head to address in ?CX?
+
 #adv-head   1
 #jump-f     1
 #jump-b     1

Modified: branches/collect/support/scripts/trace_movie.pl
===================================================================
--- branches/collect/support/scripts/trace_movie.pl	2007-04-02 17:32:12 UTC (rev 1450)
+++ branches/collect/support/scripts/trace_movie.pl	2007-04-02 19:23:51 UTC (rev 1451)
@@ -66,7 +66,7 @@
 use Pod::Usage;
 my ($help, $man);
 my $frame_limit = 1000;
-my ($input, $output, $trace, $movie);
+my ($input, $output, $trace, $movie, $collapse_frames);
 #pod2usage(1) if (scalar @ARGV == 0);
 GetOptions(
 	'help|?' => \$help, 'man' => \$man,
@@ -74,11 +74,12 @@
 	'trace|t=s' => \$trace,
 	'output|o=s' => \$output,
 	'movie|m' => \$movie,
-	'frame-limit|f=s' => \$frame_limit
+	'frame-limit|f=s' => \$frame_limit,
+	'collapse|c' => \$collapse_frames,
 ) or pod2usage(2);
 pod2usage(1) if $help;
 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
-pod2usage(1) if (!defined $output or !defined $input);
+pod2usage(1) if (!defined $output or !defined $input or !defined $trace);
 
 #Other options
 my $each_execution_once = 1;
@@ -86,12 +87,16 @@
 my $data;
 
 #Load the genome from the .org file
-open ORGANISM, "$input";
+open ORGANISM, "$input" or die "Could not open organism file: $input";
 our @inst = <ORGANISM>;
 close ORGANISM;
 chomp @inst;
 @inst = grep !/^#/, @inst; #comments
 @inst = grep $_, @inst; #blank lines
+foreach my $inst (@inst)
+{
+	$inst =~ s/\s*#.*$//;
+}
 #print +(join "\n", @org_lines) . "\n";
 
 #Load the trace from the .org file
@@ -140,7 +145,7 @@
 		#The next line is merit/bonus/tasks
 		$on_line = <TRACE>;
 		chomp $on_line;
-		$on_line =~ m/Bonus:\s*(\d+)\s*Errors:\s*(\d+)\s*Donates:\s*(\d+)/;
+		$on_line =~ m/Bonus:\s*(\S+)\s*Errors:\s*(\d+)\s*Donates:\s*(\d+)/;
 		$t->{bonus} = $1;
 		$t->{donates} = $3;
 		
@@ -178,6 +183,18 @@
 			@{$t->{resources}} = @{$t->{resources}} = split /\s+/, $cur_resource_line;
 		}
 		#print Dumper($t);
+		
+		#Check to see if the last fram added was at the same location		
+		if ($collapse_frames && $trace[$#trace])
+		{
+		  	#print $trace[$#trace]->{'inst'} . " " . $t->{'inst'} . "\n";
+		  	if ($trace[$#trace]->{'inst'} == $t->{'inst'})
+			{
+				pop @trace;
+				#print "removed down to: " . scalar @trace . "\n";
+			}
+		}
+		
 		push @trace, $t;
 	}
 	if ($_ =~ s/^Resources: //)
@@ -249,19 +266,24 @@
 
 
 our $inst_to_style = {
-	'nop-A'   => { 'c' => 'red',     's' => 'circle' },
-	'nop-B'   => { 'c' => 'green',   's' => 'circle' },
-	'nop-C'   => { 'c' => 'blue',    's' => 'circle' },
-	'sense'   => { 'c' => 'blue',    's' => 'triangle' },
-	'goto'    => { 'c' => 'green',   's' => 'square' },
-	'label'   => { 'c' => 'red',     's' => 'square' },
-	'throw'   => { 'c' => 'green',   's' => 'square' },
-	'catch'   => { 'c' => 'red',     's' => 'square' },
-	'nand'    => { 'c' => 'orange',  's' => 'square' },
-	'get'     => { 'c' => 'magenta', 's' => 'square' },
-	'put'     => { 'c' => 'cyan',    's' => 'square' },
-	'repro'   => { 'c' => 'purple',  's' => 'square' },
-    'default' => { 'c' => 'black',   's' => 'square' }
+	'nop-A'   		=> { 'c' => 'red',     's' => 'circle' },
+	'nop-B'   		=> { 'c' => 'green',   's' => 'circle' },
+	'nop-C'   		=> { 'c' => 'blue',    's' => 'circle' },
+	'sense'   		=> { 'c' => 'blue',    's' => 'triangle' },
+	'goto'    		=> { 'c' => 'green',   's' => 'square' },
+	'label'   		=> { 'c' => 'red',     's' => 'square' },
+	'throw'   		=> { 'c' => 'green',   's' => 'square' },
+	'catch'   		=> { 'c' => 'red',     's' => 'square' },
+	'promoter'   	=> { 'c' => 'green',   's' => 'square' },
+	'terminate'  	=> { 'c' => 'red',     's' => 'square' },	
+	'up-reg'     	=> { 'c' => 'green',   's' => 'triangle' },
+	'down-reg'   	=> { 'c' => 'red',     's' => 'triangle' },	
+	'nand'       	=> { 'c' => 'orange',  's' => 'square' },
+	'get'        	=> { 'c' => 'magenta', 's' => 'square' },
+	'put'        	=> { 'c' => 'cyan',    's' => 'square' },
+	'metabolize' 	=> { 'c' => 'cyan',    's' => 'square' },	
+	'repro'   		=> { 'c' => 'purple',  's' => 'square' },
+    'default' 		=> { 'c' => 'black',   's' => 'square' }
 };
 
 our $max_label_size = 8;
@@ -429,7 +451,7 @@
 			print Dumper($trace[$i]->{tasks}, $trace[$i-1]->{tasks});
 		}
 		$text_color = ($i==0 or $trace[$i]->{tasks}->[$b] == $trace[$i-1]->{tasks}->[$b]) ? $colors->{black} : $colors->{red};
-		$img->string(gdMediumBoldFont,250 + 50 * $b,$text_y + 54,"$trace[$i]->{tasks}->[$b]",$text_color);
+		$img->string(gdMediumBoldFont,250 + 60 * $b,$text_y + 54,"$trace[$i]->{tasks}->[$b]",$text_color);
 	}
 
 	#$img->string(gdMediumBoldFont,3,$text_y + 72,"Effective Time:",$colors->{black});
@@ -445,7 +467,7 @@
 				print Dumper($trace[$i]->{resources}, $trace[$i-1]->{resources});
 			}
 			$text_color = ($i==0 or $trace[$i]->{resources}->[$b] == $trace[$i-1]->{resources}->[$b]) ? $colors->{black} : $colors->{red};
-			$img->string(gdMediumBoldFont,250 + 50 * $b,$text_y + 72,"$trace[$i]->{resources}->[$b]",$text_color);
+			$img->string(gdMediumBoldFont,250 + 60 * $b,$text_y + 72, sprintf("%.2e",$trace[$i]->{resources}->[$b]) ,$text_color);
 		}
 	}
 			

Copied: branches/collect/tests (from rev 1450, development/tests)




More information about the Avida-cvs mailing list