[Avida-SVN] r1427 - in development: source/main tests/default_classic_100u/expected/data tests/default_transsmt_100u/expected/data

brysonda at myxo.css.msu.edu brysonda at myxo.css.msu.edu
Sat Mar 24 19:33:55 PDT 2007


Author: brysonda
Date: 2007-03-24 22:33:55 -0400 (Sat, 24 Mar 2007)
New Revision: 1427

Modified:
   development/source/main/cPopulation.cc
   development/source/main/cStats.cc
   development/tests/default_classic_100u/expected/data/stats.dat
   development/tests/default_transsmt_100u/expected/data/stats.dat
Log:
Fix a couple of bugs that were causing inconsistent output in stats.dat.  Specifically, optimization level dependent behavior was causing -0.0 to propagate from genotypic entropy calculations to the output stage.  Additionally, num_resamplings and num_failedResamplings were not being initialized.  Updated expected results.

Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc	2007-03-24 20:35:17 UTC (rev 1426)
+++ development/source/main/cPopulation.cc	2007-03-25 02:33:55 UTC (rev 1427)
@@ -1600,8 +1600,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 +1654,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;
     }
     

Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc	2007-03-24 20:35:17 UTC (rev 1426)
+++ development/source/main/cStats.cc	2007-03-25 02:33:55 UTC (rev 1427)
@@ -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: development/tests/default_classic_100u/expected/data/stats.dat
===================================================================
--- development/tests/default_classic_100u/expected/data/stats.dat	2007-03-24 20:35:17 UTC (rev 1426)
+++ development/tests/default_classic_100u/expected/data/stats.dat	2007-03-25 02:33:55 UTC (rev 1427)
@@ -13,9 +13,9 @@
 # 11: Total number of resamplings this generation
 # 12: Total number of organisms that failed to resample this generation
 
-0 0.000000 0.097500 0.562358 0.102587 0.826353 1 -0.000000 0.000000 0 1 0 
-10 0 0.0975 0.562358 0.102587 0.826353 0 -0 0 0 0 0 
-20 0 0.562358 0.562358 0.826353 0.826353 0 -0 0 0 0 0 
+0 0.000000 0.097500 0.562358 0.102587 0.826353 1 0.000000 0.000000 0 0 0 
+10 0 0.0975 0.562358 0.102587 0.826353 0 0 0 0 0 0 
+20 0 0.562358 0.562358 0.826353 0.826353 0 0 0 0 0 0 
 30 0 0.562358 0.562358 0.826353 0.826353 0 0.562335 0 0 0 0 
 40 -0.000644122 0.562358 0.562358 0.826353 0.826353 0 0.735622 0 0 0 0 
 50 -0.000644122 0.562358 0.562358 0.826353 0.826353 0 0.735622 0 0 0 0 

Modified: development/tests/default_transsmt_100u/expected/data/stats.dat
===================================================================
--- development/tests/default_transsmt_100u/expected/data/stats.dat	2007-03-24 20:35:17 UTC (rev 1426)
+++ development/tests/default_transsmt_100u/expected/data/stats.dat	2007-03-25 02:33:55 UTC (rev 1427)
@@ -13,10 +13,10 @@
 # 11: Total number of resamplings this generation
 # 12: Total number of organisms that failed to resample this generation
 
-0 0.000000 0.097500 0.564736 0.102587 0.831801 1 -0.000000 0.000000 0 6395120 27 
-10 0 0.0975 0.564736 0.102587 0.831801 0 -0 0 0 0 0 
-20 0 0.564736 0.564736 0.831801 0.831801 0 -0 0 0 0 0 
-30 0 0.564736 0.564736 0.831801 0.831801 0 -0 0 0 0 0 
+0 0.000000 0.097500 0.564736 0.102587 0.831801 1 0.000000 0.000000 0 0 0 
+10 0 0.0975 0.564736 0.102587 0.831801 0 0 0 0 0 0 
+20 0 0.564736 0.564736 0.831801 0.831801 0 0 0 0 0 0 
+30 0 0.564736 0.564736 0.831801 0.831801 0 0 0 0 0 0 
 40 0 0.563941 0.564736 0.829978 0.831801 0 1.03972 0 0 0 0 
 50 0 0.563941 0.564736 0.829978 0.831801 0 1.03972 0 0 0 0 
 60 -0.000858723 0.563941 0.564736 0.829978 0.831801 0 1.03972 0 0 0 0 




More information about the Avida-cvs mailing list