Ver código fonte

Add new scheduler based on boost::heap

Eric Ramat 11 anos atrás
pai
commit
c79179f1ed

+ 1 - 1
src/apps/CMakeLists.txt

@@ -10,7 +10,7 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIRS}
   ${Boost_LIBRARY_DIRS})
 
-ADD_EXECUTABLE(paradevs main.cpp)
+ADD_EXECUTABLE(paradevs main.cpp ../tests/mixed_tests.hpp)
 SET_TARGET_PROPERTIES(paradevs PROPERTIES ${PARADEVS_APP_PROPERTIES})
 
 TARGET_LINK_LIBRARIES(paradevs

+ 38 - 0
src/apps/main.cpp

@@ -24,7 +24,45 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <common/RootCoordinator.hpp>
+#include <common/scheduler/VectorScheduler.hpp>
+#include <common/scheduler/HeapScheduler.hpp>
+
+#include <tests/mixed_tests.hpp>
+
+void run_with_heap()
+{
+    paradevs::common::RootCoordinator <
+        paradevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::MyTime,
+            paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
+            paradevs::RootGraphManager >
+        > rc(0, 10000, "root", paradevs::pdevs::Parameters());
+
+    paradevs::common::Trace < paradevs::MyTime >::trace().clear();
+    rc.run();
+}
+
+void run_with_vector()
+{
+    paradevs::common::RootCoordinator <
+        paradevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::MyTime,
+            paradevs::common::scheduler::VectorScheduler < paradevs::MyTime >,
+            paradevs::RootGraphManager >
+        > rc(0, 10000, "root", paradevs::pdevs::Parameters());
+
+    paradevs::common::Trace < paradevs::MyTime >::trace().clear();
+    rc.run();
+}
+
 int main()
 {
+    std::cout << "run_with_heap ..." << std::endl;
+    run_with_heap();
+    std::cout << "... OK" << std::endl;
+    std::cout << "run_with_vector ..." << std::endl;
+    run_with_vector();
+    std::cout << "... OK" << std::endl;
     return 0;
 }

+ 7 - 4
src/common/CMakeLists.txt

@@ -7,9 +7,12 @@ INCLUDE_DIRECTORIES(
 
 LINK_DIRECTORIES(
   ${GLIBMM_LIBRARY_DIRS}
-  ${LIBXML_LIBRARY_DIR})
+  ${LIBXML_LIBRARY_DIR}
+  ${Boost_LIBRARY_DIRS})
 
-SET(COMMON_HPP Bag.hpp EventTable.hpp ExternalEvent.hpp
-  InternalEvent.hpp Links.hpp Node.hpp RootCoordinator.hpp Time.hpp Trace.hpp)
+SET(COMMON_HPP Bag.hpp ExternalEvent.hpp InternalEvent.hpp Links.hpp Node.hpp
+  RootCoordinator.hpp Scheduler.hpp Time.hpp Trace.hpp)
 
-INSTALL(FILES ${COMMON_HPP} DESTINATION ${PARADEVS_INCLUDE_DIRS}/common)
+INSTALL(FILES ${COMMON_HPP} DESTINATION ${PARADEVS_INCLUDE_DIRS}/common)
+
+ADD_SUBDIRECTORY(scheduler)

+ 21 - 1
src/common/InternalEvent.hpp

@@ -29,8 +29,13 @@
 
 #include <common/Model.hpp>
 
+#include <functional>
+
 namespace paradevs { namespace common {
 
+template < class Time >
+class Model;
+
 template < class Time >
 class InternalEvent
 {
@@ -50,7 +55,12 @@ public:
 
     bool operator<(InternalEvent const &e) const
     {
-        return e._time < _time;
+        return _time < e._time;
+    }
+
+    bool operator==(InternalEvent const &e) const
+    {
+        return _time == e._time;
     }
 
 private:
@@ -58,6 +68,16 @@ private:
     Model < Time >*     _model;
 };
 
+template < typename Event >
+struct EventCompare
+    : std::binary_function < Event, Event, bool >
+{
+    bool operator()(const Event &left, const Event &right) const
+    {
+        return left.get_time() > right.get_time();
+    }
+};
+
 } } // namespace paradevs common
 
 #endif

+ 34 - 0
src/common/Model.hpp

@@ -29,6 +29,9 @@
 
 #include <common/Bag.hpp>
 #include <common/ExternalEvent.hpp>
+#include <common/InternalEvent.hpp>
+
+#include <boost/heap/fibonacci_heap.hpp>
 
 #include <iostream>
 #include <sstream>
@@ -36,9 +39,15 @@
 
 namespace paradevs { namespace common {
 
+template < class Time >
+struct EventCompare;
+
 template < class Time >
 class ExternalEvent;
 
+template < class Time >
+class InternalEvent;
+
 template < class Time >
 class Bag;
 
@@ -103,6 +112,26 @@ public:
     Model < Time >* get_parent() const
     { return _parent; }
 
+    typename Time::type get_tl() const
+    { return _tl; }
+
+    typename Time::type get_tn() const
+    { return _tn; }
+
+    void heap_id(typename boost::heap::fibonacci_heap <
+                     InternalEvent < Time >,
+                     boost::heap::compare <
+                         EventCompare < InternalEvent <
+                             Time > > > >::handle_type id)
+    { _heap_id = id; }
+
+    typename boost::heap::fibonacci_heap <
+        InternalEvent < Time >,
+        boost::heap::compare <
+            EventCompare < InternalEvent <
+                               Time > > > >::handle_type heap_id()
+                               { return _heap_id; }
+
     void set_parent(Model < Time >* parent)
     { _parent = parent; }
 
@@ -114,6 +143,11 @@ private :
     Model < Time >*     _parent;
     std::string         _name;
     Bag < Time >*       _inputs;
+    typename boost::heap::fibonacci_heap <
+        InternalEvent < Time >,
+        boost::heap::compare <
+            EventCompare < InternalEvent <
+                               Time > > > >::handle_type _heap_id;
 };
 
 template < class Time >

+ 16 - 0
src/common/scheduler/CMakeLists.txt

@@ -0,0 +1,16 @@
+INCLUDE_DIRECTORIES(
+  ${PARADEVS_BINARY_DIR}/src
+  ${PARADEVS_SOURCE_DIR}/src
+  ${Boost_INCLUDE_DIRS}
+  ${GLIBMM_INCLUDE_DIRS}
+  ${LIBXML_INCLUDE_DIRS})
+
+LINK_DIRECTORIES(
+  ${GLIBMM_LIBRARY_DIRS}
+  ${LIBXML_LIBRARY_DIR}
+  ${Boost_LIBRARY_DIRS})
+
+SET(COMMON_SCHEDULER_HPP HeapScheduler.hpp VectorScheduler.hpp)
+
+INSTALL(FILES ${COMMON_SCHEDULER_HPP} DESTINATION
+  ${PARADEVS_INCLUDE_DIRS}/common/scheduler)

+ 116 - 0
src/common/scheduler/HeapScheduler.hpp

@@ -0,0 +1,116 @@
+/**
+ * @file HeapScheduler.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef COMMON_SCHEDULER_HEAP_SCHEDULER_HPP
+#define COMMON_SCHEDULER_HEAP_SCHEDULER_HPP 1
+
+#include <common/InternalEvent.hpp>
+
+#include <boost/heap/fibonacci_heap.hpp>
+
+#include <sstream>
+
+namespace paradevs { namespace common { namespace scheduler {
+
+template < typename Time >
+struct Heap
+{
+    typedef boost::heap::fibonacci_heap <
+        InternalEvent < Time >, boost::heap::compare <
+                       EventCompare < InternalEvent < Time > > > > Type;
+
+    typedef typename boost::heap::fibonacci_heap <
+        InternalEvent < Time >, boost::heap::compare <
+                       EventCompare < InternalEvent <
+                                          Time > > > >::handle_type Handle;
+};
+
+template < class Time >
+class HeapScheduler : public boost::heap::fibonacci_heap <
+    InternalEvent < Time >, boost::heap::compare <
+                                EventCompare < InternalEvent < Time > > > >
+{
+public:
+    HeapScheduler()
+    { }
+    virtual ~HeapScheduler()
+    { }
+
+    Model < Time >* get_current_model()
+    {
+        return HeapScheduler < Time >::top().get_model();
+    }
+
+    Models < Time > get_current_models(typename Time::type time) const
+    {
+        Models < Time > models;
+
+        for (typename HeapScheduler < Time >::ordered_iterator it =
+                 HeapScheduler < Time >::ordered_begin();
+             it != HeapScheduler < Time >::ordered_end() and
+                 it->get_time() == time; ++it) {
+            models.push_back(it->get_model());
+        }
+        return models;
+    }
+
+    typename Time::type get_current_time() const
+    {
+        return HeapScheduler < Time >::top().get_time();
+    }
+
+    void init(typename Time::type time, Model < Time >* model)
+    {
+        model->heap_id(HeapScheduler < Time >::push(
+                           InternalEvent < Time >(time, model)));
+    }
+
+    void put(typename Time::type time, Model < Time >* model)
+    {
+        HeapScheduler < Time >::erase(model->heap_id());
+        model->heap_id(HeapScheduler < Time >::push(
+                           InternalEvent < Time >(time, model)));
+    }
+
+    std::string to_string() const
+    {
+        std::stringstream ss;
+
+        ss << "Scheduler = { ";
+        for (typename HeapScheduler < Time >::ordered_iterator it =
+                 HeapScheduler < Time >::ordered_begin();
+             it != HeapScheduler < Time >::ordered_end(); ++it) {
+            ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
+               << ") ";
+        }
+        ss << "}";
+        return ss.str();
+    }
+};
+
+} } } // namespace paradevs common scheduler
+
+#endif

+ 31 - 31
src/common/EventTable.hpp

@@ -1,5 +1,5 @@
 /**
- * @file EventTable.hpp
+ * @file VectorScheduler.hpp
  * @author The PARADEVS Development Team
  * See the AUTHORS or Authors.txt file
  */
@@ -24,71 +24,71 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef COMMON_EVENT_TABLE
-#define COMMON_EVENT_TABLE 1
+#ifndef COMMON_SCHEDULER_VECTOR_SCHEDULER_HPP
+#define COMMON_SCHEDULER_VECTOR_SCHEDULER_HPP 1
 
 #include <common/InternalEvent.hpp>
 
 #include <algorithm>
 #include <sstream>
 
-namespace paradevs { namespace common {
+namespace paradevs { namespace common { namespace scheduler {
 
 template < class Time >
-class EventTable : protected std::vector < InternalEvent < Time > >
+class VectorScheduler : protected std::vector < InternalEvent < Time > >
 {
 public:
-    EventTable()
+    VectorScheduler()
     { }
-    virtual ~EventTable()
+    virtual ~VectorScheduler()
     { }
 
     Model < Time >* get_current_model()
     {
-        return EventTable < Time >::back().get_model();
+        return VectorScheduler < Time >::back().get_model();
     }
 
     Models < Time > get_current_models(typename Time::type time) const
     {
         Models < Time > models;
-        bool found = true;
 
-        for (typename EventTable < Time >::const_reverse_iterator it =
-                 EventTable < Time >::rbegin();
-             found and it != EventTable < Time >::rend(); ++it) {
-            if (it->get_time() == time) {
-                models.push_back(it->get_model());
-            } else {
-                found = false;
-            }
+        for (typename VectorScheduler < Time >::const_reverse_iterator it =
+                 VectorScheduler < Time >::rbegin();
+             it != VectorScheduler < Time >::rend() and it->get_time() == time;
+             ++it) {
+            models.push_back(it->get_model());
         }
         return models;
     }
 
     typename Time::type get_current_time() const
-    { return EventTable < Time >::back().get_time(); }
+    { return VectorScheduler < Time >::back().get_time(); }
 
     void init(typename Time::type time, Model < Time >* model)
     {
-        EventTable < Time >::push_back(InternalEvent < Time >(time, model));
-        std::sort(EventTable < Time >::begin(), EventTable < Time >::end());
+        VectorScheduler < Time >::push_back(
+            InternalEvent < Time >(time, model));
+        std::sort(VectorScheduler < Time >::begin(),
+                  VectorScheduler < Time >::end());
     }
 
     void put(typename Time::type time, Model < Time >* model)
     {
         remove(model);
-        EventTable < Time >::push_back(InternalEvent < Time >(time, model));
-        std::sort(EventTable < Time >::begin(), EventTable < Time >::end());
+        VectorScheduler < Time >::push_back(
+            InternalEvent < Time >(time, model));
+        std::sort(VectorScheduler < Time >::begin(),
+                  VectorScheduler < Time >::end());
     }
 
     std::string to_string() const
     {
         std::stringstream ss;
 
-        ss << "EventTable = { ";
-        for (typename EventTable < Time >::const_iterator it =
-                 EventTable < Time >::begin();
-             it != EventTable < Time >::end(); ++it) {
+        ss << "Scheduler = { ";
+        for (typename VectorScheduler < Time >::const_iterator it =
+                 VectorScheduler < Time >::begin();
+             it != VectorScheduler < Time >::end(); ++it) {
             ss << "(" << it->get_time() << " -> " << it->get_model()->get_name()
                << ") ";
         }
@@ -99,12 +99,12 @@ public:
 private:
     void remove(Model < Time >* model)
     {
-        typename EventTable < Time >::iterator jt =
-            EventTable < Time >::begin();
+        typename VectorScheduler < Time >::iterator jt =
+            VectorScheduler < Time >::begin();
 
-        while (jt != EventTable < Time >::end()) {
+        while (jt != VectorScheduler < Time >::end()) {
             if (jt->get_model() == model) {
-                jt = EventTable < Time >::erase(jt);
+                jt = VectorScheduler < Time >::erase(jt);
             } else {
                 ++jt;
             }
@@ -112,6 +112,6 @@ private:
     }
 };
 
-} } // namespace paradevs common
+} } } // namespace paradevs common scheduler
 
 #endif

+ 65 - 53
src/pdevs/Coordinator.hpp

@@ -28,7 +28,6 @@
 #define PDEVS_COORDINATOR 1
 
 #include <common/Coordinator.hpp>
-#include <common/EventTable.hpp>
 #include <common/Trace.hpp>
 
 #include <cassert>
@@ -43,7 +42,7 @@ public:
     { }
 };
 
-template < class Time, class GraphManager >
+template < class Time, class Scheduler, class GraphManager >
 class Coordinator : public common::Coordinator < Time >
 {
 public:
@@ -61,34 +60,35 @@ public:
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::I_MESSAGE)
             << ": BEFORE => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
 
         assert(_graph_manager.children().size() > 0);
 
         for (auto & child : _graph_manager.children()) {
             _event_table.init(child->start(
-                                  Coordinator < Time, GraphManager >::_tn),
+                                  Coordinator < Time, Scheduler,
+                                  GraphManager >::_tn),
                               child);
         }
-        Coordinator < Time, GraphManager >::_tl = t;
-        Coordinator < Time, GraphManager >::_tn =
+        Coordinator < Time, Scheduler, GraphManager >::_tl = t;
+        Coordinator < Time, Scheduler, GraphManager >::_tn =
             _event_table.get_current_time();
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::I_MESSAGE)
             << ": AFTER => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
 
-        return Coordinator < Time, GraphManager >::_tn;
+        return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
 
 /**************************************************
@@ -105,21 +105,21 @@ public:
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::OUTPUT)
             << ": BEFORE => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
 
-        // assert(t == Coordinator < Time, GraphManager >::_tn);
+        // assert(t == Coordinator < Time, Scheduler, GraphManager >::_tn);
 
         common::Models < Time > IMM = _event_table.get_current_models(t);
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::OUTPUT)
             << ": IMM = " << IMM.to_string();
         common::Trace < Time >::trace().flush();
@@ -130,11 +130,11 @@ public:
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::OUTPUT)
             << ": AFTER => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
 
@@ -156,15 +156,15 @@ public:
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::S_MESSAGE)
             << ": BEFORE => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
 
-        // assert(t >= Coordinator < Time, GraphManager >::_tl and t <= Coordinator < Time, GraphManager >::_tn);
+        // assert(t >= Coordinator < Time, Scheduler, GraphManager >::_tl and t <= Coordinator < Time, Scheduler, GraphManager >::_tn);
 
         common::Models < Time > receivers = _event_table.get_current_models(t);
 
@@ -172,7 +172,7 @@ public:
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::S_MESSAGE)
             << ": receivers = " << receivers.to_string();
         common::Trace < Time >::trace().flush();
@@ -181,41 +181,46 @@ public:
             _event_table.put(model->transition(t), model);
         }
         update_event_table(t);
-        Coordinator < Time, GraphManager >::_tl = t;
-        Coordinator < Time, GraphManager >::_tn =
+        Coordinator < Time, Scheduler, GraphManager >::_tl = t;
+        Coordinator < Time, Scheduler, GraphManager >::_tn =
             _event_table.get_current_time();
-        Coordinator < Time, GraphManager >::clear_bag();
+        Coordinator < Time, Scheduler, GraphManager >::clear_bag();
 
         common::Trace < Time >::trace()
             << common::TraceElement < Time >(
-                Coordinator < Time, GraphManager >::get_name(), t,
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
                 common::S_MESSAGE)
             << ": AFTER => "
-            << "tl = " << Coordinator < Time, GraphManager >::_tl
-            << " ; tn = " << Coordinator < Time, GraphManager >::_tn
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
             << " ; scheduler = " << _event_table.to_string();
         common::Trace < Time >::trace().flush();
 
-        return Coordinator < Time, GraphManager >::_tn;
+        return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
 
     void post_event(typename Time::type t,
                     const common::ExternalEvent < Time >& event)
     {
 
-        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": BEFORE => " << event.to_string();
+        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();
 
-        Coordinator < Time, GraphManager >::add_event(event);
+        Coordinator < Time, Scheduler, GraphManager >::add_event(event);
         _graph_manager.post_event(t, event);
         update_event_table(t);
-        Coordinator < Time, GraphManager >::_tn = _event_table.get_current_time();
+        Coordinator < Time, Scheduler, GraphManager >::_tn =
+            _event_table.get_current_time();
 
-        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
-                                                       common::POST_EVENT)
-                               << ": AFTER => " << event.to_string();
+        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();
 
     }
@@ -223,25 +228,32 @@ public:
 /*******************************************************************
  * when y-message(y_d, t) with output y_d from d
  *******************************************************************/
-    typename Time::type dispatch_events(common::Bag < Time > bag, typename Time::type t)
+    typename Time::type dispatch_events(common::Bag < Time > bag,
+                                        typename Time::type t)
     {
 
-        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
-                                                       common::Y_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << Coordinator < Time, GraphManager >::_tl << " ; tn = " << Coordinator < Time, GraphManager >::_tn
-                               << " ; bag = " << bag.to_string();
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
+                common::Y_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn
+            << " ; bag = " << bag.to_string();
         common::Trace < Time >::trace().flush();
 
         _graph_manager.dispatch_events(bag, t);
 
-        common::Trace < Time >::trace() << common::TraceElement < Time >(Coordinator < Time, GraphManager >::get_name(), t,
-                                                       common::Y_MESSAGE)
-                               << ": BEFORE => "
-                               << "tl = " << Coordinator < Time, GraphManager >::_tl << " ; tn = " << Coordinator < Time, GraphManager >::_tn;
+        common::Trace < Time >::trace()
+            << common::TraceElement < Time >(
+                Coordinator < Time, Scheduler, GraphManager >::get_name(), t,
+                common::Y_MESSAGE)
+            << ": BEFORE => "
+            << "tl = " << Coordinator < Time, Scheduler, GraphManager >::_tl
+            << " ; tn = " << Coordinator < Time, Scheduler, GraphManager >::_tn;
         common::Trace < Time >::trace().flush();
 
-        return Coordinator < Time, GraphManager >::_tn;
+        return Coordinator < Time, Scheduler, GraphManager >::_tn;
     }
 
     void observation(std::ostream& file) const
@@ -273,8 +285,8 @@ public:
     }
 
 private:
-    GraphManager                _graph_manager;
-    common::EventTable < Time > _event_table;
+    GraphManager _graph_manager;
+    Scheduler    _event_table;
 };
 
 } } // namespace paradevs pdevs

