Parcourir la source

Fix: update scheduler after event dispatch
Add WITH_TRACE directive

Eric Ramat il y a 11 ans
Parent
commit
9cef1f95d2

+ 7 - 0
src/CMakeLists.txt

@@ -1,3 +1,10 @@
+IF ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+  message("TRACE off")
+ELSE ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+  message("TRACE on")
+  add_definitions(-DWITH_TRACE)
+ENDIF ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+
 ADD_SUBDIRECTORY(apps)
 ADD_SUBDIRECTORY(common)
 ADD_SUBDIRECTORY(dtss)

+ 3 - 1
src/apps/main.cpp

@@ -77,7 +77,7 @@ void run_hierarchic_with_heap()
     paradevs::common::RootCoordinator <
         paradevs::MyTime, paradevs::pdevs::Coordinator <
             paradevs::MyTime,
-            paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
+            paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
             paradevs::Root2GraphManager >
         > rc(0, 100, "root", paradevs::pdevs::Parameters());
 
@@ -114,6 +114,7 @@ int main()
     run_flat_with_heap < 80 >();
     run_flat_with_heap < 90 >();
     run_flat_with_heap < 100 >();
+    run_flat_with_heap < 200 >();
 
     run_flat_with_vector < 10 >();
     run_flat_with_vector < 20 >();
@@ -125,6 +126,7 @@ int main()
     run_flat_with_vector < 80 >();
     run_flat_with_vector < 90 >();
     run_flat_with_vector < 100 >();
+    run_flat_with_vector < 200 >();
 
     double t2 = t.elapsed();
 

+ 6 - 3
src/common/InternalEvent.hpp

@@ -58,6 +58,11 @@ public:
         return _time < e._time;
     }
 
+    bool operator>(InternalEvent const &e) const
+    {
+        return _time > e._time;
+    }
+
     bool operator==(InternalEvent const &e) const
     {
         return _time == e._time;
@@ -73,9 +78,7 @@ struct EventCompare
     : std::binary_function < Event, Event, bool >
 {
     bool operator()(const Event &left, const Event &right) const
-    {
-        return left.get_time() > right.get_time();
-    }
+    { return left > right; }
 };
 
 } } // namespace paradevs common

+ 16 - 4
src/common/scheduler/HeapScheduler.hpp

@@ -31,6 +31,7 @@
 
 #include <boost/heap/fibonacci_heap.hpp>
 
+#include <cmath>
 #include <sstream>
 
 namespace paradevs { namespace common { namespace scheduler {
@@ -88,11 +89,22 @@ public:
                            InternalEvent < Time >(time, model)));
     }
 
-    void put(typename Time::type time, Model < Time >* model)
+    void put_increase(typename Time::type time, Model < Time >* model)
     {
-        HeapScheduler < Time >::erase(model->heap_id());
-        model->heap_id(HeapScheduler < Time >::push(
-                           InternalEvent < Time >(time, model)));
+        if (std::isfinite(time)) {
+            HeapScheduler < Time >::erase(model->heap_id());
+            model->heap_id(HeapScheduler < Time >::push(
+                               InternalEvent < Time >(time, model)));
+        } else {
+            HeapScheduler < Time >::increase(
+                model->heap_id(), InternalEvent < Time >(time, model));
+        }
+    }
+
+    void put_decrease(typename Time::type time, Model < Time >* model)
+    {
+        HeapScheduler < Time >::decrease(
+            model->heap_id(), InternalEvent < Time >(time, model));
     }
 
     std::string to_string() const

+ 10 - 1
src/common/scheduler/VectorScheduler.hpp

@@ -72,7 +72,16 @@ public:
                   VectorScheduler < Time >::end());
     }
 
-    void put(typename Time::type time, Model < Time >* model)
+    void put_increase(typename Time::type time, Model < Time >* model)
+    {
+        remove(model);
+        VectorScheduler < Time >::push_back(
+            InternalEvent < Time >(time, model));
+        std::sort(VectorScheduler < Time >::begin(),
+                  VectorScheduler < Time >::end());
+    }
+
+    void put_decrease(typename Time::type time, Model < Time >* model)
     {
         remove(model);
         VectorScheduler < Time >::push_back(

+ 20 - 0
src/dtss/Coordinator.hpp

@@ -62,6 +62,7 @@ public:
     typename Time::type start(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -70,6 +71,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         assert(_graph_manager.children().size() > 0);
 
@@ -79,6 +81,7 @@ public:
         Coordinator < Time, Policy, GraphManager >::_tl = t;
         Coordinator < Time, Policy, GraphManager >::_tn = t;
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -87,6 +90,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Policy, GraphManager >::_tn;
     }
@@ -95,6 +99,7 @@ public:
                                         typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -104,9 +109,11 @@ public:
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn
             << " ; bag = " << bag.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         _graph_manager.dispatch_events(bag, t);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -115,6 +122,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Policy, GraphManager >::_tn;
     }
@@ -129,6 +137,7 @@ public:
     void output(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -137,6 +146,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             for (auto & model : _graph_manager.children()) {
@@ -144,6 +154,7 @@ public:
             }
         }
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -152,6 +163,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -159,12 +171,14 @@ public:
                     const common::ExternalEvent < Time >& event)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
                 common::POST_EVENT)
             << ": BEFORE => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             _graph_manager.post_event(t, event);
