[Avida-SVN] r1231 - in extras: . source/testsuites source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config

avidaedward at myxo.css.msu.edu avidaedward at myxo.css.msu.edu
Sat Jan 27 22:18:00 PST 2007


Author: avidaedward
Date: 2007-01-28 01:18:00 -0500 (Sun, 28 Jan 2007)
New Revision: 1231

Added:
   extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/
   extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/default-classic.org
   extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/events.cfg
   extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/data/
Modified:
   extras/
   extras/source/testsuites/nAnalyze.cpp
Log:
 r1251 at clearly:  kaben | 2007-01-23 01:21:53 -0500
 Brainstorming work on my "EpochalVsContinuous" project.



Property changes on: extras
___________________________________________________________________
Name: svk:merge
   - 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/extras:1250
   + 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/local/extras:1251

Added: extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/default-classic.org
===================================================================
--- extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/default-classic.org	2007-01-28 06:17:53 UTC (rev 1230)
+++ extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/default-classic.org	2007-01-28 06:18:00 UTC (rev 1231)
@@ -0,0 +1,100 @@
+h-alloc    # Allocate space for child
+h-search   # Locate the end of the organism
+nop-C      #
+nop-A      #
+mov-head   # Place write-head at beginning of offspring.
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+nop-C      #
+h-search   # Mark the beginning of the copy loop
+h-copy     # Do the copy
+if-label   # If we're done copying....
+nop-C      #
+nop-A      #
+h-divide   #    ...divide!
+mov-head   # Otherwise, loop back to the beginning of the copy loop.
+nop-A      # End label.
+nop-B      #

Added: extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/events.cfg
===================================================================
--- extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/events.cfg	2007-01-28 06:17:53 UTC (rev 1230)
+++ extras/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config/events.cfg	2007-01-28 06:18:00 UTC (rev 1231)
@@ -0,0 +1,36 @@
+##############################################################################
+#
+# This is the setup file for the events system.  From here, you can
+# configure any actions that you want to have happen during the course of
+# an experiment, including setting the times for data collection.
+#
+# basic syntax: [trigger] [start:interval:stop] [action/event] [arguments...]
+#
+# This file is currently setup to record key information every 100 updates.
+#
+# For information on how to use this file, see:  doc/events.html
+# For other sample event configurations, see:  support/config/
+#
+##############################################################################
+
+# Print all of the standard data files...
+u 0:100:end PrintAverageData       # Save info about they average genotypes
+u 0:100:end PrintDominantData      # Save info about most abundant genotypes
+u 0:100:end PrintStatsData         # Collect satistics about entire pop.
+u 0:100:end PrintCountData         # Count organisms, genotypes, species, etc.
+u 0:100:end PrintTasksData         # Save organisms counts for each task.
+u 0:100:end PrintTimeData          # Track time conversion (generations, etc.)
+u 0:100:end PrintResourceData      # Track resource abundance.
+
+# A few data files not printed by default
+# u 0:100 PrintDominantGenotype      # Save the most abundant genotypes
+# u 100:100:end PrintErrorData       # Std. Error on averages.
+# u 100:100:end PrintVarianceData    # Variance on averages.
+# u 100:100:end PrintTotalsData      # Total counts over entire run.
+# u 100:100:end PrintTasksExeData    # Num. times tasks have been executed.
+# u 100:100:end PrintTasksQualData   # Task quality information
+
+# Setup the exit time and full population data collection.
+u 100:100 SavePopulation         # Save current state of population.
+u 100:100 SaveHistoricPopulation # Save ancestors of current population.
+u 500 exit                        # exit

Modified: extras/source/testsuites/nAnalyze.cpp
===================================================================
--- extras/source/testsuites/nAnalyze.cpp	2007-01-28 06:17:53 UTC (rev 1230)
+++ extras/source/testsuites/nAnalyze.cpp	2007-01-28 06:18:00 UTC (rev 1231)
@@ -8,6 +8,7 @@
 #include "cDefaultAnalyzeDriver.h"
 #include "cDefaultRunDriver.h"
 #include "cDrivermanager.h"
+#include "cStringUtil.h"
 #include "cTestLib.h"
 #include "cXMLArchive.h"
 #include "cWorld.h"
@@ -77,6 +78,22 @@
     cAddTestSuite t("cAnalyze_Brainstorm_HelloWorld", test);
   }
 
