[Avida-SVN] r1526 - branches/uml/source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Thu May 3 18:18:35 PDT 2007
Author: dknoester
Date: 2007-05-03 21:18:34 -0400 (Thu, 03 May 2007)
New Revision: 1526
Modified:
branches/uml/source/main/cStats.cc
Log:
Reapplying demes test fix to this branch.
Modified: branches/uml/source/main/cStats.cc
===================================================================
--- branches/uml/source/main/cStats.cc 2007-05-03 22:35:40 UTC (rev 1525)
+++ branches/uml/source/main/cStats.cc 2007-05-04 01:18:34 UTC (rev 1526)
@@ -329,10 +329,15 @@
assert(sum_fitness.Average() >= 0.0);
assert(dom_fitness >= 0);
- if (sum_fitness.Average() == 0.0 || dom_fitness == 0.0) {
+ // Note: When average fitness and dominant fitness are close in value (i.e. sh ould be identical)
+ // floating point rounding error can cause output variances. To mitigat e this, threshold
+ // caps off values that differ by less than it, flushing the effective o utput value to zero.
+ const double ave_fitness = sum_fitness.Average();
+ const double threshold = 1.0e-14;
+ if (ave_fitness == 0.0 || dom_fitness == 0.0 || fabs(ave_fitness - dom_fitness) < threshold) {
energy = 0.0;
} else {
- energy = Log(dom_fitness / sum_fitness.Average());
+ energy = Log(dom_fitness / ave_fitness);
}
}
More information about the Avida-cvs
mailing list