[Avida-SVN] r3005 - in development/source: analyze cpu

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Fri Dec 5 21:23:39 PST 2008


Author: brysonda
Date: 2008-12-06 00:23:39 -0500 (Sat, 06 Dec 2008)
New Revision: 3005

Modified:
   development/source/analyze/cAnalyze.cc
   development/source/cpu/cCPUTestInfo.cc
   development/source/cpu/cCPUTestInfo.h
Log:
Add support for setting the state grid to use in the TRACE command.  This can be accomplished by passing "sg=#" as the first argument following the output directory.  For example:

TRACE archive/ sg=1

As in the example, # is simply an integer at the moment, where 0 is the first grid listed in the environment file.   Eventually this should be changed to use the name of the state grid.

Also note that since the TRACE command creates the file name based on the organism's ID, it will overwrite existing files in the output directory.   When performing analysis on a genotype with multiple different state grids it will be necessary to specify different output directories.

All other arguments to the TRACE command should be processed in the same order as before, with and without a 'sg=' argument.

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2008-12-06 04:39:54 UTC (rev 3004)
+++ development/source/analyze/cAnalyze.cc	2008-12-06 05:23:39 UTC (rev 3005)
@@ -1728,11 +1728,25 @@
 {
   cString msg;
   tArray<int> manual_inputs;
+  int sg = 0;
   
   // Process our arguments; manual inputs must be the last arguments
 
   cString directory      = PopDirectory(cur_string.PopWord(), cString("archive/"));           // #1
-  int use_resources      = (cur_string.GetSize()) ? cur_string.PopWord().AsInt() : 0;         // #2
+  cString first_arg = cur_string.PopWord();
+  
+  if (first_arg.IsSubstring("sg=", 0)) {
+    first_arg.Pop('=');
+    sg = first_arg.AsInt();
+    if (sg < 0 || sg >= m_world->GetEnvironment().GetNumStateGrids()) {
+      msg.Set("invalid state grid selection");
+      m_world->GetDriver().NotifyWarning(msg);
+      return;
+    }
+    first_arg = cur_string.PopWord();
+  }
+  
+  int use_resources      = (first_arg.GetSize()) ? first_arg.AsInt() : 0;                     // #2
   int update             = (cur_string.GetSize()) ? cur_string.PopWord().AsInt() : -1;        // #3
   bool use_random_inputs = (cur_string.GetSize()) ? cur_string.PopWord().AsInt() == 1: false; // #4
   bool use_manual_inputs = false;                                                             // #5+
@@ -1781,6 +1795,7 @@
     else
       test_info.UseRandomInputs(use_random_inputs); 
     test_info.SetResourceOptions(use_resources, m_resources, update, m_resource_time_spent_offset);
+    test_info.SetCurrentStateGridID(sg);
 
     if (m_world->GetVerbosity() >= VERBOSE_ON){
       msg = cString("Tracing ") + filename;

Modified: development/source/cpu/cCPUTestInfo.cc
===================================================================
--- development/source/cpu/cCPUTestInfo.cc	2008-12-06 04:39:54 UTC (rev 3004)
+++ development/source/cpu/cCPUTestInfo.cc	2008-12-06 05:23:39 UTC (rev 3005)
@@ -38,6 +38,7 @@
   , use_manual_inputs(false)
   , m_tracer(NULL)
   , m_inst_set(NULL)
+  , m_cur_sg(0)
   , org_array(max_tests)
   , m_res_method(RES_INITIAL)
   , m_res(NULL)

Modified: development/source/cpu/cCPUTestInfo.h
===================================================================
--- development/source/cpu/cCPUTestInfo.h	2008-12-06 04:39:54 UTC (rev 3004)
+++ development/source/cpu/cCPUTestInfo.h	2008-12-06 05:23:39 UTC (rev 3005)
@@ -65,6 +65,8 @@
 	tArray<int> manual_inputs;  //   if so, use these.
   cHardwareTracer* m_tracer;
   cInstSet* m_inst_set;
+  
+  int m_cur_sg;
 
   // Outputs...
   bool is_viable;         // Is this organism colony forming?
@@ -100,6 +102,8 @@
   void SetInstSet(cInstSet* inst_set = NULL) { m_inst_set = inst_set; }
   void SetResourceOptions(int res_method = RES_INITIAL, cResourceHistory* 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; }
+  
+  void SetCurrentStateGridID(int sg) { m_cur_sg = sg; }
 
 
   // Input Accessors
@@ -129,7 +133,7 @@
   double GetGenotypeFitness();
   double GetColonyFitness();
   
-  int GetStateGridID() const { return 0; } // @TODO - state grid - support setting cCPUTestInfo's state grid id
+  int GetStateGridID() const { return m_cur_sg; }
 };
 
 




More information about the Avida-cvs mailing list