[Avida-SVN] [avida-svn] r1035 - in development: documentation source/analyze

barrick at myxo.css.msu.edu barrick at myxo.css.msu.edu
Wed Oct 11 16:32:50 PDT 2006


Author: barrick
Date: 2006-10-11 19:32:49 -0400 (Wed, 11 Oct 2006)
New Revision: 1035

Modified:
   development/documentation/analyze.html
   development/source/analyze/cAnalyze.cc
   development/source/analyze/cAnalyzeGenotype.cc
   development/source/analyze/cAnalyzeGenotype.h
Log:
Analyse Mode changes. Added ability to specify resources to TRACE, and ability to get real random numbers as inputs for RECALCULATE and TRACE so that probabilistic behaviors can be investigated. Updated documentation.

Modified: development/documentation/analyze.html
===================================================================
--- development/documentation/analyze.html	2006-10-11 21:17:02 UTC (rev 1034)
+++ development/documentation/analyze.html	2006-10-11 23:32:49 UTC (rev 1035)
@@ -195,14 +195,19 @@
 </p>
 
 <dl>
-<dt><strong>RECALCULATE [<span class="cmdargopt">use_resources=0</span>]</strong></dt>
+<dt><strong>RECALCULATE [<span class="cmdargopt">use_resources=0</span>] [<span class="cmdargopt">update=-1</span>] [<span class="cmdargopt">use_random_inputs=0</span>]</strong></dt>
 <dd>
   Run all of the genotypes in the current batch through a test CPU
   and record the measurements taken (fitness, gestation time, etc.).
   This overrides any values that may have been loaded in with the
   genotypes.  The use_resources flags signifies whether or not the
-  test cpu will use resources when it runs.  For more information 
-  on resources, see the <a href="#USING_RESOURCES">summary</a> below.
+  test cpu will use resources when it runs.  If resources are used, the
+  update parameter allows setting resource values from a specific time point
+  in the resource list. For more information on resources, see the 
+  <a href="#USING_RESOURCES">summary</a> below.  If the use_random_inputs flag
+  is set, then organisms will be provided with new, random input strings for 
+  each trace as they would experience during an actual Avida run. By default, 
+  the same inputs are provided every time to organisms in analysis mode.
 </dd>
 <dt><strong>FIND_GENOTYPE [<span class="cmdargopt">type='num_cpus' ...</span>]</strong></dt>
 <dd>
@@ -294,15 +299,19 @@
   the files will be named by the genotype name, with a <kbd>.gen</kbd> appended to 
   them. Specifying the filename is useful when printing a single genotype. 
 </dd>
-<dt><strong>TRACE [<span class="cmdargopt">dir='archive/'</span>] [ <span class="cmdargopt">use_resources=0</span>]</strong></dt>
+<dt><strong>TRACE [<span class="cmdargopt">dir='archive/'</span>] [ <span class="cmdargopt">use_resources=0</span>] [<span class="cmdargopt">update=-1</span>] [ <span class="cmdargopt">use_random_inputs=0</span>]</strong></dt>
 <dd>
   Trace all of the genotypes and print a listing of their execution.
   This will show step-by-step the status of all of the CPU components
   and the genome during the course of the execution.  The filename used
   for each trace will be the genotype's name with a <kbd>.trace</kbd> appended.
   The use resources flag signifies whether or not the test cpu will use
-  resources when it runs.  For more information on resources, see the 
-  <a href="#USING_RESOURCES">summary</a> below.
+  resources when it runs.  If resources are used, the update parameter allows 
+  setting resource values from a specific time point in the resource list. 
+  For more information on resources, see the <a href="#USING_RESOURCES">summary</a> below.
+  If the use_random_inputs flag is set, then organisms will be provided with new, 
+  random input strings for each trace as they would experience during an actual Avida run.  
+  By default, the same inputs are provided every time to organisms in analysis mode.
 </dd>
 <dt><strong>PRINT_TASKS [<span class="cmdargopt">file='tasks.dat'</span>]</strong></dt>
 <dd>
@@ -491,12 +500,11 @@
 <p>
 In analyze, a new data structure was included which contains a time ordered 
 list of resource concentrations.  This list can be used to set up resources 
-from different time points.  By using the FillResources function, you can 
-have the resource library updated with resource concentrations from a time 
-point closest to the user specified time point.  If the LOAD_RESOURCES 
-command is not called, the list defaults to a single entry which is the 
-the initial concentrations of the resources specified in the environment 
-configuration file.
+from different time points.  By using the update parameter in the RECALCULATE function, 
+you can use the resource concentrations from a specified time 
+point.  If the LOAD_RESOURCES command is not called, the list defaults to 
+a single entry which is the the initial concentrations of the resources 
+specified in the environment configuration file.
 </p>
 
 <dl>

Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc	2006-10-11 21:17:02 UTC (rev 1034)
+++ development/source/analyze/cAnalyze.cc	2006-10-11 23:32:49 UTC (rev 1035)
@@ -1644,17 +1644,33 @@
   cString directory = PopDirectory(dir, defaultDirectory);
   
   int useResources = 0;
+  int useRandomInputs = 0;
+  int update = -1;
   if(words >= 2) {
     useResources = cur_string.PopWord().AsInt();
-    // All non-zero values are considered false
+    // All invalid values are considered false
     if(useResources != 0 && useResources != 1) {
       useResources = 0;
     }
   }
