Parcourir la source

Remove dead code

Eric Ramat il y a 7 ans
Parent
commit
18705ee5d1

+ 3 - 3
src/tests/CMakeLists.txt

@@ -1,9 +1,9 @@
-ADD_SUBDIRECTORY(boost_graph)
+#ADD_SUBDIRECTORY(boost_graph)
 ADD_SUBDIRECTORY(common)
 #ADD_SUBDIRECTORY(corsen)
 ADD_SUBDIRECTORY(dtss)
 ADD_SUBDIRECTORY(mixed)
 ADD_SUBDIRECTORY(mpi)
-ADD_SUBDIRECTORY(multithreading)
+#ADD_SUBDIRECTORY(multithreading)
 ADD_SUBDIRECTORY(pdevs)
-ADD_SUBDIRECTORY(plot)
+#ADD_SUBDIRECTORY(plot)

+ 1 - 1
src/tests/multithreading/CMakeLists.txt

@@ -28,4 +28,4 @@ TARGET_LINK_LIBRARIES(pdevs-multithreading-main
   ${Boost_SYSTEM_LIBRARY}
   ${Boost_TIMER_LIBRARY})
 
-ADD_SUBDIRECTORY(lifegame)
+ADD_SUBDIRECTORY(lifegame)

+ 8 - 31
src/tests/pdevs/graph_manager.hpp

@@ -136,7 +136,7 @@ public:
                         const paradevs::common::NoParameters& parameters) :
         paradevs::pdevs::GraphManager < common::DoubleTime >(coordinator,
                                                           parameters),
-        model("m", common::NoParameters())
+        model("a", common::NoParameters())
     {
         add_child(&model);
     }
@@ -155,32 +155,11 @@ public:
     FlatGraphManager(common::Coordinator < common::DoubleTime >* coordinator,
                      const paradevs::common::NoParameters& parameters) :
         paradevs::pdevs::GraphManager < common::DoubleTime >(coordinator,
-							     parameters) //,
-      /*        a1("a1", common::NoParameters()), b1("b1", common::NoParameters()),
-		a2("a2", common::NoParameters()), b2("b2", common::NoParameters()) */
+							     parameters),
+        a1("a1", common::NoParameters()), b1("b1", common::NoParameters()),
+        a2("a2", common::NoParameters()), b2("b2", common::NoParameters())
     {
-      for (unsigned int i = 0; i < 10000; ++i) {
-	std::stringstream ssA;
-	std::stringstream ssB;
-
-	ssA << "a" << (i + 1);
-	ssB << "b" << (i + 1);
-
-	paradevs::pdevs::Simulator < common::DoubleTime, A >* sA = new paradevs::pdevs::Simulator < common::DoubleTime, A >(ssA.str(), common::NoParameters());
-	paradevs::pdevs::Simulator < common::DoubleTime, B >* sB = new paradevs::pdevs::Simulator < common::DoubleTime, B >(ssB.str(), common::NoParameters());
-
-	simulatorsA.push_back(sA);
-	simulatorsB.push_back(sB);
-	add_child(sA);
-	add_child(sB);
-        sA->add_in_port("in");
-	sA->add_out_port("out");
-        sB->add_in_port("in");
-	sB->add_out_port("out");
-	add_link(sA, "out", sB, "in");
-      }
-      
-	/*        add_child(&a1);
+        add_child(&a1);
         add_child(&b1);
         add_child(&a2);
         add_child(&b2);
@@ -194,19 +173,17 @@ public:
 
         add_link(&a1, "out", &b1, "in");
         add_link(&b1, "out", &a2, "in");
-        add_link(&a2, "out", &b2, "in"); */
+        add_link(&a2, "out", &b2, "in");
     }
 
     virtual ~FlatGraphManager()
     { }
 
 private:
-  std::vector < paradevs::pdevs::Simulator < common::DoubleTime, A >* > simulatorsA;
-  std::vector < paradevs::pdevs::Simulator < common::DoubleTime, B >* > simulatorsB;
-  /*    paradevs::pdevs::Simulator < common::DoubleTime, A > a1;
+    paradevs::pdevs::Simulator < common::DoubleTime, A > a1;
     paradevs::pdevs::Simulator < common::DoubleTime, B > b1;
     paradevs::pdevs::Simulator < common::DoubleTime, A > a2;
-    paradevs::pdevs::Simulator < common::DoubleTime, B > b2; */
+    paradevs::pdevs::Simulator < common::DoubleTime, B > b2;
 };
 
 } } } // namespace paradevs tests pdevs

+ 78 - 65
src/tests/pdevs/models.hpp

@@ -90,10 +90,6 @@ public:
         // delay();
         ++_value.x;
         --_value.y;