+ 7 - 10
src/tests/CMakeLists.txt

@@ -10,15 +10,14 @@ LINK_DIRECTORIES(
   ${LIBXML_LIBRARY_DIR})
 
 # pdevs tests
-ADD_EXECUTABLE(pdevs-tests ${COMMON_HPP} ${PDEVS_HPP} pdevs_tests.hpp
-  pdevs_tests.cpp)
+ADD_EXECUTABLE(pdevs-tests ${COMMON_HPP} ${COMMON_SCHEDULER_HPP} ${PDEVS_HPP}
+  pdevs_tests.hpp pdevs_tests.cpp)
 SET_TARGET_PROPERTIES(pdevs-tests PROPERTIES ${PARADEVS_APP_PROPERTIES})
 
 TARGET_LINK_LIBRARIES(pdevs-tests
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}
-  ${GTHREAD_LIBRARIES}
-  ${Boost_FILESYSTEM_LIBRARY})
+  ${GTHREAD_LIBRARIES})
 
 # dtss tests
 ADD_EXECUTABLE(dtss-tests ${COMMON_HPP} ${DTSS_HPP} dtss_tests.hpp
@@ -28,16 +27,14 @@ SET_TARGET_PROPERTIES(dtss-tests PROPERTIES ${PARADEVS_APP_PROPERTIES})
 TARGET_LINK_LIBRARIES(dtss-tests
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}
-  ${GTHREAD_LIBRARIES}
-  ${Boost_FILESYSTEM_LIBRARY})
+  ${GTHREAD_LIBRARIES})
 
 # mixed tests
