Merged in upstream changes and reopened #c42 ar
authorDmitriy Morozov <morozov@cs.duke.edu>
Wed, 19 Mar 2008 12:50:35 -0400
branchar
changeset 85 58deab1c8eb9
parent 84 c711bb2916e4 (current diff)
parent 51 0a18d6902a55 (diff)
child 86 73a54447b54a
Merged in upstream changes and reopened #c42
.issues/c420501cc5285bbc
CMakeLists.txt
--- a/.issues/c420501cc5285bbc	Sun Mar 02 16:42:33 2008 -0500
+++ b/.issues/c420501cc5285bbc	Wed Mar 19 12:50:35 2008 -0400
@@ -1,7 +1,7 @@
 From artemis Tue Feb 26 10:25:07 2008
 From: Dmitriy Morozov <morozov@cs.duke.edu>
 Date: Tue, 26 Feb 2008 05:22:56 -0500
-State: fixed
+State: open
 Subject: Non-optimized CGAL runtime error
 Message-Id: <c420501cc5285bbc-0-artemis@metatron>
 
@@ -29,3 +29,33 @@
 I suspect the bug in CGAL (since everything works fine with CGAL_NO_ASSERTIONS
 set), so I disabled the offending assertion (and all the rest of them) by
 setting a CXX flag in CMakeLists.txt.
+
+From artemis Wed Mar 19 16:47:55 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Wed, 19 Mar 2008 12:47:24 -0400
+Subject: Fixed in 0a18d6902a55
+Message-Id: <c420501cc5285bbc-db67b15857938f7b-artemis@metatron>
+References: <c420501cc5285bbc-0-artemis@metatron>
+In-Reply-To: <c420501cc5285bbc-0-artemis@metatron>
+
+Fixed by dealing with infinite simplices in 0a18d6902a55
+
+From artemis Wed Mar 19 16:49:36 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Wed, 19 Mar 2008 12:49:01 -0400
+Subject: Reopened for ar-vineyard
+Message-Id: <c420501cc5285bbc-8f74ccde6b3f0bea-artemis@metatron>
+References: <c420501cc5285bbc-0-artemis@metatron>
+In-Reply-To: <c420501cc5285bbc-0-artemis@metatron>
+
+Fix for ar-vineyard like for alphashapes
+
+From artemis Wed Mar 19 16:49:47 2008
+From: Dmitriy Morozov <morozov@cs.duke.edu>
+Date: Wed, 19 Mar 2008 12:49:47 -0400
+Subject: properties changes (state)
+Message-Id: <c420501cc5285bbc-ef5f506b45aba335-artemis@metatron>
+References: <c420501cc5285bbc-0-artemis@metatron>
+In-Reply-To: <c420501cc5285bbc-0-artemis@metatron>
+
+state=open
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.issues/cff004eda75a26c2	Wed Mar 19 12:50:35 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/CMakeLists.txt	Sun Mar 02 16:42:33 2008 -0500
+++ b/CMakeLists.txt	Wed Mar 19 12:50:35 2008 -0400
@@ -4,12 +4,15 @@
 option						(counters			"Build Dionysus with counters on" 		OFF)
 option						(debug				"Build Dionysus with debugging on" 		OFF)
 option						(optimize			"Build Dionysus with optimization"		ON)
+option						(use_dsrpdb			"Build examples that use DSR-PDB"		OFF)
 
 # Find everything that's always required
 find_package				(Boost REQUIRED)
 find_package				(Doxygen)
-find_library				(dsrpdb_LIBRARY 			NAMES dsrpdb)
-find_path					(dsrpdb_INCLUDE_DIR 		dsrpdb/Protein.h)
+if                          (use_dsrpdb)
+    find_library			(dsrpdb_LIBRARY 			NAMES dsrpdb)
+    find_path				(dsrpdb_INCLUDE_DIR 		dsrpdb/Protein.h)
+endif                       (use_dsrpdb)
 
 #CGAL
 execute_process				(COMMAND ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_SOURCE_DIR}/FindCGAL.Makefile libpaths
