Normalized persistence (#cff) + unpaired simplices output pairs with 0 fitness
authorDmitriy Morozov <morozov@cs.duke.edu>
Fri, 14 Mar 2008 18:35:41 -0400
branchfitness
changeset 49 7558e122ba4f
parent 48 71cdbdfb8887
child 50 264e05b89875
Normalized persistence (#cff) + unpaired simplices output pairs with 0
.issues/cff004eda75a26c2
examples/fitness/avida-landscape.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/cff004eda75a26c2	Fri Mar 14 18:35:41 2008 -0400
@@ -0,0 +1,20 @@
+From artemis Tue Mar 11 08:06:40 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Tue, 11 Mar 2008 04:05:25 -0400
+State: fixed
+Subject: Scale fitness
+Message-Id: <cff004eda75a26c2-0-artemis@metatron>
+
+When computing fitness persistence, divide all values by the maximum fitness.
+That way it's possible to compare persistence diagrams for runs in different
+environments.
+
+From artemis Fri Mar 14 22:34:41 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Fri, 14 Mar 2008 18:34:41 -0400
+Subject: properties changes (state)
+Message-Id: <cff004eda75a26c2-ad10cae14deb092d-artemis@metatron>
+References: <cff004eda75a26c2-0-artemis@metatron>
+In-Reply-To: <cff004eda75a26c2-0-artemis@metatron>
+
+state=fixed
--- a/examples/fitness/avida-landscape.cpp	Mon Feb 25 16:24:29 2008 -0500
+++ b/examples/fitness/avida-landscape.cpp	Fri Mar 14 18:35:41 2008 -0400
@@ -35,9 +35,15 @@
 class           StaticEvaluator: public LSVineyard::Evaluator
 {
     public:
+                StaticEvaluator(float max_fitness): 
+                    max_fitness_(max_fitness)                       {}
+
         virtual RealType        
                 value(const Simplex& s) const       
-        { return s.get_attachment()->index()->fitness(); }
+        { return s.get_attachment()->index()->fitness()/max_fitness_; }
+
+    private:
+        float   max_fitness_;
 };
 
 std::ostream& operator<<(std::ostream& out, VertexIndex i)
@@ -101,15 +107,19 @@
     const AvidaPopulationDetail::OrganismVector& organisms = population.get_organisms();
 
     rInfo("Number of organisms: %d", organisms.size());
+    float max_fitness = organisms[0].fitness();
     for (int i = 0; i < population.get_organisms().size(); ++i)
+    {
+        max_fitness = std::max(max_fitness, organisms[i].fitness());
         rInfo("%d (%s) %f %d %d", organisms[i].id(),
                                   organisms[i].genome().c_str(),
                                   organisms[i].fitness(),
                                   organisms[i].length(),
                                   organisms[i].genome().size());
+    }
 
     // Order vertices 
-    StaticEvaluator     evaluator;
+    StaticEvaluator     evaluator(max_fitness);
     LSVineyard          vineyard(&evaluator);
     VertexVector        vertices;
     for (OrganismIndex cur = organisms.begin(); cur != organisms.end(); ++cur)  vertices.push_back(cur);
@@ -190,7 +200,10 @@
             if (i->dimension() != 0) continue;
             std::cout << i->dimension() << " "
                       << evaluator.value(*i) << " "
-                      << "unpaired" << std::endl;
+                      << 0 << std::endl;
+            // The infinite pair does not make sense since we are interested in 
+            // max of fitness, rather than min of -fitness. However min value for 
+            // fitness is 0, so it's a natural choice of the answer.
         }
     }
 }