-ADD_EXECUTABLE(mixed-tests ${COMMON_HPP} ${DTSS_HPP} ${PDEVS_HPP}
-  mixed_tests.hpp mixed_tests.cpp)
+ADD_EXECUTABLE(mixed-tests ${COMMON_HPP} ${COMMON_SCHEDULER_HPP} ${DTSS_HPP}
+  ${PDEVS_HPP} mixed_tests.hpp mixed_tests.cpp)
 SET_TARGET_PROPERTIES(mixed-tests PROPERTIES ${PARADEVS_APP_PROPERTIES})
 
 TARGET_LINK_LIBRARIES(mixed-tests
   ${GLIBMM_LIBRARIES}
   ${LIBXML_LIBRARIES}
-  ${GTHREAD_LIBRARIES}
-  ${Boost_FILESYSTEM_LIBRARY})
+  ${GTHREAD_LIBRARIES})

+ 4 - 337
src/tests/mixed_tests.cpp

@@ -26,349 +26,16 @@
 
 #include <tests/mixed_tests.hpp>
 
-#include <common/RootCoordinator.hpp>
-#include <common/Trace.hpp>
-
-#include <dtss/Coordinator.hpp>
-#include <dtss/GraphManager.hpp>
-#include <dtss/Simulator.hpp>
-
-#include <pdevs/Coordinator.hpp>
-#include <pdevs/GraphManager.hpp>
-#include <pdevs/Simulator.hpp>
-
 #define CATCH_CONFIG_MAIN
 #include "catch.hpp"
 