@@ -173,18 +187,21 @@ public:
                     Coordinator < Time, Policy, GraphManager >::_tn);
         }
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
                 common::POST_EVENT)
             << ": AFTER => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
     typename Time::type transition(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -193,6 +210,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         if (t == Coordinator < Time, Policy, GraphManager >::_tn) {
             for (auto & event : _policy.bag()) {
@@ -206,6 +224,7 @@ public:
         }
         Coordinator < Time, Policy, GraphManager >::clear_bag();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Policy, GraphManager >::get_name(), t,
@@ -214,6 +233,7 @@ public:
             << "tl = " << Coordinator < Time, Policy, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Policy, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Policy, GraphManager >::_tn;
     }

+ 23 - 1
src/dtss/Simulator.hpp

@@ -49,6 +49,8 @@ public:
 
     typename Time::type start(typename Time::type t)
     {
+
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -57,11 +59,13 @@ public:
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         _dynamics.start(t);
         Simulator < Time, Dynamics >::_tl = t;
         Simulator < Time, Dynamics >::_tn = t;
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -70,6 +74,7 @@ public:
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Simulator < Time, Dynamics >::_tn;
     }
@@ -81,12 +86,15 @@ public:
 
     void output(typename Time::type t)
     {
+
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::OUTPUT)
             << ": BEFORE";
         common::Trace < Time >::trace().flush();
+#endif
 
         if (t == Simulator < Time, Dynamics >::_tn) {
             common::Bag < Time > bag = _dynamics.lambda(t);
@@ -101,12 +109,14 @@ public:
             }
         }
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::OUTPUT)
             << ": AFTER";
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -114,28 +124,37 @@ public:
                     const common::ExternalEvent < Time >& event)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::POST_EVENT)
             << ": BEFORE => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         Simulator < Time, Dynamics >::add_event(event);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::POST_EVENT)
             << ": AFTER => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
     typename Time::type transition(typename Time::type t)
     {
 
-        common::Trace < Time >::trace()
+ #ifdef WITH_TRACE
+       common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::S_MESSAGE)
@@ -143,6 +162,7 @@ public:
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         // assert(t == Simulator < Time, Dynamics >::_tn);
 
@@ -151,6 +171,7 @@ public:
         Simulator < Time, Dynamics >::_tn = t + _time_step;
         Simulator < Time, Dynamics >::clear_bag();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -159,6 +180,7 @@ public:
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Simulator < Time, Dynamics >::_tn;
     }

+ 37 - 2
src/pdevs/Coordinator.hpp

@@ -58,6 +58,7 @@ public:
     typename Time::type start(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -66,6 +67,7 @@ public:
             << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         assert(_graph_manager.children().size() > 0);
 
@@ -79,6 +81,7 @@ public:
         Coordinator < Time, Scheduler, GraphManager >::_tn =
             _event_table.get_current_time();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -87,6 +90,7 @@ public:
             << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
@@ -103,6 +107,7 @@ public:
     void output(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -112,22 +117,26 @@ public:
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         // assert(t == Coordinator < Time, Scheduler, GraphManager >::_tn);
 
         common::Models < Time > IMM = _event_table.get_current_models(t);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::OUTPUT)
             << ": IMM = " << IMM.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         for (auto & model : IMM) {
             model->output(t);
         }
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -137,6 +146,7 @@ public:
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -154,6 +164,7 @@ public:
     typename Time::type transition(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -163,6 +174,7 @@ public:
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         // assert(t >= Coordinator < Time, Scheduler, GraphManager >::_tl and t <= Coordinator < Time, Scheduler, GraphManager >::_tn);
 
@@ -170,22 +182,33 @@ public:
 
         add_models_with_inputs(receivers);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::S_MESSAGE)
             << ": receivers = " << receivers.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         for (auto & model : receivers) {
-            _event_table.put(model->transition(t), model);
+            typename Time::type previous_tn  = model->get_tn();
+            typename Time::type tn = model->transition(t);
+
+            if (previous_tn < tn) {
+                _event_table.put_increase(tn, model);
+            } else if (previous_tn > tn) {
+                _event_table.put_decrease(tn, model);
+            }
         }
+
         update_event_table(t);
         Coordinator < Time, Scheduler, GraphManager >::_tl = t;
         Coordinator < Time, Scheduler, GraphManager >::_tn =
             _event_table.get_current_time();
         Coordinator < Time, Scheduler, GraphManager >::clear_bag();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -195,6 +218,7 @@ public:
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
@@ -203,12 +227,14 @@ public:
                     const common::ExternalEvent < Time >& event)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::POST_EVENT)
             << ": BEFORE => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         Coordinator < Time, Scheduler, GraphManager >::add_event(event);
         _graph_manager.post_event(t, event);