-
-        // std::cout << t << ": " << get_name() << " => dint -> "
-        //            << _value.x << " " << _value.y << std::endl;
-
         if (_phase == SEND) {
             _phase = WAIT;
         }
@@ -109,13 +105,6 @@ public:
         (void)msgs;
 #endif
 
-        // for (common::Bag < common::DoubleTime >::const_iterator it =
-	//        msgs.begin(); it != msgs.end(); ++it) {
-	//   std::cout << t << ": " << get_name()
-	// 	    << " => " << it->get_content().get_content < double >()
-	// 	    << std::endl;
-        // }
-	
 #ifdef WITH_TRACE
         common::Trace < common::DoubleTime >::trace()
             << common::TraceElement < common::DoubleTime >(
@@ -138,9 +127,6 @@ public:
         (void)msgs;
 #endif
 
-        // std::cout << t << ": " << get_name() << " => " << msgs.to_string()
-	// 	  << std::endl;
-
 #ifdef WITH_TRACE
         common::Trace < common::DoubleTime >::trace()
             << common::TraceElement < common::DoubleTime >(
@@ -206,8 +192,6 @@ public:
             common::ExternalEvent < common::DoubleTime >(
                 "out", common::Value(_value)));
 
-        // std::cout << t << ": " << get_name() << " => lambda" << std::endl;
-
 #ifdef WITH_TRACE
         common::Trace < common::DoubleTime >::trace()
             << common::TraceElement < common::DoubleTime >(
@@ -256,11 +240,6 @@ public:
         common::Trace < common::DoubleTime >::trace().flush();
 #endif
 
-        // delay();
-
-        // std::cout << t << ": " << get_name() << " => dint -> "
-	// 	  << _value << std::endl;
-
         if (_phase == SEND) {
             _phase = WAIT;
         }
@@ -276,14 +255,6 @@ public:
         (void)msgs;
 #endif
 
-        // for (common::Bag < common::DoubleTime >::const_iterator it =
-	//        msgs.begin(); it != msgs.end(); ++it) {
-	//   std::cout << t << ": " << get_name()
-	// 	    << " => " << it->get_content().get_content < data >().x
-	// 	    << " " << it->get_content().get_content < data >().y
-	// 	    << std::endl;
-        // }
-	
 #ifdef WITH_TRACE
         common::Trace < common::DoubleTime >::trace()
             << common::TraceElement < common::DoubleTime >(
@@ -367,8 +338,6 @@ public:
 #endif
         common::Bag < common::DoubleTime > msgs;
 
-        // std::cout << t << ": " << get_name() << " => lambda" << std::endl;
-
         msgs.push_back(common::ExternalEvent <
                            common::DoubleTime >(
                                "out", common::Value(_value)));
@@ -461,6 +430,81 @@ public:
     virtual ~ThreeStateModel()
     { }
 
+    void dconf(typename common::DoubleTime::type t,
+               typename common::DoubleTime::type e,
+               const common::Bag < common::DoubleTime >& msgs)
+    {
+        dext(t, e, msgs);
+    }
+
+    void dext(typename common::DoubleTime::type /* t */,
+              typename common::DoubleTime::type /* e */,
+              const common::Bag < common::DoubleTime >& msgs)
+    {
+        for (common::Bag < common::DoubleTime >::const_iterator
+                 it = msgs.begin(); it != msgs.end(); ++it) {
+            ++n;
+        }
+        if (sigma == 1) {
+            if (n > 3) {
+                ++index;
+                if (index == scales.size()) {
+                    index = 0;
+                }
+                sigma = std::numeric_limits < double >::max();
+                if (scales[index] == 1) {
+                    scales[index] = 2;
+                } else {
+                    scales[index] = 1;
+                }
+                n = 0;
+            }
+        } else {
+            sigma = 1;
+            n = 0;
+        }
+    }
+
+    void dint(typename common::DoubleTime::type t)
+    {
+        mark_full(t);
+        if (full_N()) {
+            raz();
+        }
+        compute();
+    }
+
+    typename common::DoubleTime::type start(
+        typename common::DoubleTime::type t)
+    {
+        heights = { 0, 0, 0, 0, 0 };
+        speeds = { 0.21, 0.3, 0.7, 0.56, 0.14 };
+        scales = { 1, 1, 1, 1, 1 };
+        index = 0;
+        n = 0;
+        sigma = 1;
+        _last_time = t;
+        return 0;
+    }
+
+    typename common::DoubleTime::type ta(
+        typename common::DoubleTime::type /* t */) const
+    { return sigma; }
+
+    common::Bag < common::DoubleTime > lambda(
+        typename common::DoubleTime::type /* t */) const
+    {
+        common::Bag < common::DoubleTime > msgs;
+
+        if (full()) {
+            msgs.push_back(common::ExternalEvent < common::DoubleTime >(
+                               "out", 0));
+        }
+        return msgs;
+    }
+
+private:
+
     void compute()
     {
         for (unsigned int i = 0; i < heights.size(); ++i) {
@@ -539,43 +583,12 @@ public:
         }
     }
 
-    void dint(typename common::DoubleTime::type t)
-    {
-        mark_full(t);
-        if (full_N()) {
-            raz();
-        }
-        compute();
-    }
-
-    typename common::DoubleTime::type start(
-        typename common::DoubleTime::type t)
-    {
-        heights = { 0, 0, 0, 0, 0 };
-        speeds = { 0.21, 0.3, 0.7, 0.56, 0.14 };
-        scales = { 1, 1, 1, 1, 1 };
-        _last_time = t;
-        return 0;
-    }
-
-    typename common::DoubleTime::type ta(
-        typename common::DoubleTime::type /* t */) const
-    { return 1; }
-
-    common::Bag < common::DoubleTime > lambda(
-        typename common::DoubleTime::type t) const
-    {
-        if (full()) {
-            std::cout << (t - _last_time) << " ";
-            // display_full();
-        }
-        return common::Bag < common::DoubleTime >();
-    }
-
-private:
     std::vector < double > heights;
     std::vector < double > speeds;
     std::vector < double > scales;
+    unsigned int index;
+    unsigned int n;
+    typename common::DoubleTime::type sigma;
 
     typename common::DoubleTime::type _last_time;
 };

+ 7 - 11
src/tests/pdevs/tests.cpp

@@ -35,7 +35,7 @@
 using namespace paradevs::tests::pdevs;
 using namespace paradevs::common;
 
-/*TEST_CASE("pdevs/only_one", "run")
+TEST_CASE("pdevs/only_one", "run")
 {
     paradevs::common::RootCoordinator <
         DoubleTime, paradevs::pdevs::Coordinator <
@@ -73,7 +73,7 @@ using namespace paradevs::common;
                 filter_model_name("a").filter_time(t).
                 filter_type(paradevs::common::LAMBDA).size() == 1);
     }
-} */
+}
 
 TEST_CASE("pdevs/flat", "run")
 {
@@ -84,15 +84,11 @@ TEST_CASE("pdevs/flat", "run")
         > rc(0, 30, "root", paradevs::common::NoParameters(),
              paradevs::common::NoParameters());
 
-    std::cout << "TEST" << std::endl;
-    
     paradevs::common::Trace < DoubleTime >::trace().clear();
     rc.run();
 
-    REQUIRE(true);
-
-    /*    REQUIRE(paradevs::common::Trace <
-                DoubleTime >::trace().elements().
+    REQUIRE(paradevs::common::Trace <
+            DoubleTime >::trace().elements().
             filter_model_name("a1").
             filter_type(paradevs::common::START).size() == 1);
     REQUIRE(paradevs::common::Trace <
@@ -186,10 +182,10 @@ TEST_CASE("pdevs/flat", "run")
                     DoubleTime >::trace().elements().
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
-		} */
+    }
 }
 
