avida-landscape pairs maxima of fitness rather than minima fitness
authorDmitriy Morozov <morozov@cs.duke.edu>
Mon, 25 Feb 2008 04:39:27 -0500
branchfitness
changeset 47 19249d6d9f2d
parent 46 6fbe003aad9d
child 48 71cdbdfb8887
avida-landscape pairs maxima of fitness rather than minima
examples/fitness/avida-landscape.cpp
--- a/examples/fitness/avida-landscape.cpp	Sun Feb 17 16:32:33 2008 -0500
+++ b/examples/fitness/avida-landscape.cpp	Mon Feb 25 04:39:27 2008 -0500
@@ -24,14 +24,17 @@
 {
     public:
         bool    operator()(VertexIndex i, VertexIndex j) const      
-        { return i->index()->fitness() < j->index()->fitness(); }
+        { return i->index()->fitness() > j->index()->fitness(); }       
+        // > because of -fitness, so that maxima turn into minima
 };
 
 typedef         LSFiltration::Vineyard                              LSVineyard;
 class           StaticEvaluator: public LSVineyard::Evaluator
 {
     public:
-        virtual RealType        value(const Simplex& s) const       { return s.get_attachment()->index()->fitness(); }
+        virtual RealType        
+                value(const Simplex& s) const       
+        { return s.get_attachment()->index()->fitness(); }
 };
 
 std::ostream& operator<<(std::ostream& out, VertexIndex i)
@@ -42,6 +45,7 @@
 {
 #ifdef LOGGING
     rlog::RLogInit(argc, argv);
+    stderrLog.subscribeTo(RLOG_CHANNEL("error"));
     //stdoutLog.subscribeTo(RLOG_CHANNEL("info"));
 #endif
 
@@ -89,6 +93,7 @@
     for (LSFiltration::Index i = fitness_filtration.begin(); i != fitness_filtration.end(); ++i)
     {
         if (i->is_paired())
+        {
             if (i->sign())
             {
                 AssertMsg(i->dimension() == 0, "Expecting only 0-dimensional diagram");
@@ -97,6 +102,14 @@
                           << evaluator.value(*i) << " " 
                           << evaluator.value(*(i->pair())) << std::endl;
             }
+        }
+        else
+        {
+            if (i->dimension() != 0) continue;
+            std::cout << i->dimension() << " "
+                      << evaluator.value(*i) << " "
+                      << "unpaired" << std::endl;
+        }
     }
 
 #if 0