+  /* cAnalyze_Brainstorm_OneOffIstreamTest {{{2 */
+  namespace Brainstorm_OneOffIstreamTest {
+    void test(){
+      /* Make sure testing is working with successes and failures. @kgn */
+      TEST(true);
+      TEST(false);
+      cString blah;
+      for(int i=0; i<10; i++){
+        blah = "blah";
+        blah += cStringUtil::Convert(i);
+        cout << blah << endl;
+      }
+    }
+    cAddTestSuite t("cAnalyze_Brainstorm_OneOffIstreamTest", test);
+  }
+
   /* cAnalyze_Brainstorm_RunningAnalyze {{{2 */
   namespace Brainstorm_RunningAnalyze {
 
@@ -642,17 +659,16 @@
       }
       cout << "XXX This is an incomplete test. @kgn" << endl;
 
-      cout << "DevelBase: \"" << settings.Setting("DevelBase") << "\"" << endl;
-      cout << "ExtrasBase: \"" << settings.Setting("ExtrasBase") << "\"" << endl;
-
       ERROR("kgn at FIXME: I should verify the path to data files -");
       cString data_dir = settings.Setting("ExtrasBase") + "/source/testsuites/nAnalyze/Brainstorm/CumulativeStemminess/data";
 
       /*
       Initialize
       */
-      cString arg_string("cAnalyze_Brainstorm_CumulativeStemminess,-s,100");
-      cStringList arg_list(arg_string, ',');
+      cStringList arg_list;
+      arg_list.PushRear("cAnalyze_Brainstorm_CumulativeStemminess");
+      arg_list.PushRear("-s");
+      arg_list.PushRear("100");
 
       cDriverManager::Initialize();
       cWorld *world = new cWorld(cAvidaConfig::LoadWithArgs(arg_list));