@@ -216,12 +242,14 @@ public:
         Coordinator < Time, Scheduler, GraphManager >::_tn =
             _event_table.get_current_time();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::POST_EVENT)
             << ": AFTER => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -232,6 +260,7 @@ public:
                                         typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -241,9 +270,14 @@ public:
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; bag = " << bag.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         _graph_manager.dispatch_events(bag, t);
+        update_event_table(t);
+        Coordinator < Time, Scheduler, GraphManager >::_tn =
+            _event_table.get_current_time();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
@@ -252,6 +286,7 @@ public:
             << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
             << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
@@ -279,7 +314,7 @@ public:
     {
         for (auto & model : _graph_manager.children()) {
             if (model->event_number() > 0) {
-                _event_table.put(t, model);
+                _event_table.put_decrease(t, model);
             }
         }
     }

+ 20 - 0
src/pdevs/Simulator.hpp

@@ -54,6 +54,7 @@ public :
     typename Time::type start(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -62,11 +63,13 @@ public :
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         Simulator < Time, Dynamics >::_tl = t;
         Simulator < Time, Dynamics >::_tn =
             Simulator < Time, Dynamics >::_tl + _dynamics.start(t);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -75,6 +78,7 @@ public :
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Simulator < Time, Dynamics >::_tn;
     }
@@ -93,12 +97,14 @@ public :
     void output(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::OUTPUT)
             << ": BEFORE";
         common::Trace < Time >::trace().flush();
+#endif
 
         if(t == Simulator < Time, Dynamics >::_tn) {
             common::Bag < Time > bag = _dynamics.lambda(t);
@@ -113,12 +119,14 @@ public :
             }
         }
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::OUTPUT)
             << ": AFTER";
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -126,21 +134,29 @@ public :
                     const common::ExternalEvent < Time >& event)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::POST_EVENT)
             << ": BEFORE => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
         Simulator < Time, Dynamics >::add_event(event);
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
                 common::POST_EVENT)
             << ": AFTER => " << event.to_string();
         common::Trace < Time >::trace().flush();
+#endif
 
     }
 
@@ -159,6 +175,7 @@ public :
     typename Time::type transition(typename Time::type t)
     {
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -167,6 +184,7 @@ public :
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         // assert(Simulator < Time, Dynamics >::_tl <= t and t <= Simulator < Time, Dynamics >::_tn);
 
@@ -185,6 +203,7 @@ public :
         Simulator < Time, Dynamics >::_tl = t;
         Simulator < Time, Dynamics >::clear_bag();
 
+#ifdef WITH_TRACE
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
                 Simulator < Time, Dynamics >::get_name(), t,
@@ -193,6 +212,7 @@ public :
             << "tl = " << Simulator < Time, Dynamics >::_tl
             << " ; tn = " << Simulator < Time, Dynamics >::_tn;
         common::Trace < Time >::trace().flush();
+#endif
 
         return Simulator < Time, Dynamics >::_tn;
     }

+ 168 - 9
src/tests/mixed_tests.hpp

@@ -65,10 +65,16 @@ public:
     void dint(typename MyTime::type t)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace() <<
             common::TraceElement < MyTime >(get_name(), t,
                                             common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         if (_phase == SEND) {
             _phase = WAIT;
@@ -79,11 +85,18 @@ public:
               const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_EXT)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         _phase = SEND;
     }
@@ -92,32 +105,49 @@ public:
                const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_CONF)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
-
+#endif
     }
 
     typename MyTime::type start(typename MyTime::type t)
     {
-        common::Trace < MyTime >::trace()
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
+   common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::START);
         common::Trace < MyTime >::trace().flush();
-
+#endif
         _phase = WAIT;
         return 0;
     }
 
     typename MyTime::type ta(typename MyTime::type t) const
     {
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::TA);
         common::Trace < MyTime >::trace().flush();
-
+#endif
         if (_phase == WAIT) {
             return 1;
         } else {
@@ -127,15 +157,22 @@ public:
 
     common::Bag < MyTime > lambda(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
         common::Bag < MyTime > msgs;
 
         msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::LAMBDA)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return msgs;
     }