-namespace paradevs {
-
-void A1::dint(typename MyTime::type t)
-{
-
-    common::Trace < MyTime >::trace() <<
-        common::TraceElement < MyTime >(get_name(), t,
-                                        common::DELTA_INT);
-    common::Trace < MyTime >::trace().flush();
-
-    if (_phase == SEND) {
-        _phase = WAIT;
-    }
-}
-
-void A1::dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_EXT)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    _phase = SEND;
-}
-
-void A1::dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_CONF)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-}
-
-typename MyTime::type A1::start(typename MyTime::type t)
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::START);
-    common::Trace < MyTime >::trace().flush();
-
-    _phase = WAIT;
-    return 0;
-}
-
-typename MyTime::type A1::ta(typename MyTime::type t) const
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::TA);
-    common::Trace < MyTime >::trace().flush();
-
-    if (_phase == WAIT) {
-        return 1;
-    } else {
-        return 0;
-    }
-}
-
-common::Bag < MyTime > A1::lambda(typename MyTime::type t) const
-{
-    common::Bag < MyTime > msgs;
-
-    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::LAMBDA)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    return msgs;
-}
-
-void B1::dint(typename MyTime::type t)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_INT);
-    common::Trace < MyTime >::trace().flush();
-
-    if (_phase == SEND) {
-        _phase = WAIT;
-    }
-}
-
-void B1::dext(typename MyTime::type t, typename MyTime::type /* e */,
-              const common::Bag < MyTime >& msgs)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_EXT)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    _phase = SEND;
-}
-
-void B1::dconf(typename MyTime::type t, typename MyTime::type /* e */,
-               const common::Bag < MyTime >& msgs)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_CONF)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-}
-
-typename MyTime::type B1::start(typename MyTime::type t)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::START);
-    common::Trace < MyTime >::trace().flush();
-
-    _phase = WAIT;
-    return std::numeric_limits < double >::max();
-}
-
-typename MyTime::type B1::ta(typename MyTime::type t) const
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::TA);
-    common::Trace < MyTime >::trace().flush();
-
-    if (_phase == WAIT) {
-        return std::numeric_limits < double >::max();
-    } else {
-        return 0;
-    }
-}
-
-common::Bag < MyTime > B1::lambda(typename MyTime::type t) const
-{
-    common::Bag < MyTime > msgs;
-
-    msgs.push_back(common::ExternalEvent < MyTime >("out", t));
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::LAMBDA)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    return msgs;
-}
-
-void A2::transition(const common::Bag < MyTime >& x, typename MyTime::type t)
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::DELTA_INT)
-        << "x = " << x.to_string();
-    common::Trace < MyTime >::trace().flush();
-}
-
-typename MyTime::type A2::start(typename MyTime::type t)
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::START);
-    common::Trace < MyTime >::trace().flush();
-
-    return 0;
-}
-
-common::Bag < MyTime > A2::lambda(typename MyTime::type t) const
-{
-    common::Bag < MyTime > msgs;
-
-    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::LAMBDA)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    return msgs;
-}
-
-void B2::transition(const common::Bag < MyTime >& x, typename MyTime::type t)
-{
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                                   common::DELTA_INT)
-                           << "x = " << x.to_string();
-    common::Trace < MyTime >::trace().flush();
-}
-
-typename MyTime::type B2::start(typename MyTime::type t)
-{
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::START);
-    common::Trace < MyTime >::trace().flush();
-
-    return 0;
-}
-
-common::Bag < MyTime > B2::lambda(typename MyTime::type t) const
-{
-    common::Bag < MyTime > msgs;
-
-    msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
-
-    common::Trace < MyTime >::trace()
-        << common::TraceElement < MyTime >(get_name(), t,
-                                           common::LAMBDA)
-        << "messages = " << msgs.to_string();
-    common::Trace < MyTime >::trace().flush();
-
-    return msgs;
-}
-
-struct LastBagPolicy
-{
-    const common::Bag < MyTime >& bag() const
-    { return _bag; }
-
-    virtual void operator()(typename MyTime::type /* t */,
-                            const common::ExternalEvent < MyTime >& event,
-                            typename MyTime::type /* tl */,
-                            typename MyTime::type /* tn */)
-    {
-        _bag.clear();
-        _bag.push_back(event);
-    }
-
-private:
-    common::Bag < MyTime > _bag;
-};
-
-struct IgnorePolicy
-{
-    const common::Bag < MyTime >& bag() const
-    { return _bag; }
-
-    virtual void operator()(typename MyTime::type /* t */,
-                            const common::ExternalEvent < MyTime >& /* event */,
-                            typename MyTime::type /* tl */,
-                            typename MyTime::type /* tn */)
-    { }
-
-private:
-    common::Bag < MyTime > _bag;
-};
-
-class S1GraphManager : public pdevs::GraphManager < MyTime >
-{
-public:
-    S1GraphManager(common::Coordinator < MyTime >* coordinator) :
-        pdevs::GraphManager < MyTime >(coordinator), a("a1"), b("b1")
-    {
-        add_child(&a);
-        add_child(&b);
-        add_link(&a, "out", &b, "in");
-        add_link(&b, "out", coordinator, "out");
-    }
-
-    virtual ~S1GraphManager()
-    { }
-
-private:
-    pdevs::Simulator < MyTime, A1 > a;
-    pdevs::Simulator < MyTime, B1 > b;
-};
-
-class S2GraphManager : public dtss::GraphManager < MyTime >
-{
-public:
-    S2GraphManager(common::Coordinator < MyTime >* coordinator) :
-        dtss::GraphManager < MyTime >(coordinator), a("a2", 20), b("b2", 20)
-    {
-        add_child(&a);
-        add_child(&b);
-        add_link(&a, "out", &b, "in");
-        add_link(coordinator, "in", &a, "in");
-    }
-
-    virtual ~S2GraphManager()
-    { }
-
-private:
-    dtss::Simulator < MyTime, A2 > a;
-    dtss::Simulator < MyTime, B2 > b;
-};
-
-class RootGraphManager : public pdevs::GraphManager < MyTime >
-{
-public:
-    RootGraphManager(common::Coordinator < MyTime >* coordinator) :
-        pdevs::GraphManager < MyTime >(coordinator),
-        S1("S1", paradevs::pdevs::Parameters()),
-        S2("S2", paradevs::dtss::Parameters < MyTime >(20))
-    {
-        add_child(&S1);
-        add_child(&S2);
-        add_link(&S1, "out", &S2, "in");
-    }
-
-    virtual ~RootGraphManager()
-    { }
-
-private:
-    pdevs::Coordinator < MyTime, S1GraphManager > S1;
-    dtss::Coordinator < MyTime, LastBagPolicy, S2GraphManager > S2;
-};
-
-} // namespace paradevs
-
 TEST_CASE("mixed/hierachical", "run")
 {
     paradevs::common::RootCoordinator <
-        paradevs::MyTime,  paradevs::pdevs::Coordinator <
-            paradevs::MyTime, paradevs::RootGraphManager >
+        paradevs::MyTime, paradevs::pdevs::Coordinator <
+            paradevs::MyTime,
+            paradevs::common::scheduler::HeapScheduler < paradevs::MyTime >,
+            paradevs::RootGraphManager >
         > rc(0, 100, "root", paradevs::pdevs::Parameters());
 
     paradevs::common::Trace < paradevs::MyTime >::trace().clear();

+ 329 - 28
src/tests/mixed_tests.hpp

@@ -24,11 +24,21 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <common/RootCoordinator.hpp>
+#include <common/scheduler/VectorScheduler.hpp>
+#include <common/scheduler/HeapScheduler.hpp>
 #include <common/Time.hpp>
+#include <common/Trace.hpp>
 
+#include <dtss/Coordinator.hpp>
 #include <dtss/Dynamics.hpp>
+#include <dtss/GraphManager.hpp>
+#include <dtss/Simulator.hpp>
 
+#include <pdevs/Coordinator.hpp>
 #include <pdevs/Dynamics.hpp>
+#include <pdevs/GraphManager.hpp>
+#include <pdevs/Simulator.hpp>
 
 namespace paradevs {
 
@@ -52,16 +62,83 @@ public:
     virtual ~A1()
     { }
 
-    virtual void dint(typename MyTime::type /* t */);
-    virtual void dext(typename MyTime::type /* t */,
-                      typename MyTime::type /* e */,
-                      const common::Bag < MyTime >& /* msgs */);
-    virtual void dconf(typename MyTime::type /* t */,
-                       typename MyTime::type /* e */,
-                       const common::Bag < MyTime >& /* msgs */);
-    virtual typename MyTime::type start(typename MyTime::type /* t */);
-    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
-    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
+    void dint(typename MyTime::type t)
+    {
+
+        common::Trace < MyTime >::trace() <<
+            common::TraceElement < MyTime >(get_name(), t,
+                                            common::DELTA_INT);
+        common::Trace < MyTime >::trace().flush();
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        _phase = SEND;
+    }
+
+    void dconf(typename MyTime::type t, typename MyTime::type /* e */,
+               const common::Bag < MyTime >& msgs)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+    }
+
+    typename MyTime::type start(typename MyTime::type t)
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::START);
+        common::Trace < MyTime >::trace().flush();
+
+        _phase = WAIT;
+        return 0;
+    }
+
+    typename MyTime::type ta(typename MyTime::type t) const
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::TA);
+        common::Trace < MyTime >::trace().flush();
+
+        if (_phase == WAIT) {
+            return 1;
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    {
+        common::Bag < MyTime > msgs;
+
+        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        return msgs;
+    }
 
 private:
     enum Phase { WAIT, SEND };
@@ -77,16 +154,84 @@ public:
     virtual ~B1()
     { }
 
-    virtual void dint(typename MyTime::type /* t */);
-    virtual void dext(typename MyTime::type /* t */,
-                      typename MyTime::type /* e */,
-                      const common::Bag < MyTime >& /* msgs */);
-    virtual void dconf(typename MyTime::type /* t */,
-                       typename MyTime::type /* e */,
-                       const common::Bag < MyTime >& /* msgs */);
-    virtual typename MyTime::type start(typename MyTime::type /* t */);
-    virtual typename MyTime::type ta(typename MyTime::type /* t */) const;
-    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
+    void dint(typename MyTime::type t)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_INT);
+        common::Trace < MyTime >::trace().flush();
+
+        if (_phase == SEND) {
+            _phase = WAIT;
+        }
+    }
+
+    void dext(typename MyTime::type t, typename MyTime::type /* e */,
+              const common::Bag < MyTime >& msgs)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_EXT)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        _phase = SEND;
+    }
+
+    void dconf(typename MyTime::type t, typename MyTime::type /* e */,
+               const common::Bag < MyTime >& msgs)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_CONF)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+    }
+
+    typename MyTime::type start(typename MyTime::type t)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::START);
+        common::Trace < MyTime >::trace().flush();
+
+        _phase = WAIT;
+        return std::numeric_limits < double >::max();
+    }
+
+    typename MyTime::type ta(typename MyTime::type t) const
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::TA);
+        common::Trace < MyTime >::trace().flush();
+
+        if (_phase == WAIT) {
+            return std::numeric_limits < double >::max();
+        } else {
+            return 0;
+        }
+    }
+
+    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    {
+        common::Bag < MyTime > msgs;
+
+        msgs.push_back(common::ExternalEvent < MyTime >("out", t));
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        return msgs;
+    }
 
 private:
     enum Phase { WAIT, SEND };