@@ -39,8 +42,6 @@
 														${gmp_LIBRARY} 
 														${gmpxx_LIBRARY} 
 														${m_LIBRARY})
-set                         (cgal_cxxflags              ${cgal_cxxflags}
-                                                        -DCGAL_NO_ASSERTIONS)
 
 # SYNAPS
 add_definitions				(-DBOOST_UBLAS_TYPE_CHECK=0)
--- a/README	Sun Mar 02 16:42:33 2008 -0500
+++ b/README	Wed Mar 19 12:50:35 2008 -0400
@@ -1,6 +1,6 @@
 Dependencies
   CGAL-3.3 -    for alpha-shapes and kinetic data structures
-  DSR-PDB -     for reading in PDB files
+  DSR-PDB -     for reading in PDB files (if use_dsrpdb is turned on in cmake)
   CMake -       for controlling the build process
   boost -       great set of C++ libraries
   Doxygen -     for building documentation
@@ -21,9 +21,10 @@
   
   In the cmake line you can provide -Ddebug:bool=on to turn on debugging,
   -Dcounters:bool=on to turn on counters, -Doptimize:bool=on to turn on
-  optimization.  Depending on the combination of debugging and optimization, a
-  particular CMAKE_CXX_FLAGS* is chosen.  All of this can be set using a text
-  user interface by running ccmake instead of cmake.
+  optimization, -Duse_dsrpdb:bool=on to turn on reading PDB files.  Depending on
+  the combination of debugging and optimization, a particular CMAKE_CXX_FLAGS*
+  is chosen.  All of this can be set using a text user interface by running
+  ccmake instead of cmake.
 
 Author
   Dmitriy Morozov <morozov@cs.duke.edu>
--- a/examples/alphashapes/alphashapes2d.h	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/alphashapes/alphashapes2d.h	Wed Mar 19 12:50:35 2008 -0400
@@ -49,7 +49,7 @@
 	    							AlphaSimplex2D(const ::Vertex& v);
 		
 								    AlphaSimplex2D(const Edge& e);
-								    AlphaSimplex2D(const Edge& e, const SimplexSet& simplices);
+								    AlphaSimplex2D(const Edge& e, const SimplexSet& simplices, const Delaunay& Dt);
 		
 									AlphaSimplex2D(const Face& c);
 	    
--- a/examples/alphashapes/alphashapes2d.hpp	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/alphashapes/alphashapes2d.hpp	Wed Mar 19 12:50:35 2008 -0400
@@ -16,7 +16,7 @@
 }
 
 AlphaSimplex2D::	    