@@ -870,266 +886,163 @@
 
   /* cAnalyze_Brainstorm_EpochalVsContinuous {{{2 */
   namespace Brainstorm_EpochalVsContinuous {
-    struct cAGLData {
-      cAnalyzeGenotype *genotype; //
-      int id; //
-      int pid; //
-      int depth; //
-      int birth; //
-      int ppos; // convenient but redundant.
-      int offspring_count; // convenient but redundant.
-      int branch_dist;
-      int branch_pos;
-
-      cAGLData()
-      : genotype(0)
-      , id(-1)
-      , pid(-1)
-      , depth(-1)
-      , birth(-1)
-      , ppos(-1)
-      , offspring_count(-1)
-      , branch_dist(-1)
-      , branch_pos(-1)
-      {}
-    };
     void test(cTestSettings &settings){
-      if(!settings.HasSetting("DevelBase") || (settings.Setting("DevelBase") == "")){
-        cout << "XXX Skipping test : DevelBase not set." << endl;
+      if(
+        (!settings.HasSetting("DevelBase"))
+        ||
+        (settings.Setting("DevelBase") == "")
+      ){
+        cout << "XXX Skipping : DevelBase not set." << endl;
         return;
       }
-      if(!settings.HasSetting("ExtrasBase") || (settings.Setting("ExtrasBase") == "")){
-        cout << "XXX Skipping test : ExtrasBase not set." << endl;
+      if(
+        (!settings.HasSetting("ExtrasBase"))
+        ||
+        (settings.Setting("ExtrasBase") == "")
+      ){
+        cout << "XXX Skipping : ExtrasBase not set." << endl;
         return;
       }
-      cout << "XXX This is a test stub. It needs filling-in. @kgn" << endl;
 
-      cout << "DevelBase: \"" << settings.Setting("DevelBase") << "\"" << endl;
-      cout << "ExtrasBase: \"" << settings.Setting("ExtrasBase") << "\"" << endl;
+      ERROR("kgn at FIXME: should verify paths to config files and data dir -");
+      ERROR("kgn at FIXME: brainstorm not complete -");
 
-      ERROR("kgn at FIXME: I should verify the path to config files -");
-      cString config_dir = settings.Setting("DevelBase") + "/support/config";
-
-      ERROR("kgn at FIXME: I should verify the path to data dir -");
-      cString data_dir = settings.Setting("ExtrasBase") + "/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/data";
-
-
       /*
       Initialize
       */
-      cString arg_string("cAnalyze_Brainstorm_EpochalVsContinuous,-s,100");
-      cStringList arg_list(arg_string, ',');
-
       cDriverManager::Initialize();
-      cWorld *world = new cWorld(cAvidaConfig::LoadWithArgs(arg_list));
+      cStringList args;
 
-      cAvidaDriver* driver = new cDefaultAnalyzeDriver(
-        world,
-        (world->GetConfig().ANALYZE_MODE.Get() == 2)
-      );
+      cString config_dir
+      = settings.Setting("DevelBase")
+      + "/support/config";
 
-      cAnalyze& a = world->GetAnalyze();
+      cString local_config_dir
+      = settings.Setting("ExtrasBase")
+      + "/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/config";
 
-      a.Send(cString("SET d ") + data_dir);
-      a.Send("SET_BATCH 0");
+      cString data_dir
+      = settings.Setting("ExtrasBase")
+      + "/source/testsuites/nAnalyze/Brainstorm/EpochalVsContinuous/data";
 
-      a.Send("PURGE_BATCH");
-      a.Send("LOAD $d/detail-5000.pop");
-      a.Send("LOAD $d/historic-5000.pop");
+      args.PushRear("cAnalyze_Brainstorm_EpochalVsContinuous");
 
-      //a.Send("PRINT_TREE_STATS");
-      
-      if(true){
-        cAnalyzeGenotype * genotype = NULL;
-        tListIterator<cAnalyzeGenotype> batch_it(a.batch[a.cur_batch].List());
-        const int num_gens = a.batch[a.cur_batch].List().GetSize();
-        cout << "num_gens:" << num_gens << endl;
+      args.PushRear("-c");
+      args.PushRear(config_dir + "/avida.cfg");
 
-        // Put all of the genotypes in an array for easy reference and collect
-        // other information on them as we process them.
-        tArray<cAnalyzeGenotype *> gen_array(num_gens);
-        tHashTable<int, int> id_hash;  // Store array pos for each id.
-        tArray<int> id_array(num_gens), pid_array(num_gens);
-        tArray<int> depth_array(num_gens), birth_array(num_gens);
-        int array_pos = 0;
-        while ((genotype = batch_it.Next()) != NULL) {
-          // Put the genotype in an array.
-          gen_array[array_pos] = genotype;
-          id_hash.Add(genotype->GetID(), array_pos);
-          id_array[array_pos] = genotype->GetID();
-          pid_array[array_pos] = genotype->GetParentID();
-          depth_array[array_pos] = genotype->GetDepth();
-          birth_array[array_pos] = genotype->GetUpdateBorn();
-          array_pos++;
-        }
+      args.PushRear("-s");
+      args.PushRear("100");
 
-/**/tArray<cAGLData> agl(num_gens);  // Store agl data for each id.
+      args.PushRear("-set");
+      args.PushRear("WORLD_X");
+      args.PushRear("20");
 
-/**/array_pos = 0;
-/**/batch_it.Reset();
-/**/while ((genotype = batch_it.Next()) != NULL) {
-/**/  // Put the genotype in an array.
-/**/  //id_hash.Add(genotype->GetID(), array_pos);
-/**/  agl[array_pos].genotype = genotype;
-/**/  agl[array_pos].id = genotype->GetID();
-/**/  agl[array_pos].pid = genotype->GetParentID();
-/**/  agl[array_pos].depth = genotype->GetDepth();
-/**/  agl[array_pos].birth = genotype->GetUpdateBorn();
-/**/  array_pos++;
-/**/}
+      args.PushRear("-set");
+      args.PushRear("WORLD_Y");
+      args.PushRear("20");
 
-/*
-XXX
-Test:
-Verify that each genotype has empty child list and null parent.
-*/
-/**/for (int pos = 0; pos < num_gens; pos++) {
-/* Sanity : non-null genotype. */
-/**/  TEST(agl[pos].genotype);
-/* Verify empty child list. */
-/**/  TEST(0 == agl[pos].genotype->GetChildList().GetSize());
-/* Sanity : non-null genotype. */
-/**/  TEST(0 == agl[pos].genotype->GetParent());
-/**/}
+      args.PushRear("-set");
+      args.PushRear("EVENT_FILE");
+      args.PushRear(local_config_dir + "/events.cfg");
 
-        // Now collect information about the offspring of each individual.
-        tArray<int> ppos_array(num_gens), offspring_count(num_gens);
-        offspring_count.SetAll(0);
-        for (int pos = 0; pos < num_gens; pos++) {
-          int parent_id = gen_array[pos]->GetParentID();
-          if (parent_id == -1) {  // Organism has no parent (i.e., ancestor)
-            ppos_array[pos] = -1;
-            continue;
-          }
-          int parent_pos = -1;
-          id_hash.Find(parent_id, parent_pos);
-          ppos_array[pos] = parent_pos;
-          offspring_count[parent_pos]++;
-        }
+      args.PushRear("-set");
+      args.PushRear("START_CREATURE");
+      args.PushRear(local_config_dir + "/default-classic.org");
 
-        // For each genotype, figure out how far back you need to go to get to a
-        // branch point.
-        tArray<int> branch_dist_array(num_gens);
-        tArray<int> branch_pos_array(num_gens);
-        branch_dist_array.SetAll(-1);
-        branch_pos_array.SetAll(-1);
-        bool found = true;
-        int loop_count = 0;
-        while (found == true) {
-          found = false;
-          for (int pos = 0; pos < num_gens; pos++) {
-            if (branch_dist_array[pos] > -1) continue; // continue if its set.
-            found = true;
-            int parent_pos = ppos_array[pos];
-            if (parent_pos == -1) branch_dist_array[pos] = 0;  // Org is root.
-            else if (offspring_count[parent_pos] > 1) {        // Parent is branch.
-              branch_dist_array[pos] = 1;
-              branch_pos_array[pos] = parent_pos;
-            }
-            else if (branch_dist_array[parent_pos] > -1) {     // Parent calculated.
-              branch_dist_array[pos] = branch_dist_array[parent_pos]+1;
-              branch_pos_array[pos] = branch_pos_array[parent_pos];
-            }
-            // Otherwise, we are not yet ready to calculate this entry.
+      args.PushRear("-set");
+      args.PushRear("DATA_DIR");
+      args.PushRear(data_dir);
+
+      /*
+      Run Avida in standard mode to generate data files.
+      */
+      if(false){
+        cout << "------ Starting standard Avida run." << endl;
+
+        cWorld *world = new cWorld(cAvidaConfig::LoadWithArgs(args));
+        ERROR("kgn at FIXME: write unit test verifying args list is not destroyed in cAvidaConfig::LoadWithArgs() -");
+        TEST(world);
+        if(world){
+          cAvidaDriver* driver = new cDefaultRunDriver(world);
+          TEST(driver);
+          if(driver){
+            driver->Run();
+            delete driver; driver=0;
           }
-          loop_count++;
+          cout << "------ Finished standard Avida run." << endl;
         }
+        // note: driver deletes world deletes config.
+      }
+      /*
+      Run Avida in analyze mode to analyze data files.
+      */
+      {
+        cout << "------ Starting Avida analysis." << endl;
 
-/*
-Link each offspring to its parent.
-*/
-/**/for (int pos = 0; pos < num_gens; pos++) {
-/**/  cAnalyzeGenotype * genotype = gen_array[pos];
-/**/  int parent_id = genotype->GetParentID();
-/**/  if (-1 != parent_id){
-/**/    id_hash.Find(parent_id, agl[pos].ppos);
-/**/    cAnalyzeGenotype * parent_genotype = gen_array[agl[pos].ppos];
-/**/    genotype->LinkParent(parent_genotype);
-/**/  }
-/**/}
+        cWorld *world = new cWorld(cAvidaConfig::LoadWithArgs(args));
+        ERROR("kgn at FIXME: write unit test verifying args list is not destroyed in cAvidaConfig::LoadWithArgs() -");
+        TEST(world);
+        if(world){
+          cAvidaDriver* driver = new cDefaultAnalyzeDriver(world, false);
+          TEST(driver);
+          if(driver){
+            cAnalyze& a = world->GetAnalyze();
+            cString s;
 
-/*
-Count offspring of each parent.
-*/
-/**/for (int pos = 0; pos < num_gens; pos++) {
-/**/  cAnalyzeGenotype * genotype = gen_array[pos];
-/**/  agl[pos].offspring_count = genotype->GetChildList().GetSize();
-/**/}
+            //a.Send(cString("SET d ") + data_dir);
+            //a.Send("SET_BATCH 0");
 
-/**/found = true;
-/**/loop_count = 0;
-/**/while (found == true) {
-/**/  found = false;
-/**/  for (int pos = 0; pos < num_gens; pos++) {
-/**/    if (agl[pos].branch_dist > -1) continue; // continue if its set.
-/**/    found = true;
-/**/    int parent_pos = agl[pos].ppos;
-/**/    if (parent_pos == -1)  agl[pos].branch_dist = 0;  // Org is root.
-/**/    else if (agl[parent_pos].offspring_count > 1) {        // Parent is branch.
-/**/      agl[pos].branch_dist = 1;
-/**/      agl[pos].branch_pos = parent_pos;
-/**/    }
-/**/    else if (agl[parent_pos].branch_dist > -1) {     // Parent calculated.
-/**/      agl[pos].branch_dist = agl[parent_pos].branch_dist + 1;
-/**/      agl[pos].branch_pos = agl[parent_pos].branch_pos;
-/**/    }
-/**/    // Otherwise, we are not yet ready to calculate this entry.
-/**/  }
-/**/  loop_count++;
-/**/}
+            //a.Send("PURGE_BATCH");
+            //a.Send("LOAD $d/detail-500.pop");
+            //a.Send("LOAD $d/historic-500.pop");
 
-        // Cumulative Stemminess
-        for (int pos = 0; pos < num_gens; pos++) {
-          // We're only interested in internal n-furcating nodes.
-          if (pid_array[pos] == -1) continue;  // Don't want root.
-          if (offspring_count[pos] <= 1) continue; // No leaves or nonfurcating nodes
 
-          // @CAO Find distance to all children.
-          // @CAO Find distance to parent branch.
-          // @CAO DO math.
-        }
+            //for(int i=0; i<10; i++){
+            //  blah = "blah";
+            //  blah += cStringUtil::Convert(i);
+            //  cout << blah << endl;
+            //}
 
 
-        //cout << "LOOP COUNT:" << loop_count << endl;
-        //for (int i = 0; i < num_gens; i++) {
-        //  int branch_pos = branch_pos_array[i];
-        //  int branch_id = (branch_pos == -1) ? -1 : id_array[branch_pos];
-        //  cout
-        //    << "i:" << i << ", "
-        //    << "id:" << id_array[i] << ", "
-        //    << "offspring_ct:" << offspring_count[i] << ", "
-        //    << "branch_dist:" << branch_dist_array[i] << ", "
-        //    << "branch_id:" << branch_id << ", "
-        //    << endl;
-        //}
+            //a.Send("VERBOSE");
+            //s = "SET d ";
+            //s += data_dir;
+            //a.Send(s);
 
-/*
-XXX
-Test:
-Verify agl data matches @cao's reference data.
-*/
-/* Sanity : non-empty genotype array. */
-/**/for (int pos = 0; pos < num_gens; pos++) {
-/**/  TEST(gen_array[pos]->GetChildList().GetSize() == offspring_count[pos]);
+            //for(int i=0; i<3; i++){
+            //  s = "SET i ";
+            //  s += cStringUtil::Convert(i);
+            //  a.Send(s);
+            //  a.Send("SET_BATCH $i");
+            //  a.Send("PURGE_BATCH");
+            //  a.Send("LOAD_SEQUENCE rmzavcgmciqqptqpqcpctletncogcbeamqdtqcptipqfpgqxutycuastttva");
+            //  a.Send("RECALCULATE");
+            //  a.Send("DETAIL $d/detail-analyze.dat fitness merit gest_time length viable sequence");
+            //  a.Send("TRACE");
+            //  a.Send("PRINT");
+            //}
 
-/**/  TEST(agl[pos].id == id_array[pos]);
-/**/  TEST(agl[pos].pid == pid_array[pos]);
-/**/  TEST(agl[pos].depth == depth_array[pos]);
-/**/  TEST(agl[pos].birth == birth_array[pos]);
-/**/  TEST(agl[pos].ppos == ppos_array[pos]);
-/**/  TEST(agl[pos].offspring_count == offspring_count[pos]);
-/**/  TEST(agl[pos].branch_dist == branch_dist_array[pos]);
-/**/  TEST(agl[pos].branch_pos == branch_pos_array[pos]);
-/**/}
 
+            a.Send("VERBOSE");
+            for(int i=1; i<=3; i++){
+              s = "SET i ";
+              s += cStringUtil::Convert(i);
+              a.Send(s);
+              a.Send("SET_BATCH $i");
+              a.Send("PURGE_BATCH");
+              a.Send("LOAD_SEQUENCE rmzavcgmciqqptqpqcpctletncogcbeamqdtqcptipqfpgqxutycuastttva");
+              a.Send("RECALCULATE");
+              a.Send("DETAIL detail_test_$i.dat fitness merit gest_time length viable sequence");
+              a.Send("TRACE");
+              a.Send("PRINT");
+            }
 
-        
+            delete driver; driver=0;
+          }
+          cout << "------ Finished Avida analysis." << endl;
+        }
+        // note: driver deletes world deletes config.
       }
-      TEST(driver); delete driver; driver=0;
-
-      /* Make sure testing is working with successes and failures. @kgn */
-      TEST(true);
-      //TEST(false);
     }
     cAddTestSuite t("cAnalyze_Brainstorm_EpochalVsContinuous", test);
   }




More information about the Avida-cvs mailing list