@@ -102,10 +247,39 @@ public:
     virtual ~A2()
     { }
 
-    virtual void transition(const common::Bag < MyTime >& /* x */,
-                            typename MyTime::type /* t */);
-    virtual typename MyTime::type start(typename MyTime::type /* t */);
-    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
+    void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_INT)
+            << "x = " << x.to_string();
+        common::Trace < MyTime >::trace().flush();
+    }
+
+    typename MyTime::type start(typename MyTime::type t)
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::START);
+        common::Trace < MyTime >::trace().flush();
+
+        return 0;
+    }
+
+    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    {
+        common::Bag < MyTime > msgs;
+
+        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        return msgs;
+    }
 };
 
 class B2 : public paradevs::dtss::Dynamics < MyTime >
@@ -116,10 +290,137 @@ public:
     virtual ~B2()
     { }
 
-    virtual void transition(const common::Bag < MyTime >& /* x */,
-                            typename MyTime::type /* t */);
-    virtual typename MyTime::type start(typename MyTime::type /* t */);
-    virtual common::Bag < MyTime > lambda(typename MyTime::type /* t */) const;
+    void transition(const common::Bag < MyTime >& x, typename MyTime::type t)
+    {
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::DELTA_INT)
+            << "x = " << x.to_string();
+        common::Trace < MyTime >::trace().flush();
+    }
+
+    typename MyTime::type start(typename MyTime::type t)
+    {
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::START);
+        common::Trace < MyTime >::trace().flush();
+
+        return 0;
+    }
+
+    common::Bag < MyTime > lambda(typename MyTime::type t) const
+    {
+        common::Bag < MyTime > msgs;
+
+        msgs.push_back(common::ExternalEvent < MyTime >("out", 0.));
+
+        common::Trace < MyTime >::trace()
+            << common::TraceElement < MyTime >(get_name(), t,
+                                               common::LAMBDA)
+            << "messages = " << msgs.to_string();
+        common::Trace < MyTime >::trace().flush();
+
+        return msgs;
+    }
+};
+
+struct LastBagPolicy
+{
+    const common::Bag < MyTime >& bag() const
+    { return _bag; }
+
+    virtual void operator()(typename MyTime::type /* t */,
+                            const common::ExternalEvent < MyTime >& event,
+                            typename MyTime::type /* tl */,
+                            typename MyTime::type /* tn */)
+    {
+        _bag.clear();
+        _bag.push_back(event);
+    }
+
+private:
+    common::Bag < MyTime > _bag;
+};
+
+struct IgnorePolicy
+{
+    const common::Bag < MyTime >& bag() const
+    { return _bag; }
+
+    virtual void operator()(typename MyTime::type /* t */,
+                            const common::ExternalEvent < MyTime >& /* event */,
+                            typename MyTime::type /* tl */,
+                            typename MyTime::type /* tn */)
+    { }
+
+private:
+    common::Bag < MyTime > _bag;
+};
+
+class S1GraphManager : public pdevs::GraphManager < MyTime >
+{
+public:
+    S1GraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator), a("a1"), b("b1")
+    {
+        add_child(&a);
+        add_child(&b);
+        add_link(&a, "out", &b, "in");
+        add_link(&b, "out", coordinator, "out");
+    }
+
+    virtual ~S1GraphManager()
+    { }
+
+private:
+    pdevs::Simulator < MyTime, A1 > a;
+    pdevs::Simulator < MyTime, B1 > b;
+};
+
+class S2GraphManager : public dtss::GraphManager < MyTime >
+{
+public:
+    S2GraphManager(common::Coordinator < MyTime >* coordinator) :
+        dtss::GraphManager < MyTime >(coordinator), a("a2", 20), b("b2", 20)
+    {
+        add_child(&a);
+        add_child(&b);
+        add_link(&a, "out", &b, "in");
+        add_link(coordinator, "in", &a, "in");
+    }
+
+    virtual ~S2GraphManager()
+    { }
+
+private:
+    dtss::Simulator < MyTime, A2 > a;
+    dtss::Simulator < MyTime, B2 > b;
+};
+
+class RootGraphManager : public pdevs::GraphManager < MyTime >
+{
+public:
+    RootGraphManager(common::Coordinator < MyTime >* coordinator) :
+        pdevs::GraphManager < MyTime >(coordinator),
+        S1("S1", paradevs::pdevs::Parameters()),
+        S2("S2", paradevs::dtss::Parameters < MyTime >(20))
+    {
+        add_child(&S1);
+        add_child(&S2);
+        add_link(&S1, "out", &S2, "in");
+    }
+
+    virtual ~RootGraphManager()
+    { }
+
+private:
+    pdevs::Coordinator < MyTime,
+                         paradevs::common::scheduler::HeapScheduler <
+                             MyTime >,
+                         S1GraphManager > S1;
+    dtss::Coordinator < MyTime, LastBagPolicy, S2GraphManager > S2;
 };
 
 } // namespace paradevs

