[Avida-SVN] r2232 - / extras/source/testsuites

kaben at myxo.css.msu.edu kaben at myxo.css.msu.edu
Wed Dec 19 12:29:20 PST 2007


Author: kaben
Date: 2007-12-19 15:29:20 -0500 (Wed, 19 Dec 2007)
New Revision: 2232

Modified:
   /
   extras/source/testsuites/nAnalyze.cpp
   extras/source/testsuites/nTestSettings.cpp
   extras/source/testsuites/nTreeStats.cpp
Log:
 r2270 at vallista:  kaben | 2007-12-15 00:13:36 -0800
 Testing of Gabe's gamma statistic.
 



Property changes on: 
___________________________________________________________________
Name: svk:merge
   - 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/xcode-test:1653
c457ea80-0a68-11dc-9323-a45eea2efad5:/private:2269
   + 079b078a-dbed-46b9-b3da-37668d4295ca:/avida/xcode-test:1653
c457ea80-0a68-11dc-9323-a45eea2efad5:/private:2270

Modified: extras/source/testsuites/nAnalyze.cpp
===================================================================
--- extras/source/testsuites/nAnalyze.cpp	2007-12-19 20:29:15 UTC (rev 2231)
+++ extras/source/testsuites/nAnalyze.cpp	2007-12-19 20:29:20 UTC (rev 2232)
@@ -48,20 +48,15 @@
 #include "cTestLib.h"
 #if ENABLE_SERIALIZATION
 #  include "cXMLArchive.h"
-#endif // ENABLE_SERIALIZATION
+#endif
 #include "cWorld.h"
 #include "tDictionary.h"
-
 #if USE_tMemTrack
-# ifndef tMemTrack_h
 #  include "tMemTrack.h"
-# endif
 #endif
 
-
 #include <iostream>
 #include <fstream>
-
 #include <assert.h>
 
 using namespace std;
@@ -696,8 +691,8 @@
   };
   /* class cAGLData }}}3 */
 
-  /* class cAnalyzeGenotypeTreeStats {{{3 */
-  class cAnalyzeGenotypeTreeStats {
+  /* class cAnalyzeTreeStats_CumulativeStemminess {{{3 */
+  class cAnalyzeTreeStats_CumulativeStemminess {
   public:
     tArray<cAGLData> m_agl;
     tArray<cAGLData> m_agl2;
@@ -708,7 +703,7 @@
     bool m_should_exclude_leaves;
 
   public:
-    cAnalyzeGenotypeTreeStats()
+    cAnalyzeTreeStats_CumulativeStemminess()
     : m_agl(0)
     , m_agl2(0)
     , m_stemminess_sum(0.0)
@@ -1008,7 +1003,7 @@
     }
 
   };