@@ -157,10 +194,16 @@ public:
     void dint(typename MyTime::type t)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         if (_phase == SEND) {
             _phase = WAIT;
@@ -171,11 +214,18 @@ public:
               const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_EXT)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         _phase = SEND;
     }
@@ -184,21 +234,34 @@ public:
                const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+   (void)t;
+   (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_CONF)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
     }
 
     typename MyTime::type start(typename MyTime::type t)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::START);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         _phase = WAIT;
         return std::numeric_limits < double >::max();
@@ -206,10 +269,17 @@ public:
 
     typename MyTime::type ta(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::TA);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         if (_phase == WAIT) {
             return std::numeric_limits < double >::max();
@@ -220,15 +290,21 @@ public:
 
     common::Bag < MyTime > lambda(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
         common::Bag < MyTime > msgs;
 
         msgs.push_back(common::ExternalEvent < MyTime >("out", t));
 
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::LAMBDA)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return msgs;
     }
@@ -249,34 +325,56 @@ public:
 
     void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
     {
+
+#ifndef WITH_TRACE
+        (void)x;
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_INT)
             << "x = " << x.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
+
     }
 
     typename MyTime::type start(typename MyTime::type t)
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::START);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return 0;
     }
 
     common::Bag < MyTime > lambda(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
         common::Bag < MyTime > msgs;
 
         msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::LAMBDA)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return msgs;
     }
@@ -292,35 +390,56 @@ public:
 
     void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
     {
+
+#ifndef WITH_TRACE
+        (void)x;
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_INT)
             << "x = " << x.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
+
     }
 
     typename MyTime::type start(typename MyTime::type t)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::START);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return 0;
     }
 
     common::Bag < MyTime > lambda(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
         common::Bag < MyTime > msgs;
 
         msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::LAMBDA)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return msgs;
     }
@@ -337,10 +456,16 @@ public:
     void dint(typename MyTime::type t)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace() <<
             common::TraceElement < MyTime >(get_name(), t,
                                             common::DELTA_INT);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         if (_phase == SEND) {
             _phase = WAIT;
@@ -351,11 +476,18 @@ public:
               const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_EXT)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         _phase = SEND;
     }
@@ -364,20 +496,34 @@ public:
                const common::Bag < MyTime >& msgs)
     {
 
+#ifndef WITH_TRACE
+        (void)t;
+        (void)msgs;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::DELTA_CONF)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
     }
 
     typename MyTime::type start(typename MyTime::type t)
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::START);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         _phase = WAIT;
         return 0;
@@ -385,10 +531,17 @@ public:
 
     typename MyTime::type ta(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
+
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::TA);
         common::Trace < MyTime >::trace().flush();
+#endif
 
         if (_phase == WAIT) {
             return (rand() % 100) / 10.;
@@ -399,15 +552,21 @@ public:
 
     common::Bag < MyTime > lambda(typename MyTime::type t) const
     {
+
+#ifndef WITH_TRACE
+        (void)t;
+#endif
         common::Bag < MyTime > msgs;
 
         msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
 
+#ifdef WITH_TRACE
         common::Trace < MyTime >::trace()
             << common::TraceElement < MyTime >(get_name(), t,
                                                common::LAMBDA)
             << "messages = " << msgs.to_string();
         common::Trace < MyTime >::trace().flush();
+#endif
 
         return msgs;
     }
@@ -553,16 +712,16 @@ public:
     Linear2GraphManager(common::Coordinator < MyTime >* coordinator) :
         pdevs::GraphManager < MyTime >(coordinator)
     {
-        for (unsigned int i = 1; i <= 50; ++i) {
+        for (unsigned int i = 1; i <= 100; ++i) {
             std::ostringstream ss;
 
             ss << "a" << i;
             _models.push_back(new pdevs::Simulator < MyTime, Beep >(ss.str()));
         }
-        for (unsigned int i = 0; i < 50; ++i) {
+        for (unsigned int i = 0; i < 100; ++i) {
             add_child(_models[i]);
         }
-        for (unsigned int i = 0; i < 49; ++i) {
+        for (unsigned int i = 0; i < 99; ++i) {
             add_link(_models[i], "out", _models[i + 1], "in");
         }
         add_link(coordinator, "in", _models[0], "in");
@@ -571,7 +730,7 @@ public:
 
     virtual ~Linear2GraphManager()
     {
-        for (unsigned int i = 0; i < 50; ++i) {
+        for (unsigned int i = 0; i < 100; ++i) {
             delete _models[i];
         }
     }
@@ -617,7 +776,7 @@ public:
     {
         add_child(&S1);
         add_child(&S2);
-        add_link(&S1, "out", &S2, "in");
+        // add_link(&S1, "out", &S2, "in");
     }
 
     virtual ~Root3GraphManager()