-/*TEST_CASE("pdevs/hierachical", "run")
+TEST_CASE("pdevs/hierachical", "run")
 {
     paradevs::common::RootCoordinator <
         DoubleTime, paradevs::pdevs::Coordinator <
@@ -297,4 +293,4 @@ TEST_CASE("pdevs/flat", "run")
                 filter_model_name("b2").filter_time(t).
                 filter_type(paradevs::common::DELTA_EXT).size() == 2);
     }
-    } */
+}

+ 9 - 3
src/tests/plot/graph_builder.hpp

@@ -302,33 +302,39 @@ private:
                          polygons, std::map < int, bool >& select)
     {
         double sum = 0;
+	unsigned int N = 0;
 
         std::map < int, std::pair < Polygon*, Points > >::const_iterator it =
             polygons.begin();
 
         while (it != polygons.end()) {
             sum += it->second.first->getArea() * SCALE * SCALE / 1e4;
+	    N += it->second.second.size();
             select[it->first] = false;
             ++it;
         }
 
         std::cout << "Total area = " << sum << " Ha" << std::endl;
+        std::cout << polygons.size() << " plots - " << N << " cells"
+		  << std::endl;
 
         int n = 0;
 
         sum = 0;
-        while (sum < 150) {
+	//while (sum < 500) {
+	  while (n < 400) {
             int index = rand() % polygons.size();
 
-            if (not select[index] and
+            if (not select[index] /*and
                 polygons.find(index)->second.first->getArea() *
-                SCALE * SCALE  > 10 * 1e4) {
+                SCALE * SCALE  > 10 * 1e4*/) {
                 select[index] = true;
                 sum += polygons.find(index)->second.first->getArea() *
                     SCALE * SCALE / 1e4;
                 ++n;
             }
         }
+	select[153] = true;
 
         std::cout << "Select number = " << n << " for " << sum << std::endl;
 

+ 1 - 1
src/tests/plot/graph_defs.hpp

@@ -56,7 +56,7 @@ struct VertexProperties
     Points _points;
     int    _neighbour_number;
 
-    VertexProperties() : _index(0), _weight(0), _neighbour_number(0)
+  VertexProperties() : _index(0), _weight(0), _neighbour_number(0)
     { }
 
     VertexProperties(int index, double weight, const Points& points,

+ 30 - 13
src/tests/plot/models.hpp

@@ -49,7 +49,7 @@ struct PlotParameters
     PlotParameters(int index,
                    const paradevs::tests::boost_graph::Points& points,
                    int neighbour_number)
-        : _index(index), _points(points), _neighbour_number(neighbour_number)
+      : _index(index), _points(points), _neighbour_number(neighbour_number)
     { }
 
     int _index;
@@ -68,6 +68,9 @@ struct PlotData
         index(index), points(points), ready_spore_numbers(ready_spore_numbers)
     { }
 
+  PlotData(const PlotData& d) : index(d.index), points(d.points), ready_spore_numbers(d.ready_spore_numbers)
+    { }
+
     int index;
     Points points;
     Doubles ready_spore_numbers;
@@ -86,6 +89,9 @@ public:
     {
         _data.index = _index;
         _data.points = parameters._points;
+	_active = _data.points.size() > 0;
+
+	std::cout << _data.points.size() << std::endl;
 
         for (Points::const_iterator it = parameters._points.begin();
              it != parameters._points.end(); ++it) {
@@ -93,7 +99,7 @@ public:
             _data.ready_spore_numbers.push_back(0.);
         }
 
-        _handle = DBFOpen("/home/eric/tmp/parcelle/test/parcellaire.dbf",
+        _handle = DBFOpen("/home/eric/vagrant_data/tmp/parcelle/test/parcellaire.dbf",
                           "rb+");
 
         if (!_handle) {
@@ -179,13 +185,18 @@ public:
                 }
                 sum /= _data.points.size();
                 if (sum > 0) {
-                    p = std::log10(sum);
+
+		  std::cout << "OK" << std::endl;
+
+		  p = std::log10(sum);
                     if (p < 0) {
                         p = 0;
                     }
                 }
-
-                DBFWriteDoubleAttribute(_handle, _index, (int)t, p);
+		if (_active) 
+		  DBFWriteDoubleAttribute(_handle, _index, (int)t, p);
+		else
+		  DBFWriteDoubleAttribute(_handle, _index, (int)t, 0.);
             }
 
             _phase  = SEND;
@@ -201,18 +212,18 @@ public:
     {
         for (common::Bag < common::DoubleTime >::const_iterator it =
                  bag.begin(); it != bag.end(); ++it) {
-            PlotData data; // = *(PlotData*)(it->get_content());
+            PlotData data = it->get_content().get_content < PlotData >();
 
             _neighbour_data.push_back(data);
 
-            std::cout << _index << " " << t << ": dext - "
-                      << data.index << " [ ";
+            // std::cout << _index << " " << t << ": dext - "
+            //           << data.index << " [ ";
 
             for (int k = 0; k < data.ready_spore_numbers.size(); ++k) {
-                std::cout << data.ready_spore_numbers[k] << " ";
-            }
+                 std::cout << data.ready_spore_numbers[k] << " ";
+             }
 
-            std::cout << "]" << std::endl;
+            // std::cout << "]" << std::endl;
 
             ++_received;
         }
@@ -271,8 +282,13 @@ public:
         common::Bag < common::DoubleTime > bag;
 
         if (_phase == SEND) {
-            // bag.push_back(common::ExternalEvent < common::DoubleTime >(
-            //                   "out", _data));
+	  bag.push_back(common::ExternalEvent < common::DoubleTime >(
+	  							     "out", _data));
+
+	  for (int k = 0; k < _data.ready_spore_numbers.size(); ++k) {
+	    std::cout << _data.ready_spore_numbers[k] << " ";
+	  }
+	  
         }
         return bag;
     }
@@ -287,6 +303,7 @@ private:
     int _index;
     paradevs::tests::boost_graph::Points _points;
     int _neighbour_number;
+  bool _active;
 
     DBFHandle _handle;