-AlphaSimplex2D(const Edge& e, const SimplexSet& simplices): attached_(false)
+AlphaSimplex2D(const Edge& e, const SimplexSet& simplices, const Delaunay& Dt): attached_(false)
 {
     Face_handle f = e.first;
 	for (int i = 0; i < 3; ++i)
@@ -31,25 +31,26 @@
 	const Point& p2 = (*v)->point();
 	
 	attached_ = false;
-	if (CGAL::side_of_bounded_circle(p1, p2, 
+	if (!Dt.is_infinite(f->vertex(e.second)) &&
+        CGAL::side_of_bounded_circle(p1, p2, 
 									 f->vertex(e.second)->point()) == CGAL::ON_BOUNDED_SIDE)
 		attached_ = true;
-	else if (CGAL::side_of_bounded_circle(p1, p2,
+	else if (!Dt.is_infinite(o->vertex(oi)) &&
+             CGAL::side_of_bounded_circle(p1, p2,
 										  o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
-			attached_ = true;
+		attached_ = true;
 	else
 		alpha_ = squared_radius(p1, p2);
 
 	if (attached_)
 	{
-		SimplexSet::const_iterator f_iter = simplices.find(AlphaSimplex2D(*f));
-		SimplexSet::const_iterator o_iter = simplices.find(AlphaSimplex2D(*o));
-		if (f_iter == simplices.end())			// f is infinite
-			alpha_ = o_iter->alpha();
-		else if (o_iter == simplices.end())		// o is infinite
-			alpha_ = f_iter->alpha();
+		if (Dt.is_infinite(f))
+			alpha_ = simplices.find(AlphaSimplex2D(*o))->alpha();
+		else if (Dt.is_infinite(o))
+			alpha_ = simplices.find(AlphaSimplex2D(*f))->alpha();
 		else
-			alpha_ = std::min(f_iter->alpha(), o_iter->alpha());
+			alpha_ = std::min(simplices.find(AlphaSimplex2D(*f))->alpha(), 
+                              simplices.find(AlphaSimplex2D(*o))->alpha());
 	}
 }
 
@@ -107,7 +108,7 @@
 		simplices.insert(AlphaSimplex2D(*cur));
 	rInfo("Faces inserted");
 	for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
-		simplices.insert(AlphaSimplex2D(*cur, simplices));
+		simplices.insert(AlphaSimplex2D(*cur, simplices, Dt));
 	rInfo("Edges inserted");
 	for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
 		simplices.insert(AlphaSimplex2D(*cur));
--- a/examples/alphashapes/alphashapes3d.h	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/alphashapes/alphashapes3d.h	Wed Mar 19 12:50:35 2008 -0400
@@ -52,10 +52,10 @@
 	    							AlphaSimplex3D(const ::Vertex& v);
 		
 								    AlphaSimplex3D(const Edge& e);
-								    AlphaSimplex3D(const Edge& e, const SimplexSet& simplices, Facet_circulator facet_bg);
+								    AlphaSimplex3D(const Edge& e, const SimplexSet& simplices, const Delaunay& Dt, Facet_circulator facet_bg);
 		
 								    AlphaSimplex3D(const Facet& f);
-								    AlphaSimplex3D(const Facet& f, const SimplexSet& simplices);
+								    AlphaSimplex3D(const Facet& f, const SimplexSet& simplices, const Delaunay& Dt);
 	    
 									AlphaSimplex3D(const Cell& c);
 	    
--- a/examples/alphashapes/alphashapes3d.hpp	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/alphashapes/alphashapes3d.hpp	Wed Mar 19 12:50:35 2008 -0400
@@ -15,19 +15,15 @@
 }
 
 AlphaSimplex3D::	    
-AlphaSimplex3D(const Edge& e, const SimplexSet& simplices, Facet_circulator facet_bg)
+AlphaSimplex3D(const Edge& e, const SimplexSet& simplices, const Delaunay& Dt, Facet_circulator facet_bg)
 {
     Cell_handle c = e.first;
 	Parent::add(c->vertex(e.second));
 	Parent::add(c->vertex(e.third));
 
 	Facet_circulator cur = facet_bg;
+	while (Dt.is_infinite(*cur))    ++cur; 
 	SimplexSet::const_iterator cur_iter = simplices.find(AlphaSimplex3D(*cur));
-	while (cur_iter == simplices.end())
-	{
-		++cur; 
-		cur_iter = simplices.find(AlphaSimplex3D(*cur));
-	}
 	RealValue min = cur_iter->alpha();
 	
 	VertexSet::const_iterator v = Parent::vertices().begin();
@@ -41,14 +37,10 @@
 		int i0 = (*cur).first->index(*v++);
 		int i1 = (*cur).first->index(*v);
 		int i = 6 - i0 - i1 - (*cur).second;
+        if (Dt.is_infinite(cur->first->vertex(i))) { ++cur; continue; }
 		Point p3 = (*cur).first->vertex(i)->point();
 
 		cur_iter = simplices.find(AlphaSimplex3D(*cur));
-		if (cur_iter == simplices.end())			// cur is infinite
-		{
-			++cur; continue;
-		}
-		
 		if (CGAL::side_of_bounded_sphere(p1, p2, p3) == CGAL::ON_BOUNDED_SIDE)
 			attached_ = true;
 		RealValue val = cur_iter->alpha();
@@ -73,7 +65,7 @@
 }
 
 AlphaSimplex3D::	    
-AlphaSimplex3D(const Facet& f, const SimplexSet& simplices)
+AlphaSimplex3D(const Facet& f, const SimplexSet& simplices, const Delaunay& Dt)
 {
     Cell_handle c = f.first;
 	for (int i = 0; i < 4; ++i)
@@ -89,10 +81,12 @@
 	const Point& p3 = (*v)->point();
 	
 	attached_ = false;
-	if (CGAL::side_of_bounded_sphere(p1, p2, p3,
+	if (!Dt.is_infinite(c->vertex(f.second)) && 
+        CGAL::side_of_bounded_sphere(p1, p2, p3,
 									 c->vertex(f.second)->point()) == CGAL::ON_BOUNDED_SIDE)
 		attached_ = true;
-	else if (CGAL::side_of_bounded_sphere(p1, p2, p3,
+	else if (!Dt.is_infinite(o->vertex(oi)) &&
+             CGAL::side_of_bounded_sphere(p1, p2, p3,
 										  o->vertex(oi)->point()) == CGAL::ON_BOUNDED_SIDE)
 		attached_ = true;
 	else
@@ -100,14 +94,13 @@
 	
 	if (attached_)
 	{
-		SimplexSet::const_iterator c_iter = simplices.find(AlphaSimplex3D(*c));
-		SimplexSet::const_iterator o_iter = simplices.find(AlphaSimplex3D(*o));
-		if (c_iter == simplices.end())			// c is infinite
-			alpha_ = o_iter->alpha();
-		else if (o_iter == simplices.end())		// o is infinite
-			alpha_ = c_iter->alpha();
+		if (Dt.is_infinite(c))
+			alpha_ = simplices.find(AlphaSimplex3D(*o))->alpha();
+		else if (Dt.is_infinite(o))
+			alpha_ = simplices.find(AlphaSimplex3D(*c))->alpha();
 		else
-			alpha_ = std::min(c_iter->alpha(), o_iter->alpha());
+			alpha_ = std::min(simplices.find(AlphaSimplex3D(*c))->alpha(), 
+                              simplices.find(AlphaSimplex3D(*o))->alpha());
 	}
 }
 
@@ -165,10 +158,10 @@
 		simplices.insert(AlphaSimplex3D(*cur));
 	rInfo("Cells inserted");
 	for(Facet_iterator cur = Dt.finite_facets_begin(); cur != Dt.finite_facets_end(); ++cur)
-		simplices.insert(AlphaSimplex3D(*cur, simplices));
+		simplices.insert(AlphaSimplex3D(*cur, simplices, Dt));
 	rInfo("Facets inserted");
 	for(Edge_iterator cur = Dt.finite_edges_begin(); cur != Dt.finite_edges_end(); ++cur)
-		simplices.insert(AlphaSimplex3D(*cur, simplices, Dt.incident_facets(*cur)));
+		simplices.insert(AlphaSimplex3D(*cur, simplices, Dt, Dt.incident_facets(*cur)));
 	rInfo("Edges inserted");
 	for(Vertex_iterator cur = Dt.finite_vertices_begin(); cur != Dt.finite_vertices_end(); ++cur)
 		simplices.insert(AlphaSimplex3D(*cur));
--- a/examples/fitness/avida-landscape.cpp	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/fitness/avida-landscape.cpp	Wed Mar 19 12:50:35 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.
         }
     }
 }
--- a/examples/grid/CMakeLists.txt	Sun Mar 02 16:42:33 2008 -0500
+++ b/examples/grid/CMakeLists.txt	Wed Mar 19 12:50:35 2008 -0400
@@ -1,7 +1,12 @@
 set							(targets						
 							 test-grid2D 
-							 pdbdistance-vineyard
 							 combustion-vineyard)
+
+if                          (use_dsrpdb)
+    set                     (targets                    ${targets}
+                            							pdbdistance-vineyard)
+endif                       (use_dsrpdb)
+
 							 
 add_definitions				(${cgal_cxxflags})
 foreach 					(t ${targets})