+ 17 - 5
src/tests/pdevs_tests.cpp

@@ -27,6 +27,7 @@
 #include <tests/pdevs_tests.hpp>
 
 #include <common/RootCoordinator.hpp>
+#include <common/scheduler/VectorScheduler.hpp>
 #include <common/Trace.hpp>
 
 #include <pdevs/Coordinator.hpp>
@@ -258,8 +259,10 @@ public:
     { }
 
 private:
-    Coordinator < MyTime, S1GraphManager > S1;
-    Coordinator < MyTime, S2GraphManager > S2;
+    Coordinator < MyTime, paradevs::common::scheduler::VectorScheduler <
+                              MyTime >, S1GraphManager > S1;
+    Coordinator < MyTime, paradevs::common::scheduler::VectorScheduler <
+                              MyTime >, S2GraphManager > S2;
 };
 
 class OnlyOneGraphManager : public pdevs::GraphManager < MyTime >
@@ -310,7 +313,10 @@ TEST_CASE("pdevs/only_one", "run")
 {
     paradevs::common::RootCoordinator <
         paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
-            paradevs::pdevs::MyTime, paradevs::pdevs::OnlyOneGraphManager >
+            paradevs::pdevs::MyTime,
+            paradevs::common::scheduler::VectorScheduler <
+                paradevs::pdevs::MyTime >,
+            paradevs::pdevs::OnlyOneGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
     paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();
@@ -348,7 +354,10 @@ TEST_CASE("pdevs/flat", "run")
 {
     paradevs::common::RootCoordinator <
         paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
-            paradevs::pdevs::MyTime, paradevs::pdevs::FlatGraphManager >
+            paradevs::pdevs::MyTime,
+            paradevs::common::scheduler::VectorScheduler <
+                paradevs::pdevs::MyTime >,
+            paradevs::pdevs::FlatGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
     paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();
@@ -456,7 +465,10 @@ TEST_CASE("pdevs/hierachical", "run")
 {
     paradevs::common::RootCoordinator <
         paradevs::pdevs::MyTime, paradevs::pdevs::Coordinator <
-            paradevs::pdevs::MyTime, paradevs::pdevs::RootGraphManager >
+            paradevs::pdevs::MyTime,
+            paradevs::common::scheduler::VectorScheduler <
+                paradevs::pdevs::MyTime >,
+            paradevs::pdevs::RootGraphManager >
         > rc(0, 10, "root", paradevs::pdevs::Parameters());
 
     paradevs::common::Trace < paradevs::pdevs::MyTime >::trace().clear();