-  /* class cAnalyzeGenotypeTreeStats }}}3 */
+  /* class cAnalyzeTreeStats_CumulativeStemminess }}}3 */
 
   void testsuite(){
     cout << "XXX This is an incomplete test. @kgn" << endl;
@@ -1017,118 +1012,122 @@
     We know what its stemminess should be.
     */
     cString detail_fake_filename("./detail-fake.pop");
-    std::ofstream detail_file(detail_fake_filename);
-    detail_file << "#filetype genotype_data" << endl;
-    detail_file << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl;
-    detail_file << "" << endl;
-    detail_file << "#  1: ID" << endl;
-    detail_file << "#  2: parent ID" << endl;
-    detail_file << "#  3: depth in phylogentic tree" << endl;
-    detail_file << "" << endl;
-    detail_file << "36 35 22 #" << endl;
-    detail_file << "44 43 23 #" << endl;
-    detail_file << "56 55 21 #" << endl;
-    detail_file << "63 62 20 #" << endl;
-    detail_file << "71 70 21 #" << endl;
-    detail_file << "# This file was autogenerated to test Avida." << endl;
-    detail_file << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
-    detail_file.close();
+    {
+      std::ofstream detail_file(detail_fake_filename);
+      detail_file << "#filetype genotype_data" << endl;
+      detail_file << "#format id parent_id depth" << endl;
+      detail_file << "" << endl;
+      detail_file << "#  1: ID" << endl;
+      detail_file << "#  2: parent ID" << endl;
+      detail_file << "#  3: depth in phylogentic tree" << endl;
+      detail_file << "" << endl;
+      detail_file << "36 35 22 #" << endl;
+      detail_file << "44 43 23 #" << endl;
+      detail_file << "56 55 21 #" << endl;
+      detail_file << "63 62 20 #" << endl;
+      detail_file << "71 70 21 #" << endl;
+      detail_file << "# This file was autogenerated to test Avida." << endl;
+      detail_file << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
+      detail_file.close();
+    }
 
     cString historic_fake_filename("./historic-fake.pop");
-    std::ofstream historic_file(historic_fake_filename);
-    historic_file << "#filetype genotype_data" << endl;
-    historic_file << "#format id parent_id parent_dist num_cpus total_cpus length merit gest_time fitness update_born update_dead depth sequence" << endl;
-    historic_file << "" << endl;
-    historic_file << "#  1: ID" << endl;
-    historic_file << "#  2: parent ID" << endl;
-    historic_file << "#  3: depth in phylogentic tree" << endl;
-    historic_file << "" << endl;
-    historic_file << "# important nodes:" << endl;
-    historic_file << " 1 -1  0 #" << endl;
-    historic_file << "16 15 15 #" << endl;
-    historic_file << "25 24  9 #" << endl;
-    historic_file << "29 28 13 #" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 14 genotypes between 1 and 16:" << endl;
-    historic_file << "2 1 1" << endl;
-    historic_file << "3 2 2" << endl;
-    historic_file << "4 3 3" << endl;
-    historic_file << "5 4 4" << endl;
-    historic_file << "6 5 5" << endl;
-    historic_file << "7 6 6" << endl;
-    historic_file << "8 7 7" << endl;
-    historic_file << "9 8 8" << endl;
-    historic_file << "10 9 9" << endl;
-    historic_file << "11 10 10" << endl;
-    historic_file << "12 11 11" << endl;
-    historic_file << "13 12 12" << endl;
-    historic_file << "14 13 13" << endl;
-    historic_file << "15 14 14" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 8 genotypes between 1 and 25:" << endl;
-    historic_file << "17  1 1" << endl;
-    historic_file << "18 17 2" << endl;
-    historic_file << "19 18 3" << endl;
-    historic_file << "20 19 4" << endl;
-    historic_file << "21 20 5" << endl;
-    historic_file << "22 21 6" << endl;
-    historic_file << "23 22 7" << endl;
-    historic_file << "24 23 8" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 3 genotypes between 25 and 29" << endl;
-    historic_file << "26 25 10" << endl;
-    historic_file << "27 26 11" << endl;
-    historic_file << "28 27 12" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 6 genotypes between 16 and 36" << endl;
-    historic_file << "30 16 16" << endl;
-    historic_file << "31 30 17" << endl;
-    historic_file << "32 31 18" << endl;
-    historic_file << "33 32 19" << endl;
-    historic_file << "34 33 20" << endl;
-    historic_file << "35 34 21" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 7 genotypes between 16 and 44" << endl;
-    historic_file << "37 16 16" << endl;
-    historic_file << "38 37 17" << endl;
-    historic_file << "39 38 18" << endl;
-    historic_file << "40 39 19" << endl;
-    historic_file << "41 40 20" << endl;
-    historic_file << "42 41 21" << endl;
-    historic_file << "43 42 22" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 11 genotypes between 25 and 56" << endl;
-    historic_file << "45 25 10" << endl;
-    historic_file << "46 45 11" << endl;
-    historic_file << "47 46 12" << endl;
-    historic_file << "48 47 13" << endl;
-    historic_file << "49 48 14" << endl;
-    historic_file << "50 49 15" << endl;
-    historic_file << "51 50 16" << endl;
-    historic_file << "52 51 17" << endl;
-    historic_file << "53 52 18" << endl;
-    historic_file << "54 53 19" << endl;
-    historic_file << "55 54 20" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 6 genotypes between 29 and 63" << endl;
-    historic_file << "57 29 14" << endl;
-    historic_file << "58 57 15" << endl;
-    historic_file << "59 58 16" << endl;
-    historic_file << "60 59 17" << endl;
-    historic_file << "61 60 18" << endl;
-    historic_file << "62 61 19" << endl;
-    historic_file << "" << endl;
-    historic_file << "# the 7 genotypes between 29 and 71" << endl;
-    historic_file << "64 29 14" << endl;
-    historic_file << "65 64 15" << endl;
-    historic_file << "66 65 16" << endl;
-    historic_file << "67 66 17" << endl;
-    historic_file << "68 67 18" << endl;
-    historic_file << "69 68 19" << endl;
-    historic_file << "70 69 20" << endl;
-    historic_file << "# This file was autogenerated to test Avida." << endl;
-    historic_file << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
-    historic_file.close();
+    {
+      std::ofstream historic_file(historic_fake_filename);
+      historic_file << "#filetype genotype_data" << endl;
+      historic_file << "#format id parent_id depth" << endl;
+      historic_file << "" << endl;
+      historic_file << "#  1: ID" << endl;
+      historic_file << "#  2: parent ID" << endl;
+      historic_file << "#  3: depth in phylogentic tree" << endl;
+      historic_file << "" << endl;
+      historic_file << "# important nodes:" << endl;
+      historic_file << " 1 -1  0 #" << endl;
+      historic_file << "16 15 15 #" << endl;
+      historic_file << "25 24  9 #" << endl;
+      historic_file << "29 28 13 #" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 14 genotypes between 1 and 16:" << endl;
+      historic_file << "2 1 1" << endl;
+      historic_file << "3 2 2" << endl;
+      historic_file << "4 3 3" << endl;
+      historic_file << "5 4 4" << endl;
+      historic_file << "6 5 5" << endl;
+      historic_file << "7 6 6" << endl;
+      historic_file << "8 7 7" << endl;
+      historic_file << "9 8 8" << endl;
+      historic_file << "10 9 9" << endl;
+      historic_file << "11 10 10" << endl;
+      historic_file << "12 11 11" << endl;
+      historic_file << "13 12 12" << endl;
+      historic_file << "14 13 13" << endl;
+      historic_file << "15 14 14" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 8 genotypes between 1 and 25:" << endl;
+      historic_file << "17  1 1" << endl;
+      historic_file << "18 17 2" << endl;
+      historic_file << "19 18 3" << endl;
+      historic_file << "20 19 4" << endl;
+      historic_file << "21 20 5" << endl;
+      historic_file << "22 21 6" << endl;
+      historic_file << "23 22 7" << endl;
+      historic_file << "24 23 8" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 3 genotypes between 25 and 29" << endl;
+      historic_file << "26 25 10" << endl;
+      historic_file << "27 26 11" << endl;
+      historic_file << "28 27 12" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 6 genotypes between 16 and 36" << endl;
+      historic_file << "30 16 16" << endl;
+      historic_file << "31 30 17" << endl;
+      historic_file << "32 31 18" << endl;
+      historic_file << "33 32 19" << endl;
+      historic_file << "34 33 20" << endl;
+      historic_file << "35 34 21" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 7 genotypes between 16 and 44" << endl;
+      historic_file << "37 16 16" << endl;
+      historic_file << "38 37 17" << endl;
+      historic_file << "39 38 18" << endl;
+      historic_file << "40 39 19" << endl;
+      historic_file << "41 40 20" << endl;
+      historic_file << "42 41 21" << endl;
+      historic_file << "43 42 22" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 11 genotypes between 25 and 56" << endl;
+      historic_file << "45 25 10" << endl;
+      historic_file << "46 45 11" << endl;
+      historic_file << "47 46 12" << endl;
+      historic_file << "48 47 13" << endl;
+      historic_file << "49 48 14" << endl;
+      historic_file << "50 49 15" << endl;
+      historic_file << "51 50 16" << endl;
+      historic_file << "52 51 17" << endl;
+      historic_file << "53 52 18" << endl;
+      historic_file << "54 53 19" << endl;
+      historic_file << "55 54 20" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 6 genotypes between 29 and 63" << endl;
+      historic_file << "57 29 14" << endl;
+      historic_file << "58 57 15" << endl;
+      historic_file << "59 58 16" << endl;
+      historic_file << "60 59 17" << endl;
+      historic_file << "61 60 18" << endl;
+      historic_file << "62 61 19" << endl;
+      historic_file << "" << endl;
+      historic_file << "# the 7 genotypes between 29 and 71" << endl;
+      historic_file << "64 29 14" << endl;
+      historic_file << "65 64 15" << endl;
+      historic_file << "66 65 16" << endl;
+      historic_file << "67 66 17" << endl;
+      historic_file << "68 67 18" << endl;
+      historic_file << "69 68 19" << endl;
+      historic_file << "70 69 20" << endl;
+      historic_file << "# This file was autogenerated to test Avida." << endl;
+      historic_file << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
+      historic_file.close();
+    }
 
     /*
     Initialize Avida {{{3
@@ -1136,9 +1135,11 @@
 
     /* Prep to run in analyze mode with args "-s 100" {{{3 */
     cStringList arg_list;
-    arg_list.PushRear("cAnalyze_Brainstorm_CumulativeStemminess_fake_1");
-    arg_list.PushRear("-s");
-    arg_list.PushRear("100");
+    {
+      arg_list.PushRear("cAnalyze_Brainstorm_CumulativeStemminess_fake_1");
+      arg_list.PushRear("-s");
+      arg_list.PushRear("100");
+    }
 
     /* Standard init, then get analyze object. {{{3 */
     cDriverManager::Initialize();
@@ -1165,7 +1166,7 @@
     {
       const int num_gens = a.batch[a.cur_batch].List().GetSize();
 
-      cAnalyzeGenotypeTreeStats agts;
+      cAnalyzeTreeStats_CumulativeStemminess agts;
       agts.AnalyzeBatchTree(a.batch[a.cur_batch].List());
 
       tListIterator<cAnalyzeGenotype> batch_it(a.batch[a.cur_batch].List());
@@ -1176,84 +1177,107 @@
       Fields: array-pos, id, pid, depth, birth, ppos, offspring_count,
       anc_branch_dist, anc_branch_pos.
       */
-      cString sanitycheck_filename("./agl_sanitycheck.dat");
+      cString sanitycheck_filename("./agl_sanitycheck_Brainstorm_CumulativeStemminess_fake_3.dat");
       {
+        if(false) {
+          /*
+           Writes the expected data to a sanitycheck file.
+           
+           We then copy the file into this code, and when this test is run, the
+           file is regenerated, and we can check for unexpected changes to actual
+           data.
+           */
+          std::ofstream scf(sanitycheck_filename);
+          for (int pos = 0; pos < num_gens; pos++) {
+            scf << pos;
+            scf << " " << agts.AGL()[pos].id;
+            scf << " " << agts.AGL()[pos].pid;
+            scf << " " << agts.AGL()[pos].depth;
+            scf << " " << agts.AGL()[pos].birth;
+            scf << " " << agts.AGL()[pos].ppos;
+            scf << " " << agts.AGL()[pos].offspring_count;
+            scf << " " << agts.AGL()[pos].anc_branch_dist;
+            scf << " " << agts.AGL()[pos].anc_branch_pos;
+            scf << endl;
+          }
+          scf.close();
+        }
         if(true) {
           {
             std::ofstream scf(sanitycheck_filename);
-            scf << "0 36 35 0 0 39 0 7 6" << endl;
-            scf << "1 44 43 0 0 46 0 8 6" << endl;
-            scf << "2 56 55 0 0 57 0 12 7" << endl;
-            scf << "3 63 62 0 0 63 0 7 8" << endl;
-            scf << "4 71 70 0 0 70 0 8 8" << endl;
+            scf << "0 36 35 22 0 39 0 7 6" << endl;
+            scf << "1 44 43 23 0 46 0 8 6" << endl;
+            scf << "2 56 55 21 0 57 0 12 7" << endl;
+            scf << "3 63 62 20 0 63 0 7 8" << endl;
+            scf << "4 71 70 21 0 70 0 8 8" << endl;
             scf << "5 1 -1 0 0 -1 2 0 -1" << endl;
-            scf << "6 16 15 0 0 22 2 15 5" << endl;
-            scf << "7 25 24 0 0 30 2 9 5" << endl;
-            scf << "8 29 28 0 0 33 2 4 7" << endl;
-            scf << "9 2 1 0 0 5 1 1 5" << endl;
-            scf << "10 3 2 0 0 9 1 2 5" << endl;
-            scf << "11 4 3 0 0 10 1 3 5" << endl;
-            scf << "12 5 4 0 0 11 1 4 5" << endl;
-            scf << "13 6 5 0 0 12 1 5 5" << endl;
-            scf << "14 7 6 0 0 13 1 6 5" << endl;
-            scf << "15 8 7 0 0 14 1 7 5" << endl;
-            scf << "16 9 8 0 0 15 1 8 5" << endl;
-            scf << "17 10 9 0 0 16 1 9 5" << endl;
-            scf << "18 11 10 0 0 17 1 10 5" << endl;
-            scf << "19 12 11 0 0 18 1 11 5" << endl;
-            scf << "20 13 12 0 0 19 1 12 5" << endl;
-            scf << "21 14 13 0 0 20 1 13 5" << endl;
-            scf << "22 15 14 0 0 21 1 14 5" << endl;
-            scf << "23 17 1 0 0 5 1 1 5" << endl;
-            scf << "24 18 17 0 0 23 1 2 5" << endl;
-            scf << "25 19 18 0 0 24 1 3 5" << endl;
-            scf << "26 20 19 0 0 25 1 4 5" << endl;
-            scf << "27 21 20 0 0 26 1 5 5" << endl;
-            scf << "28 22 21 0 0 27 1 6 5" << endl;
-            scf << "29 23 22 0 0 28 1 7 5" << endl;
-            scf << "30 24 23 0 0 29 1 8 5" << endl;
-            scf << "31 26 25 0 0 7 1 1 7" << endl;
-            scf << "32 27 26 0 0 31 1 2 7" << endl;
-            scf << "33 28 27 0 0 32 1 3 7" << endl;
-            scf << "34 30 16 0 0 6 1 1 6" << endl;
-            scf << "35 31 30 0 0 34 1 2 6" << endl;
-            scf << "36 32 31 0 0 35 1 3 6" << endl;
-            scf << "37 33 32 0 0 36 1 4 6" << endl;
-            scf << "38 34 33 0 0 37 1 5 6" << endl;
-            scf << "39 35 34 0 0 38 1 6 6" << endl;
-            scf << "40 37 16 0 0 6 1 1 6" << endl;
-            scf << "41 38 37 0 0 40 1 2 6" << endl;
-            scf << "42 39 38 0 0 41 1 3 6" << endl;
-            scf << "43 40 39 0 0 42 1 4 6" << endl;
-            scf << "44 41 40 0 0 43 1 5 6" << endl;
-            scf << "45 42 41 0 0 44 1 6 6" << endl;
-            scf << "46 43 42 0 0 45 1 7 6" << endl;
-            scf << "47 45 25 0 0 7 1 1 7" << endl;
-            scf << "48 46 45 0 0 47 1 2 7" << endl;
-            scf << "49 47 46 0 0 48 1 3 7" << endl;
-            scf << "50 48 47 0 0 49 1 4 7" << endl;
-            scf << "51 49 48 0 0 50 1 5 7" << endl;
-            scf << "52 50 49 0 0 51 1 6 7" << endl;
-            scf << "53 51 50 0 0 52 1 7 7" << endl;
-            scf << "54 52 51 0 0 53 1 8 7" << endl;
-            scf << "55 53 52 0 0 54 1 9 7" << endl;
-            scf << "56 54 53 0 0 55 1 10 7" << endl;
-            scf << "57 55 54 0 0 56 1 11 7" << endl;
-            scf << "58 57 29 0 0 8 1 1 8" << endl;
-            scf << "59 58 57 0 0 58 1 2 8" << endl;
-            scf << "60 59 58 0 0 59 1 3 8" << endl;
-            scf << "61 60 59 0 0 60 1 4 8" << endl;
-            scf << "62 61 60 0 0 61 1 5 8" << endl;
-            scf << "63 62 61 0 0 62 1 6 8" << endl;
-            scf << "64 64 29 0 0 8 1 1 8" << endl;
-            scf << "65 65 64 0 0 64 1 2 8" << endl;
-            scf << "66 66 65 0 0 65 1 3 8" << endl;
-            scf << "67 67 66 0 0 66 1 4 8" << endl;
-            scf << "68 68 67 0 0 67 1 5 8" << endl;
-            scf << "69 69 68 0 0 68 1 6 8" << endl;
-            scf << "70 70 69 0 0 69 1 7 8" << endl;
+            scf << "6 16 15 15 0 22 2 15 5" << endl;
+            scf << "7 25 24 9 0 30 2 9 5" << endl;
+            scf << "8 29 28 13 0 33 2 4 7" << endl;
+            scf << "9 2 1 1 0 5 1 1 5" << endl;
+            scf << "10 3 2 2 0 9 1 2 5" << endl;
+            scf << "11 4 3 3 0 10 1 3 5" << endl;
+            scf << "12 5 4 4 0 11 1 4 5" << endl;
+            scf << "13 6 5 5 0 12 1 5 5" << endl;
+            scf << "14 7 6 6 0 13 1 6 5" << endl;
+            scf << "15 8 7 7 0 14 1 7 5" << endl;
+            scf << "16 9 8 8 0 15 1 8 5" << endl;
+            scf << "17 10 9 9 0 16 1 9 5" << endl;
+            scf << "18 11 10 10 0 17 1 10 5" << endl;
+            scf << "19 12 11 11 0 18 1 11 5" << endl;
+            scf << "20 13 12 12 0 19 1 12 5" << endl;
+            scf << "21 14 13 13 0 20 1 13 5" << endl;
+            scf << "22 15 14 14 0 21 1 14 5" << endl;
+            scf << "23 17 1 1 0 5 1 1 5" << endl;
+            scf << "24 18 17 2 0 23 1 2 5" << endl;
+            scf << "25 19 18 3 0 24 1 3 5" << endl;
+            scf << "26 20 19 4 0 25 1 4 5" << endl;
+            scf << "27 21 20 5 0 26 1 5 5" << endl;
+            scf << "28 22 21 6 0 27 1 6 5" << endl;
+            scf << "29 23 22 7 0 28 1 7 5" << endl;
+            scf << "30 24 23 8 0 29 1 8 5" << endl;
+            scf << "31 26 25 10 0 7 1 1 7" << endl;
+            scf << "32 27 26 11 0 31 1 2 7" << endl;
+            scf << "33 28 27 12 0 32 1 3 7" << endl;
+            scf << "34 30 16 16 0 6 1 1 6" << endl;
+            scf << "35 31 30 17 0 34 1 2 6" << endl;
+            scf << "36 32 31 18 0 35 1 3 6" << endl;
+            scf << "37 33 32 19 0 36 1 4 6" << endl;
+            scf << "38 34 33 20 0 37 1 5 6" << endl;
+            scf << "39 35 34 21 0 38 1 6 6" << endl;
+            scf << "40 37 16 16 0 6 1 1 6" << endl;
+            scf << "41 38 37 17 0 40 1 2 6" << endl;
+            scf << "42 39 38 18 0 41 1 3 6" << endl;
+            scf << "43 40 39 19 0 42 1 4 6" << endl;
+            scf << "44 41 40 20 0 43 1 5 6" << endl;
+            scf << "45 42 41 21 0 44 1 6 6" << endl;
+            scf << "46 43 42 22 0 45 1 7 6" << endl;
+            scf << "47 45 25 10 0 7 1 1 7" << endl;
+            scf << "48 46 45 11 0 47 1 2 7" << endl;
+            scf << "49 47 46 12 0 48 1 3 7" << endl;
+            scf << "50 48 47 13 0 49 1 4 7" << endl;
+            scf << "51 49 48 14 0 50 1 5 7" << endl;
+            scf << "52 50 49 15 0 51 1 6 7" << endl;
+            scf << "53 51 50 16 0 52 1 7 7" << endl;
+            scf << "54 52 51 17 0 53 1 8 7" << endl;
+            scf << "55 53 52 18 0 54 1 9 7" << endl;
+            scf << "56 54 53 19 0 55 1 10 7" << endl;
+            scf << "57 55 54 20 0 56 1 11 7" << endl;
+            scf << "58 57 29 14 0 8 1 1 8" << endl;
+            scf << "59 58 57 15 0 58 1 2 8" << endl;
+            scf << "60 59 58 16 0 59 1 3 8" << endl;
+            scf << "61 60 59 17 0 60 1 4 8" << endl;
+            scf << "62 61 60 18 0 61 1 5 8" << endl;
+            scf << "63 62 61 19 0 62 1 6 8" << endl;
+            scf << "64 64 29 14 0 8 1 1 8" << endl;
+            scf << "65 65 64 15 0 64 1 2 8" << endl;
+            scf << "66 66 65 16 0 65 1 3 8" << endl;
+            scf << "67 67 66 17 0 66 1 4 8" << endl;
+            scf << "68 68 67 18 0 67 1 5 8" << endl;
+            scf << "69 69 68 19 0 68 1 6 8" << endl;
+            scf << "70 70 69 20 0 69 1 7 8" << endl;
             scf << "# This file was autogenerated to test Avida." << endl;
-            scf << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
+            scf << "# Test: Brainstorm_CumulativeStemminess_fake_3." << endl;
             scf.close();
           }
           {
@@ -1274,29 +1298,6 @@
           }
           std::remove(sanitycheck_filename);
         }
-        if(false) {
-          /*
-          Writes the expected data to a sanitycheck file.
-
-          We then copy the file into this code, and when this test is run, the
-          file is regenerated, and we can check for unexpected changes to actual
-          data.
-          */
-          std::ofstream scf(sanitycheck_filename);
-          for (int pos = 0; pos < num_gens; pos++) {
-            scf << pos;
-            scf << " " << agts.AGL()[pos].id;
-            scf << " " << agts.AGL()[pos].pid;
-            scf << " " << agts.AGL()[pos].depth;
-            scf << " " << agts.AGL()[pos].birth;
-            scf << " " << agts.AGL()[pos].ppos;
-            scf << " " << agts.AGL()[pos].offspring_count;
-            scf << " " << agts.AGL()[pos].anc_branch_dist;
-            scf << " " << agts.AGL()[pos].anc_branch_pos;
-            scf << endl;
-          }
-          scf.close();
-        }
       }
 
       /*
@@ -1316,7 +1317,7 @@
           bcf << "7 25 2 1 9" << endl;
           bcf << "8 29 2 25 4" << endl;
           bcf << "# This file was autogenerated to test Avida." << endl;
-          bcf << "# Test: Brainstorm_CumulativeStemminess_fake_1." << endl;
+          bcf << "# Test: Brainstorm_CumulativeStemminess_fake_3." << endl;
           bcf.close();
         }
         {

Modified: extras/source/testsuites/nTestSettings.cpp
===================================================================
--- extras/source/testsuites/nTestSettings.cpp	2007-12-19 20:29:15 UTC (rev 2231)
+++ extras/source/testsuites/nTestSettings.cpp	2007-12-19 20:29:20 UTC (rev 2232)
@@ -148,7 +148,7 @@
       TEST(ts.Setting("y") == "fubar");
       TEST(ts.Setting("x") == "");
       TEST(ts.Setting("") == "good-grief");
-      /* - This should parse, and should set "y" to "z_z". {{{5 */
+      /* - This should parse, and should set "y" to "z-z". {{{5 */
       TEST(ts.ParseSettingString("--set-y-z-z"));
       TEST(3 == ts.Size());
       TEST(ts.HasSetting("y"));

Modified: extras/source/testsuites/nTreeStats.cpp
===================================================================
--- extras/source/testsuites/nTreeStats.cpp	2007-12-19 20:29:15 UTC (rev 2231)
+++ extras/source/testsuites/nTreeStats.cpp	2007-12-19 20:29:20 UTC (rev 2232)
@@ -23,30 +23,29 @@
  */
 
 #include "cAnalyze.h"
-
+#include "cAnalyzeGenotype.h"
 #include "cAnalyzeTestFixture.h"
+#include "cAnalyzeTreeStats_Gamma.h"
 #include "cTestLib.h"
-
+#include "cWorld.h"
+#include "functions.h"
 #if USE_tMemTrack
-# ifndef tMemTrack_h
-#  include "tMemTrack.h"
-# endif
+#  include "cMemTracker.h"
 #endif
 
 #include <iostream>
 #include <fstream>
-
 #include <assert.h>
+#include <math.h>
 
 using namespace std;
 
 
 namespace nTreeStats {
-  void GenerateStandardCfgs(const cString &avida_cfg_filename, const cString &analyze_cfg_filename){
+  void GenerateStandardCfgs(const cString &avida_cfg_filename, const cString &analyze_cfg_filename) {
     std::ofstream avida_cfg_file(avida_cfg_filename);
 
     avida_cfg_file << "#############################################################################" << endl;
-    avida_cfg_file << "#############################################################################" << endl;
     avida_cfg_file << "# This file includes all the basic run-time defines for Avida." << endl;
     avida_cfg_file << "# For more information, see doc/config.html" << endl;
     avida_cfg_file << "#############################################################################" << endl;
@@ -414,50 +413,377 @@
 
 
     std::ofstream analyze_cfg_file(analyze_cfg_filename);
-
-    analyze_cfg_file << "#############################################################################" << endl;
-    analyze_cfg_file << "# This file is used to setup avida when it is in analysis-only mode (by" << endl;
-    analyze_cfg_file << "# running \"avida -a\".  It allows variety of methods to load organisms" << endl;
-    analyze_cfg_file << "# (specifying the type of each) and analyze them once loaded." << endl;
-    analyze_cfg_file << "#" << endl;
-    analyze_cfg_file << "# See the documentation in doc/analyze_mode.html for usage, or the file" << endl;
-    analyze_cfg_file << "# doc/analyze_samples.html for guidelines on writing programs." << endl;
-    analyze_cfg_file << "#" << endl;
-    analyze_cfg_file << "#############################################################################" << endl;
     analyze_cfg_file << "" << endl;
-
     analyze_cfg_file.close();
   }
+  /* Generate fake data files containing hand-crafted tree. */
+  void GenerateGammaDetail(const cString &detail_fake_filename) {
+    std::ofstream detail_file(detail_fake_filename);
+    detail_file << "#filetype genotype_data" << endl;
+    detail_file << "#format id parent_id depth" << endl;
+    detail_file << "" << endl;
+    detail_file << "#  1: ID" << endl;
+    detail_file << "#  2: parent ID" << endl;
+    detail_file << "#  3: depth in phylogentic tree" << endl;
+    detail_file << "" << endl;
+    detail_file << "100 -1 32 #" << endl;
+    detail_file << "150 -1 32 #" << endl;
+    detail_file << "600 500 155 #" << endl;
+    detail_file << "200 100 57 #" << endl;
+    detail_file << "500 300 143 #" << endl;
+    detail_file << "700 500 155 #" << endl;
+    detail_file << "300 100 71 #" << endl;
+    detail_file << "400 100 110 #" << endl;
+    detail_file << "450 200 110 #" << endl;
+    detail_file << "# This file was autogenerated to test Avida." << endl;
+    detail_file << "# Tests for GabeYedidGammaStatistic." << endl;
+    detail_file.close();
+  }  
 }
 
+/* Unit tests. */
+namespace cAnalyze_UnitTest_GabeYedidGammaStatistic {
+  void testsuite(){
+    cString avida_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_avida.cfg");
+    cString analyze_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_analyze.cfg");    
+    cString detail_fake_filename("./detail-fake.pop");
+    nTreeStats::GenerateStandardCfgs(avida_cfg_filename, analyze_cfg_filename);
+    nTreeStats::GenerateGammaDetail(detail_fake_filename);
+    
+    cAnalyzeTestFixture atf;
+    /* Set Avida command-line args. */
+    {
+      atf.AddArg("cAnalyze_Brainstorm_GabeYedidGammaStatistic");
+      atf.AddArg("-c");
+      atf.AddArg(avida_cfg_filename);
+      atf.AddArg("-set");
+      atf.AddArg("ANALYZE_FILE");
+      atf.AddArg(analyze_cfg_filename);
+    }
+    
+    /* Start Avida. */
+    if(true) {
+      cout << "------ Starting Avida run." << endl;
+      atf.Start();
+      atf.Send("SET_BATCH 0");
+      atf.Send("PURGE_BATCH");
+      atf.Send(cString("LOAD ") + detail_fake_filename);
+    }
+    
+    cAnalyzeTreeStats_Gamma agts(atf.m_world);
+    cAnalyze& a = atf.m_world->GetAnalyze();
+    
+    /* Record memory footprint so we can check for memory leaks. */
+#if USE_tMemTrack
+    cMemTracker mt;
+    REGISTER_INSTANCE_TRACKER(mt, cAnalyzeGenotype);
+#endif USE_tMemTrack
+    
+    /* Load genotypes into gen_array. */
+    agts.LoadGenotypes(a.batch[a.cur_batch].List());
+    /* TESTS: Verify initial order of loaded genotypes. */
+    if(true) {
+      TEST(agts.m_gen_array[0]->GetID() == 100);
+      TEST(agts.m_gen_array[0]->GetParentID() == -1);
+      TEST(agts.m_gen_array[0]->GetDepth() == 32);
+      
+      TEST(agts.m_gen_array[1]->GetID() == 150);
+      TEST(agts.m_gen_array[1]->GetParentID() == -1);
+      TEST(agts.m_gen_array[1]->GetDepth() == 32);
+      
+      TEST(agts.m_gen_array[2]->GetID() == 600);
+      TEST(agts.m_gen_array[2]->GetParentID() == 500);
+      TEST(agts.m_gen_array[2]->GetDepth() == 155);
+      
+      TEST(agts.m_gen_array[3]->GetID() == 200);
+      TEST(agts.m_gen_array[3]->GetParentID() == 100);
+      TEST(agts.m_gen_array[3]->GetDepth() == 57);
+      
+      TEST(agts.m_gen_array[4]->GetID() == 500);
+      TEST(agts.m_gen_array[4]->GetParentID() == 300);
+      TEST(agts.m_gen_array[4]->GetDepth() == 143);
+      
+      TEST(agts.m_gen_array[5]->GetID() == 700);
+      TEST(agts.m_gen_array[5]->GetParentID() == 500);
+      TEST(agts.m_gen_array[5]->GetDepth() == 155);
+      
+      TEST(agts.m_gen_array[6]->GetID() == 300);
+      TEST(agts.m_gen_array[6]->GetParentID() == 100);
+      TEST(agts.m_gen_array[6]->GetDepth() == 71);
+      
+      TEST(agts.m_gen_array[7]->GetID() == 400);
+      TEST(agts.m_gen_array[7]->GetParentID() == 100);
+      TEST(agts.m_gen_array[7]->GetDepth() == 110);
+      
+      TEST(agts.m_gen_array[8]->GetID() == 450);
+      TEST(agts.m_gen_array[8]->GetParentID() == 200);
+      TEST(agts.m_gen_array[8]->GetDepth() == 110);
+    }
+    
+    /* Sort gen_array by phylogenetic depth. */
+    {
+      int result = agts.HeapSortGenotypes();
+      if(true) {
+        TEST(result == 0);
+      }
+    }
+    /* TESTS: Verify final order of loaded genotypes. */
+    if(true) {
+      TEST(agts.m_gen_array[0]->GetDepth() == 32);
+      TEST(agts.m_gen_array[1]->GetDepth() == 32);
+      TEST(agts.m_gen_array[2]->GetDepth() == 57);
+      TEST(agts.m_gen_array[3]->GetDepth() == 71);
+      TEST(agts.m_gen_array[4]->GetDepth() == 110);
+      TEST(agts.m_gen_array[5]->GetDepth() == 110);
+      TEST(agts.m_gen_array[6]->GetDepth() == 143);
+      TEST(agts.m_gen_array[7]->GetDepth() == 155);
+      TEST(agts.m_gen_array[8]->GetDepth() == 155);
+    }
+    
+    /* Determine internode distances. */
+    agts.CalculateInternodeDistances();
+    /* TESTS: Verify simple internode distances, without fixup. */
+    if(true)  {
+      TEST(agts.m_g[0] == 0);
+      TEST(agts.m_g[1] == 32);
+      TEST(agts.m_g[2] == 0);
+      TEST(agts.m_g[3] == 25);
+      TEST(agts.m_g[4] == 14);
+      TEST(agts.m_g[5] == 39);
+      TEST(agts.m_g[6] == 0);
+      TEST(agts.m_g[7] == 33);
+      TEST(agts.m_g[8] == 12);
+      TEST(agts.m_g[9] == 0);
+    }
+    
+    /* Fixup internode distance rendundancies to weigh last instead of first. */
+    agts.FixupInternodeDistances();
+    /* TESTS: Verify simple internode distances. */
+    if(true) {
+      TEST(agts.m_g[0] == 0);
+      TEST(agts.m_g[1] == 0);
+      TEST(agts.m_g[2] == 32);
+      TEST(agts.m_g[3] == 25);
+      TEST(agts.m_g[4] == 14);
+      TEST(agts.m_g[5] == 0);
+      TEST(agts.m_g[6] == 39);
+      TEST(agts.m_g[7] == 33);
+      TEST(agts.m_g[8] == 0);
+      TEST(agts.m_g[9] == 12);
+    }
+    
+    /* Calculate Pybus-Harvey gamma statistic. */
+    {
+      agts.CalculateGamma();
+      double gamma = agts.Gamma();
+      if(true) {
+        TEST((-0.5899 - 0.0001) <= gamma);
+        TEST(gamma <= (-0.5899 + 0.0001));
+      }
+    }
+    
+    /* Check for memory leaks. */
+#if   USE_tMemTrack
+    if(true) {
+      TEST(mt.Verify());
+      //mt.Report();
+    }
+#endif
+    
+    /* Stop Avida. */
+    if(true) {
+      atf.Stop();
+      cout << "------ Finished Avida run." << endl;
+    }
+    
+    /* Remove generated files. */
+    {
+      std::remove(detail_fake_filename);
+      std::remove(avida_cfg_filename);
+      std::remove(analyze_cfg_filename);
+    }
+  }
+  cAddTestSuite t("cAnalyze_UnitTest_GabeYedidGammaStatistic", testsuite);
+}
 
-/* Brainstorms. */
-namespace cAnalyze_Brainstorm_GabeYedidGammaStatistic {
+/* Functional tests. */
+namespace cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo1 {
+  /* Generate fake data files containing hand-crafted tree. */
+  void GenerateGammaDetail_Demo1(const cString &detail_fake_filename) {
+    std::ofstream detail_file(detail_fake_filename);
+    detail_file << "#filetype genotype_data" << endl;
+    detail_file << "#format id parent_id depth" << endl;
+    detail_file << "" << endl;
+    detail_file << "#  1: ID" << endl;
+    detail_file << "#  2: parent ID" << endl;
+    detail_file << "#  3: depth in phylogentic tree" << endl;
+    detail_file << "" << endl;
+    detail_file << "100 -1 32 #" << endl;
+    detail_file << "600 500 155 #" << endl;
+    detail_file << "200 100 57 #" << endl;
+    detail_file << "500 300 143 #" << endl;
+    detail_file << "300 100 71 #" << endl;
+    detail_file << "400 100 110 #" << endl;
+    detail_file << "# This file was autogenerated to test Avida." << endl;
+    detail_file << "# Tests for cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo1." << endl;
+    detail_file.close();
+  }  
   void testsuite(){
     cString avida_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_avida.cfg");
     cString analyze_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_analyze.cfg");    
+    cString detail_fake_filename("./detail-fake.pop");
     nTreeStats::GenerateStandardCfgs(avida_cfg_filename, analyze_cfg_filename);
-
+    GenerateGammaDetail_Demo1(detail_fake_filename);
+    
     cAnalyzeTestFixture atf;
-    atf.AddArg("cAnalyze_Brainstorm_GabeYedidGammaStatistic");
-    atf.AddArg("-c");
-    atf.AddArg(avida_cfg_filename);
-    atf.AddArg("-set");
-    atf.AddArg("ANALYZE_FILE");
-    atf.AddArg(analyze_cfg_filename);
-
-    /* Run Avida. */
-    if(true){
+    /* Set Avida command-line args. */
+    {
+      atf.AddArg("cAnalyze_Brainstorm_GabeYedidGammaStatistic");
+      atf.AddArg("-c");
+      atf.AddArg(avida_cfg_filename);
+      atf.AddArg("-set");
+      atf.AddArg("ANALYZE_FILE");
+      atf.AddArg(analyze_cfg_filename);
+    }
+    
+    /* Start Avida. */
+    if(true) {
       cout << "------ Starting Avida run." << endl;
       atf.Start();
-      atf.Send("ECHO blah");
+      atf.Send("SET_BATCH 0");
+      atf.Send("PURGE_BATCH");
+      atf.Send(cString("LOAD ") + detail_fake_filename);
+    }
+    
+    cAnalyzeTreeStats_Gamma agts(atf.m_world);
+    cAnalyze& a = atf.m_world->GetAnalyze();
+    
+    /* Record memory footprint so we can check for memory leaks. */
+#if USE_tMemTrack
+    cMemTracker mt;
+    REGISTER_INSTANCE_TRACKER(mt, cAnalyzeGenotype);
+#endif USE_tMemTrack
+    
+    /* Calculate Pybus-Harvey gamma statistic. */
+    {
+      agts.AnalyzeBatch(a.batch[a.cur_batch].List());
+      double gamma = agts.Gamma();
+      if(true) {
+        TEST((-0.5964 - 0.0001) <= gamma);
+        TEST(gamma <= (-0.5964 + 0.0001));
+      }
+    }
+    
+    /* Check for memory leaks. */
+#if   USE_tMemTrack
+    if(true) {
+      TEST(mt.Verify());
+      //mt.Report();
+    }
+#endif
+    
+    /* Stop Avida. */
+    if(true) {
       atf.Stop();
       cout << "------ Finished Avida run." << endl;
     }
-
-    /* Remove generated config files. */
-    std::remove(avida_cfg_filename);
-    std::remove(analyze_cfg_filename);
+    
+    /* Remove generated files. */
+    {
+      std::remove(detail_fake_filename);
+      std::remove(avida_cfg_filename);
+      std::remove(analyze_cfg_filename);
+    }
   }
-  cAddTestSuite t("cAnalyze_Brainstorm_GabeYedidGammaStatistic", testsuite);
+  cAddTestSuite t("cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo1", testsuite);
 }
+namespace cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo2 {
+  /* Generate fake data files containing hand-crafted tree. */
+  void GenerateGammaDetail_Demo1(const cString &detail_fake_filename) {
+    std::ofstream detail_file(detail_fake_filename);
+    detail_file << "#filetype genotype_data" << endl;
+    detail_file << "#format id parent_id depth" << endl;
+    detail_file << "" << endl;
+    detail_file << "#  1: ID" << endl;
+    detail_file << "#  2: parent ID" << endl;
+    detail_file << "#  3: depth in phylogentic tree" << endl;
+    detail_file << "" << endl;
+    detail_file << "100 -1 32 #" << endl;
+    detail_file << "600 500 300 #" << endl;
+    detail_file << "200 100 471 #" << endl;
+    detail_file << "500 300 520 #" << endl;
+    detail_file << "300 100 585 #" << endl;
+    detail_file << "400 100 600 #" << endl;
+    detail_file << "# This file was autogenerated to test Avida." << endl;
+    detail_file << "# Tests for cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo2." << endl;
+    detail_file.close();
+  }  
+  void testsuite(){
+    cString avida_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_avida.cfg");
+    cString analyze_cfg_filename("./cAnalyze_Brainstorm_GabeYedidGammaStatistic_analyze.cfg");    
+    cString detail_fake_filename("./detail-fake.pop");
+    nTreeStats::GenerateStandardCfgs(avida_cfg_filename, analyze_cfg_filename);
+    GenerateGammaDetail_Demo1(detail_fake_filename);
+    
+    cAnalyzeTestFixture atf;
+    /* Set Avida command-line args. */
+    {
+      atf.AddArg("cAnalyze_Brainstorm_GabeYedidGammaStatistic");
+      atf.AddArg("-c");
+      atf.AddArg(avida_cfg_filename);
+      atf.AddArg("-set");
+      atf.AddArg("ANALYZE_FILE");
+      atf.AddArg(analyze_cfg_filename);
+    }
+    
+    /* Start Avida. */
+    if(true) {
+      cout << "------ Starting Avida run." << endl;
+      atf.Start();
+      atf.Send("SET_BATCH 0");
+      atf.Send("PURGE_BATCH");
+      atf.Send(cString("LOAD ") + detail_fake_filename);
+    }
+    
+    cAnalyzeTreeStats_Gamma agts(atf.m_world);
+    cAnalyze& a = atf.m_world->GetAnalyze();
+    
+    /* Record memory footprint so we can check for memory leaks. */
+#if USE_tMemTrack
+    cMemTracker mt;
+    REGISTER_INSTANCE_TRACKER(mt, cAnalyzeGenotype);
+#endif USE_tMemTrack
+    
+    /* Calculate Pybus-Harvey gamma statistic. */
+    {
+      agts.AnalyzeBatch(a.batch[a.cur_batch].List());
+      double gamma = agts.Gamma();
+      if(true) {
+        TEST((1.1269 - 0.0001) <= gamma);
+        TEST(gamma <= (1.1269 + 0.0001));
+      }
+    }
+    
+    /* Check for memory leaks. */
+#if   USE_tMemTrack
+    if(true) {
+      TEST(mt.Verify());
+      //mt.Report();
+    }
+#endif
+    
+    /* Stop Avida. */
+    if(true) {
+      atf.Stop();
+      cout << "------ Finished Avida run." << endl;
+    }
+    
+    /* Remove generated files. */
+    {
+      std::remove(detail_fake_filename);
+      std::remove(avida_cfg_filename);
+      std::remove(analyze_cfg_filename);
+    }
+  }
+  cAddTestSuite t("cAnalyze_FunctionalTest_GabeYedidGammaStatistic_Demo2", testsuite);
+}




More information about the Avida-cvs mailing list