+  if (words >= 3) {
+    update = cur_string.PopWord().AsInt();
+  }
+  if (words >= 4) {
+    useRandomInputs = cur_string.PopWord().AsInt();
+    // All invalid values are considered false
+    if(useRandomInputs != 0 && useRandomInputs != 1) {
+      useRandomInputs = 0;
+    }
+  }
   
   cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();  
   testcpu->SetUseResources(useResources);
   
+  if (useResources && update > -1) {
+    FillResources(testcpu, update);
+  }
+  
   tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
   cAnalyzeGenotype * genotype = NULL;
   while ((genotype = batch_it.Next()) != NULL) {
@@ -1673,6 +1689,7 @@
     // Build the test info for printing.
     cCPUTestInfo test_info;
     test_info.SetTraceExecution(&trace_printer);
+    test_info.UseRandomInputs(useRandomInputs==1); 
     
     testcpu->TestGenome(m_ctx, test_info, genotype->GetGenome());
     
@@ -6901,6 +6918,7 @@
 {
   int words = cur_string.CountNumWords();
   int useResources = 0;
+  int useRandomInputs = 0;
   int update = -1;
   if(words >= 1) {
     useResources = cur_string.PopWord().AsInt();
@@ -6912,10 +6930,21 @@
   if (words >= 2) {
     update = cur_string.PopWord().AsInt();
   }
+  if (words >= 3) {
+    useRandomInputs = cur_string.PopWord().AsInt();
+    // All invalid values are considered false
+    if(useRandomInputs != 0 && useRandomInputs != 1) {
+      useRandomInputs = 0;
+    }
+  }
+
   
   cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
   testcpu->SetUseResources(useResources);
   
+  cCPUTestInfo *test_info = new cCPUTestInfo();
+  test_info->UseRandomInputs(useRandomInputs==1); 
+  
   if (m_world->GetVerbosity() >= VERBOSE_ON) {
     cout << "Running batch " << cur_batch << " through test CPUs..." << endl;
   } else cout << "Running through test CPUs..." << endl;
@@ -6943,13 +6972,14 @@
     // If the previous genotype was the parent of this one, pass in a pointer
     // to it for improved recalculate (such as distance to parent, etc.)
     if (last_genotype != NULL && genotype->GetParentID() == last_genotype->GetID()) {
-      genotype->Recalculate(m_ctx, testcpu, last_genotype);
+      genotype->Recalculate(m_ctx, testcpu, last_genotype, test_info);
     } else {
-      genotype->Recalculate(m_ctx, testcpu);
+      genotype->Recalculate(m_ctx, testcpu, NULL, test_info);
     }
     last_genotype = genotype;
   }
   
+  delete test_info;
   delete testcpu;
   
   return;

Modified: development/source/analyze/cAnalyzeGenotype.cc
===================================================================
--- development/source/analyze/cAnalyzeGenotype.cc	2006-10-11 21:17:02 UTC (rev 1034)
+++ development/source/analyze/cAnalyzeGenotype.cc	2006-10-11 23:32:49 UTC (rev 1035)
@@ -338,10 +338,19 @@
   m_land->Process(ctx);
 }
 
-void cAnalyzeGenotype::Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype)
+void cAnalyzeGenotype::Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype, cCPUTestInfo* test_info)
 {
     // Build the test info for printing.
-  cCPUTestInfo test_info;
+  
+  //Allocate our own test info if it wasn't provided
+  cCPUTestInfo* temp_test_info = NULL;
+  if (!test_info)
+  {
+      temp_test_info = new cCPUTestInfo();
+      test_info = temp_test_info;
+  }
+  
+  //cCPUTestInfo test_info;
   // test_info.TraceTaskOrder();
 
   // @DMB - This does some 'interesting' things with the instruction set
@@ -352,14 +361,14 @@
   cInstSet env_inst_set_backup = m_world->GetHardwareManager().GetInstSet();
   m_world->GetHardwareManager().GetInstSet() = inst_set;
 
-  testcpu->TestGenome(ctx, test_info, genome);
+  testcpu->TestGenome(ctx, *test_info, genome);
   
   // Restore the instruction set
   m_world->GetHardwareManager().GetInstSet() = env_inst_set_backup;
 
-  viable = test_info.IsViable();
+  viable = test_info->IsViable();
 
-  cOrganism* test_organism = test_info.GetTestOrganism();
+  cOrganism* test_organism = test_info->GetTestOrganism();
   cPhenotype& test_phenotype = test_organism->GetPhenotype();
 
   length = test_organism->GetGenome().GetSize();
@@ -382,6 +391,9 @@
 		    parent_genotype->GetGenome().AsString(), parent_muts);
     ancestor_dist = parent_genotype->GetAncestorDist() + parent_dist;
   }
+  
+  //Deallocate if we created
+  if (temp_test_info) delete temp_test_info;
 }
 
 

Modified: development/source/analyze/cAnalyzeGenotype.h
===================================================================
--- development/source/analyze/cAnalyzeGenotype.h	2006-10-11 21:17:02 UTC (rev 1034)
+++ development/source/analyze/cAnalyzeGenotype.h	2006-10-11 23:32:49 UTC (rev 1035)
@@ -154,7 +154,7 @@
   const cStringList & GetSpecialArgs() { return special_args; }
   void SetSpecialArgs(const cStringList & _args) { special_args = _args; }
 
-  void Recalculate(cAvidaContext& ctx, cTestCPU* testcpu, cAnalyzeGenotype* parent_genotype = NULL);
+  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 CalcLandscape(cAvidaContext& ctx);
 




More information about the Avida-cvs mailing list