Parcourir la source

Add new QSS: multiQSS

Eric Ramat il y a 4 ans
Parent
commit
439234f961
73 fichiers modifiés avec 2272 ajouts et 1057 suppressions
  1. 1 3
      AUTHORS
  2. 2 1
      src/apps/main.cpp
  3. 50 19
      src/artis-star/common/Any.hpp
  4. 10 5
      src/artis-star/common/Bag.hpp
  5. 30 15
      src/artis-star/common/Coordinator.hpp
  6. 34 17
      src/artis-star/common/ExternalEvent.hpp
  7. 26 13
      src/artis-star/common/GraphManager.hpp
  8. 24 12
      src/artis-star/common/InternalEvent.hpp
  9. 20 10
      src/artis-star/common/Links.hpp
  10. 94 47
      src/artis-star/common/Model.hpp
  11. 16 8
      src/artis-star/common/Node.hpp
  12. 4 2
      src/artis-star/common/Parameters.hpp
  13. 22 11
      src/artis-star/common/RootCoordinator.hpp
  14. 10 5
      src/artis-star/common/Scheduler.hpp
  15. 10 5
      src/artis-star/common/Simulator.hpp
  16. 24 12
      src/artis-star/common/States.hpp
  17. 32 16
      src/artis-star/common/Value.hpp
  18. 28 14
      src/artis-star/common/context/Context.hpp
  19. 26 13
      src/artis-star/common/context/State.hpp
  20. 14 7
      src/artis-star/common/context/StateValues.hpp
  21. 18 9
      src/artis-star/common/observer/Iterator.hpp
  22. 22 11
      src/artis-star/common/observer/Observer.hpp
  23. 8 4
      src/artis-star/common/observer/Output.hpp
  24. 26 13
      src/artis-star/common/observer/View.hpp
  25. 22 11
      src/artis-star/common/scheduler/HeapScheduler.hpp
  26. 8 4
      src/artis-star/common/scheduler/SchedulerHandle.hpp
  27. 20 10
      src/artis-star/common/scheduler/VectorScheduler.hpp
  28. 2 1
      src/artis-star/common/time/Limits.hpp
  29. 2 1
      src/artis-star/common/time/RationalTime.hpp
  30. 2 1
      src/artis-star/common/time/Time.hpp
  31. 6 3
      src/artis-star/common/utils/FormalismType.hpp
  32. 6 3
      src/artis-star/common/utils/FunctionType.hpp
  33. 6 3
      src/artis-star/common/utils/LevelType.hpp
  34. 62 31
      src/artis-star/common/utils/Multithreading.hpp
  35. 4 2
      src/artis-star/common/utils/String.hpp
  36. 68 34
      src/artis-star/common/utils/Trace.hpp
  37. 34 17
      src/artis-star/kernel/devs/Coordinator.hpp
  38. 34 17
      src/artis-star/kernel/devs/Dynamics.hpp
  39. 18 9
      src/artis-star/kernel/devs/GraphManager.hpp
  40. 40 20
      src/artis-star/kernel/devs/Simulator.hpp
  41. 34 17
      src/artis-star/kernel/dsde/Coordinator.hpp
  42. 70 35
      src/artis-star/kernel/dsde/Executive.hpp
  43. 20 10
      src/artis-star/kernel/dsde/GraphManager.hpp
  44. 28 14
      src/artis-star/kernel/dtss/Coordinator.hpp
  45. 40 20
      src/artis-star/kernel/dtss/Dynamics.hpp
  46. 26 13
      src/artis-star/kernel/dtss/GraphManager.hpp
  47. 20 10
      src/artis-star/kernel/dtss/Policy.hpp
  48. 38 19
      src/artis-star/kernel/dtss/Simulator.hpp
  49. 8 4
      src/artis-star/kernel/fddevs/Coordinator.hpp
  50. 46 23
      src/artis-star/kernel/fddevs/Dynamics.hpp
  51. 4 2
      src/artis-star/kernel/fddevs/GraphManager.hpp
  52. 38 19
      src/artis-star/kernel/fddevs/Simulator.hpp
  53. 10 5
      src/artis-star/kernel/pdevs/Context.hpp
  54. 34 17
      src/artis-star/kernel/pdevs/Coordinator.hpp
  55. 48 24
      src/artis-star/kernel/pdevs/Dynamics.hpp
  56. 32 16
      src/artis-star/kernel/pdevs/GraphManager.hpp
  57. 30 15
      src/artis-star/kernel/pdevs/Simulator.hpp
  58. 10 5
      src/artis-star/kernel/pdevs/mpi/Coordinator.hpp
  59. 10 5
      src/artis-star/kernel/pdevs/mpi/GraphManager.hpp
  60. 10 5
      src/artis-star/kernel/pdevs/mpi/LogicalProcessor.hpp
  61. 30 15
      src/artis-star/kernel/pdevs/mpi/ModelProxy.hpp
  62. 36 18
      src/artis-star/kernel/pdevs/multithreading/Coordinator.hpp
  63. 1 1
      src/artis-star/kernel/qss/CMakeLists.txt
  64. 6 3
      src/artis-star/kernel/qss/Data.hpp
  65. 107 72
      src/artis-star/kernel/qss/Derivative.hpp
  66. 117 85
      src/artis-star/kernel/qss/Integrator.hpp
  67. 275 0
      src/artis-star/kernel/qss/MultiDerivative.hpp
  68. 131 82
      src/artis-star/kernel/qss/Quantifier.hpp
  69. 32 16
      src/artis-star/kernel/sss/Coordinator.hpp
  70. 22 11
      src/artis-star/kernel/sss/Dynamics.hpp
  71. 12 6
      src/artis-star/kernel/sss/GraphManager.hpp
  72. 34 17
      src/artis-star/kernel/sss/Model.hpp
  73. 28 14
      src/artis-star/kernel/sss/Simulator.hpp

+ 1 - 3
AUTHORS

@@ -26,6 +26,4 @@ Main programmer and founder
 
 
 Contributors
-------------
-
-- Christopher Herbez <christopher.herbez@gmail.com>
+------------

+ 2 - 1
src/apps/main.cpp

@@ -24,6 +24,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-int main() {
+int main()
+{
   return 0;
 }

+ 50 - 19
src/artis-star/common/Any.hpp

@@ -37,20 +37,26 @@
 namespace artis {
 namespace common {
 
-class Any {
+class Any
+{
 private:
-  struct base {
-    virtual ~base() {}
+  struct base
+  {
+    virtual ~base()
+    {}
 
     virtual base *clone() const = 0;
   };
 
   template<typename T, typename V>
-  struct data : base {
+  struct data : base
+  {
     data(V T::* const &value)
-        : value_(value) {}
+        : value_(value)
+    {}
 
-    base *clone() const { return new data<T, V>(*this); }
+    base *clone() const
+    { return new data<T, V>(*this); }
 
     V T::* value_;
   };
@@ -59,37 +65,60 @@ private:
 
 public:
   Any()
-      : ptr_(nullptr) {}
+      : ptr_(nullptr)
+  {}
 
   template<typename T, typename V>
   Any(V T::* const &value)
-      : ptr_(new data<T, V>(value)) {}
+      : ptr_(new data<T, V>(value))
+  {}
 
   Any(Any const &other)
-      : ptr_(other.ptr_ ? other.ptr_->clone() : nullptr) {}
+      : ptr_(other.ptr_ ? other.ptr_->clone() : nullptr)
+  {}
 
-  virtual ~Any() {
-    if (ptr_)
+  virtual ~Any()
+  {
+    if (ptr_) {
       delete ptr_;
+    }
   }
 
-  void operator=(Any const &other) { Any(other).swap(*this); }
+  void operator=(Any const &other)
+  { Any(other).swap(*this); }
 
-  void swap(Any &other) { std::swap(ptr_, other.ptr_); }
+  void swap(Any &other)
+  { std::swap(ptr_, other.ptr_); }
 
   template<typename T, typename V>
-  V T::* get() const { return dynamic_cast < data<T, V> * >(ptr_)->value_; }
+  V T::* get() const
+  { return dynamic_cast < data<T, V> * >(ptr_)->value_; }
+
+  template<typename T, typename V>
+  void get(T *o, V &value) const
+  {
+    data<T, V> *q = dynamic_cast < data<T, V> * >(ptr_);
+
+    if (q) {
+      value = o->*(q->value_);
+    } else {
+      assert(false);
+    }
+  }
 
-  bool is_null() const { return ptr_ == nullptr; }
+  bool is_null() const
+  { return ptr_ == nullptr; }
 
   template<typename T, typename V>
-  void put(T *o, const V &value) {
+  void put(T *o, const V &value)
+  {
     V T::* p = dynamic_cast <data<T, V> * >(ptr_)->value_;
     o->*(p) = value;
   }
 
   template<typename T>
-  void restore(T *o, const common::Value &value) {
+  void restore(T *o, const common::Value &value)
+  {
     if (value.is_type<double>()) {
       double v;
 
@@ -136,7 +165,8 @@ public:
   }
 
   template<typename T>
-  common::Value save(const T *o) const {
+  common::Value save(const T *o) const
+  {
     if (ptr_) {
       data<T, double> *q_double =
           dynamic_cast < data<T, double> * >(ptr_);
@@ -196,7 +226,8 @@ public:
   }
 
   template<typename T>
-  std::string to_string(const T *o) const {
+  std::string to_string(const T *o) const
+  {
     if (ptr_) {
       data<T, double> *q_double =
           dynamic_cast < data<T, double> * >(ptr_);

+ 10 - 5
src/artis-star/common/Bag.hpp

@@ -42,15 +42,18 @@ template<class Time>
 class ExternalEvent;
 
 template<class Time>
-class Bag : public std::vector<ExternalEvent<Time> > {
+class Bag : public std::vector<ExternalEvent<Time> >
+{
 public:
   Bag() = default;
 
-  Bag(const ExternalEvent<Time> &event) { this->push_back(event); }
+  Bag(const ExternalEvent<Time> &event)
+  { this->push_back(event); }
 
   virtual ~Bag() = default;
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "{ ";
@@ -67,7 +70,8 @@ private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void save(Archive &ar, const unsigned int version) const {
+  void save(Archive &ar, const unsigned int version) const
+  {
     (void) version;
 
     ar & *dynamic_cast < const std::vector<ExternalEvent<Time> > * >(
@@ -75,7 +79,8 @@ private:
   }
 
   template<class Archive>
-  void load(Archive &ar, const unsigned int version) {
+  void load(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & *dynamic_cast < std::vector<ExternalEvent<Time> > * >(this);

+ 30 - 15
src/artis-star/common/Coordinator.hpp

@@ -45,18 +45,22 @@ template<class Time>
 class GraphManager;
 
 template<class Time>
-class Coordinator : public virtual Model<Time> {
+class Coordinator : public virtual Model<Time>
+{
 public :
   Coordinator(const std::string &name)
-      : Model<Time>(name) {}
+      : Model<Time>(name)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
   virtual GraphManager<Time> &get_graph_manager() = 0;
 
   virtual const GraphManager<Time> &get_graph_manager() const = 0;
 
-  virtual const Model<Time> *get_submodel(unsigned int index) const {
+  virtual const Model<Time> *get_submodel(unsigned int index) const
+  {
     const GraphManager<Time> &graph_manager = get_graph_manager();
     typename common::ModelMap<Time>::const_iterator it = graph_manager.child_map().find(
         index);
@@ -68,7 +72,8 @@ public :
     }
   }
 
-  virtual const Model<Time> *get_submodel(unsigned int index, unsigned int rank) const {
+  virtual const Model<Time> *get_submodel(unsigned int index, unsigned int rank) const
+  {
     const GraphManager<Time> &graph_manager = get_graph_manager();
     typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
         index);
@@ -80,7 +85,8 @@ public :
     }
   }
 
-  virtual unsigned int get_submodel_number(unsigned int index) const {
+  virtual unsigned int get_submodel_number(unsigned int index) const
+  {
     const GraphManager<Time> &graph_manager = get_graph_manager();
     typename common::ModelsMap<Time>::const_iterator it = graph_manager.children_map().find(
         index);
@@ -92,9 +98,11 @@ public :
     }
   }
 
-  void input_port(common::Port p) { Coordinator<Time>::add_in_port(p); }
+  void input_port(common::Port p)
+  { Coordinator<Time>::add_in_port(p); }
 
-  void input_ports(std::initializer_list<common::Port> list) {
+  void input_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -102,11 +110,14 @@ public :
     }
   }
 
-  virtual bool is_atomic() const { return false; }
+  virtual bool is_atomic() const
+  { return false; }
 
-  void output_port(common::Port p) { Coordinator<Time>::add_out_port(p); }
+  void output_port(common::Port p)
+  { Coordinator<Time>::add_out_port(p); }
 
-  void output_ports(std::initializer_list<common::Port> list) {
+  void output_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -114,21 +125,25 @@ public :
     }
   }
 
-  virtual void remove_model(const typename Time::type &t, common::Model<Time> *model) {
+  virtual void remove_model(const typename Time::type &t, common::Model<Time> *model)
+  {
     model->finish(t);
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     Model<Time>::restore(state);
     get_graph_manager().restore(state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     Model<Time>::save(state);
     get_graph_manager().save(state);
   }
 
-  virtual std::string to_string(int /* level */) const {
+  virtual std::string to_string(int /* level */) const
+  {
     std::ostringstream ss;
 
     ss << "Coordinator " << Coordinator<Time>::get_name();

+ 34 - 17
src/artis-star/common/ExternalEvent.hpp

@@ -48,68 +48,84 @@ template<class Time>
 class Model;
 
 template<class Time>
-class ExternalEvent {
+class ExternalEvent
+{
 public:
   ExternalEvent(const Value &data)
       :
-      _port_index(-1), _model(nullptr), _data(data) {}
+      _port_index(-1), _model(nullptr), _data(data)
+  {}
 
   ExternalEvent(int port_index)
       :
-      _port_index(port_index), _model(nullptr), _data(Value()) {}
+      _port_index(port_index), _model(nullptr), _data(Value())
+  {}
 
   ExternalEvent(int port_index, const Value &data)
       :
-      _port_index(port_index), _model(nullptr), _data(data) {}
+      _port_index(port_index), _model(nullptr), _data(data)
+  {}
 
   ExternalEvent(const Node<Time> &node, const Value &data)
       :
       _port_index(node.get_port_index()),
       _model(node.get_model()),
-      _data(data) {}
+      _data(data)
+  {}
 
   ExternalEvent(const ExternalEvent &event)
       :
       _port_index(event._port_index), _model(event._model),
-      _data(event._data) {}
+      _data(event._data)
+  {}
 
   ExternalEvent()
-      : _port_index(-2), _model(nullptr) {}
+      : _port_index(-2), _model(nullptr)
+  {}
 
   virtual ~ExternalEvent() = default;
 
-  const Value &data() const { return _data; }
+  const Value &data() const
+  { return _data; }
 
-  void data(const Value &data) { _data = data; }
+  void data(const Value &data)
+  { _data = data; }
 
-  Model<Time> *get_model() const { return _model; }
+  Model<Time> *get_model() const
+  { return _model; }
 
-  bool is_void() const { return _port_index == -2; }
+  bool is_void() const
+  { return _port_index == -2; }
 
-  bool on_port(int port_index) const {
+  bool on_port(int port_index) const
+  {
 
     assert(_port_index != -1);
 
     return _port_index == port_index;
   }
 
-  ExternalEvent &operator=(const ExternalEvent &e) {
+  ExternalEvent &operator=(const ExternalEvent &e)
+  {
     _port_index = e._port_index;
     _model = e._model;
     _data = e._data;
     return *this;
   }
 
-  int port_index() const {
+  int port_index() const
+  {
 
     assert(_port_index != -1);
 
     return _port_index;
   }
 
-  void set_model(Model<Time> *model) { _model = model; }
+  void set_model(Model<Time> *model)
+  { _model = model; }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "( ";
@@ -133,7 +149,8 @@ private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void serialize(Archive &ar, const unsigned int version) {
+  void serialize(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & _port_index;

+ 26 - 13
src/artis-star/common/GraphManager.hpp

@@ -39,21 +39,26 @@ namespace artis {
 namespace common {
 
 template<class Time>
-class GraphManager {
+class GraphManager
+{
 public:
   GraphManager(common::Coordinator<Time> *coordinator)
       :
-      _coordinator(coordinator) {}
+      _coordinator(coordinator)
+  {}
 
-  virtual ~GraphManager() {}
+  virtual ~GraphManager()
+  {}
 
-  virtual void add_child(unsigned int index, common::Model<Time> *child) {
+  virtual void add_child(unsigned int index, common::Model<Time> *child)
+  {
     _children.push_back(child);
     _child_map[index] = child;
     child->set_parent(_coordinator);
   }
 
-  virtual void add_children(unsigned int index, common::Model<Time> *child) {
+  virtual void add_children(unsigned int index, common::Model<Time> *child)
+  {
     _children.push_back(child);
     if (_children_map.find(index) == _children_map.end()) {
       _children_map[index] = Models<Time>();
@@ -62,17 +67,23 @@ public:
     child->set_parent(_coordinator);
   }
 
-  const common::Models<Time> &children() const { return _children; }
+  const common::Models<Time> &children() const
+  { return _children; }
 
-  const common::ModelMap<Time> &child_map() const { return _child_map; }
+  const common::ModelMap<Time> &child_map() const
+  { return _child_map; }
 
-  common::Model<Time> *child_map(size_t index) const { return _child_map.at(index); }
+  common::Model<Time> *child_map(size_t index) const
+  { return _child_map.at(index); }
 
-  const common::ModelsMap<Time> &children_map() const { return _children_map; }
+  const common::ModelsMap<Time> &children_map() const
+  { return _children_map; }
 
-  common::Coordinator<Time> *coordinator() const { return _coordinator; }
+  common::Coordinator<Time> *coordinator() const
+  { return _coordinator; }
 
-  virtual void remove_child(unsigned int index) {
+  virtual void remove_child(unsigned int index)
+  {
     common::Model<Time> *child = _child_map[index];
 
     _children.erase(std::find(_children.begin(), _children.end(), child));
@@ -80,14 +91,16 @@ public:
     _child_map.erase(index);
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     for (typename common::ModelMap<Time>::iterator it = _child_map.begin(); it != _child_map.end();
          ++it) {
       it->second->restore(state.get_substate(it->first));
     }
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     for (typename common::ModelMap<Time>::const_iterator it = _child_map.begin();
          it != _child_map.end(); ++it) {
       context::State<Time> substate;

+ 24 - 12
src/artis-star/common/InternalEvent.hpp

@@ -38,34 +38,44 @@ template<class Time>
 class Model;
 
 template<class Time>
-class InternalEvent {
+class InternalEvent
+{
 public:
   InternalEvent(const typename Time::type &time, Model<Time> *model)
-      : _time(time), _model(model) {}
+      : _time(time), _model(model)
+  {}
 
-  virtual ~InternalEvent() {}
+  virtual ~InternalEvent()
+  {}
 
-  Model<Time> *get_model() const { return _model; }
+  Model<Time> *get_model() const
+  { return _model; }
 
-  typename Time::type get_time() const { return _time; }
+  typename Time::type get_time() const
+  { return _time; }
 
-  bool operator<(InternalEvent const &e) const {
+  bool operator<(InternalEvent const &e) const
+  {
     return _time < e._time;
   }
 
-  bool operator>(InternalEvent const &e) const {
+  bool operator>(InternalEvent const &e) const
+  {
     return _time > e._time;
   }
 
-  bool operator>=(InternalEvent const &e) const {
+  bool operator>=(InternalEvent const &e) const
+  {
     return _time >= e._time;
   }
 
-  bool operator==(InternalEvent const &e) const {
+  bool operator==(InternalEvent const &e) const
+  {
     return _time == e._time;
   }
 
-  void set_time(typename Time::type time) { _time = time; }
+  void set_time(typename Time::type time)
+  { _time = time; }
 
 private:
   typename Time::type _time;
@@ -74,8 +84,10 @@ private:
 
 template<typename Event>
 struct EventCompare
-    : std::binary_function<Event, Event, bool> {
-  bool operator()(const Event &left, const Event &right) const { return left >= right; }
+    : std::binary_function<Event, Event, bool>
+{
+  bool operator()(const Event &left, const Event &right) const
+  { return left >= right; }
 };
 
 }

+ 20 - 10
src/artis-star/common/Links.hpp

@@ -40,7 +40,8 @@ template<class Time>
 class Node;
 
 template<class Time>
-class Links : public std::multimap<Node<Time>, Node<Time> > {
+class Links : public std::multimap<Node<Time>, Node<Time> >
+{
   typedef std::multimap<Node<Time>, Node<Time> > type;
 
 public:
@@ -49,12 +50,15 @@ public:
       typename Links<Time>::const_iterator
   > Result;
 
-  Links() {}
+  Links()
+  {}
 
-  virtual ~Links() {}
+  virtual ~Links()
+  {}
 
   void add(Model<Time> *out_model, unsigned int out_port_index,
-           Model<Time> *in_model, unsigned int in_port_index) {
+           Model<Time> *in_model, unsigned int in_port_index)
+  {
     type::insert(std::pair<Node<Time>, Node<Time> >(
         Node<Time>(out_model, out_port_index),
         Node<Time>(in_model, in_port_index)));
@@ -63,7 +67,8 @@ public:
   bool exist(Model<Time> *out_model,
              unsigned int out_port_index,
              Model<Time> *in_model,
-             unsigned int in_port_index) const {
+             unsigned int in_port_index) const
+  {
     std::pair<typename Links<Time>::const_iterator,
               typename Links<Time>::const_iterator> it =
         type::equal_range(Node<Time>(out_model, out_port_index));
@@ -80,7 +85,8 @@ public:
 
   typename Links<Time>::const_iterator
   find(Model<Time> *out_model, unsigned int out_port_index,
-       Model<Time> *in_model, unsigned int in_port_index) const {
+       Model<Time> *in_model, unsigned int in_port_index) const
+  {
     std::pair<typename Links<Time>::const_iterator,
               typename Links<Time>::const_iterator> it =
         type::equal_range(Node<Time>(out_model, out_port_index));
@@ -97,19 +103,22 @@ public:
     return it2;
   }
 
-  Links::Result find(Model<Time> *out_model, unsigned int out_port_index) const {
+  Links::Result find(Model<Time> *out_model, unsigned int out_port_index) const
+  {
     return type::equal_range(common::Node<Time>(out_model, out_port_index));
   }
 
   void remove(common::Model<Time> *src_model, unsigned int src_port_index,
-              common::Model<Time> *dst_model, unsigned int dst_port_index) {
+              common::Model<Time> *dst_model, unsigned int dst_port_index)
+  {
     typename Links<Time>::const_iterator result = find(src_model, src_port_index,
                                                        dst_model, dst_port_index);
 
     this->erase(result);
   }
 
-  void remove_links(common::Model<Time> *model) {
+  void remove_links(common::Model<Time> *model)
+  {
     typename Links<Time>::iterator it = this->begin();
 
     while (it != this->end()) {
@@ -122,7 +131,8 @@ public:
     }
   }
 
-  std::string to_string(int level = 0) const {
+  std::string to_string(int level = 0) const
+  {
     std::stringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "Links:" << std::endl;

+ 94 - 47
src/artis-star/common/Model.hpp

@@ -51,7 +51,8 @@ class InternalEvent;
 template<class Time>
 class Bag;
 
-struct Port {
+struct Port
+{
   unsigned int index;
   std::string name;
 };
@@ -60,34 +61,40 @@ typedef std::vector<unsigned int> Ports;
 typedef std::map<unsigned int, std::string> PortMap;
 
 template<class Time>
-class Model {
+class Model
+{
 public:
   Model(const std::string &name)
       :
-      _tl(0), _tn(0), _parent(0), _name(name), _inputs(0) {}
+      _tl(0), _tn(0), _parent(0), _name(name), _inputs(0)
+  {}
 
-  virtual ~Model() {
+  virtual ~Model()
+  {
     if (_inputs) {
       delete _inputs;
     }
   }
 
   // structure
-  void add_in_port(const Port &port) {
+  void add_in_port(const Port &port)
+  {
     assert(not exist_in_port(port.index));
 
     _in_ports.push_back(port.index);
     _in_port_map[port.index] = port.name;
   }
 
-  void add_out_port(const Port &port) {
+  void add_out_port(const Port &port)
+  {
     assert(not exist_out_port(port.index));
 
     _out_ports.push_back(port.index);
     _out_port_map[port.index] = port.name;
   }
 
-  void delete_in_port(const Port &port) {
+  void delete_in_port(const Port &port)
+  {
     assert(not exist_in_port(port.index));
 
     _in_ports.erase(std::find(_in_ports.begin(), _in_ports.end(),
@@ -95,7 +102,8 @@ public:
     _in_port_map.erase(port.index);
   }
 
-  void delete_out_port(const Port &port) {
+  void delete_out_port(const Port &port)
+  {
     assert(not exist_out_port(port.index));
 
     _out_ports.erase(std::find(_out_ports.begin(), _out_ports.end(),
@@ -103,42 +111,52 @@ public:
     _out_port_map.erase(port.index);
   }
 
-  bool exist_in_port(unsigned int port_index) const {
+  bool exist_in_port(unsigned int port_index) const
+  {
     return _in_port_map.find(port_index) != _in_port_map.end();
   }
 
-  bool exist_out_port(unsigned int port_index) const {
+  bool exist_out_port(unsigned int port_index) const
+  {
     return _out_port_map.find(port_index) != _out_port_map.end();
   }
 
-  std::string get_in_port_name(unsigned int port_index) const {
+  std::string get_in_port_name(unsigned int port_index) const
+  {
     assert(exist_in_port(port_index));
 
     return _in_port_map.find(port_index)->second;
   }
 
-  size_t get_in_port_number() const { return _in_port_map.size(); }
+  size_t get_in_port_number() const
+  { return _in_port_map.size(); }
 
-  std::string get_out_port_name(unsigned int port_index) const {
+  std::string get_out_port_name(unsigned int port_index) const
+  {
     assert(exist_out_port(port_index));
 
     return _out_port_map.find(port_index)->second;
   }
 
-  size_t get_out_port_number() const { return _out_port_map.size(); }
+  size_t get_out_port_number() const
+  { return _out_port_map.size(); }
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  Model<Time> *get_parent() const { return _parent; }
+  Model<Time> *get_parent() const
+  { return _parent; }
 
   // TODO: to remove
-  virtual int get_receiver_number(typename Time::type t) {
+  virtual int get_receiver_number(typename Time::type t)
+  {
     (void) t;
 
     return 0;
   }
 
-  virtual const Model<Time> *get_submodel(unsigned int index) const {
+  virtual const Model<Time> *get_submodel(unsigned int index) const
+  {
     (void) index;
 
     assert(false);
@@ -147,7 +165,8 @@ public:
   }
 
   virtual const Model<Time> *get_submodel(unsigned int index,
-                                          unsigned int rank) const {
+                                          unsigned int rank) const
+  {
     (void) index;
     (void) rank;
 
@@ -156,7 +175,8 @@ public:
     return nullptr;
   }
 
-  virtual unsigned int get_submodel_number(unsigned int index) const {
+  virtual unsigned int get_submodel_number(unsigned int index) const
+  {
     (void) index;
 
     assert(false);
@@ -166,9 +186,11 @@ public:
 
   virtual bool is_atomic() const = 0;
 
-  virtual bool is_remote() const { return false; }
+  virtual bool is_remote() const
+  { return false; }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     (void) observable_index;
 
     assert(false);
@@ -176,44 +198,52 @@ public:
     return std::string();
   }
 
-  std::string path() const {
+  std::string path() const
+  {
     return (_parent != nullptr ? _parent->path() : "") + ":" + get_name();
   }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     _tl = state.last_time();
     _tn = state.next_time();
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     state.last_time(_tl);
     state.next_time(_tn);
   }
 
-  void set_parent(Model<Time> *parent) { _parent = parent; }
+  void set_parent(Model<Time> *parent)
+  { _parent = parent; }
 
   virtual std::string to_string(int /* level */) const = 0;
 
   // event
-  void add_event(const common::ExternalEvent<Time> &message) {
+  void add_event(const common::ExternalEvent<Time> &message)
+  {
     if (_inputs == 0) {
       _inputs = new Bag<Time>;
     }
     _inputs->push_back(message);
   }
 
-  void clear_bag() {
+  void clear_bag()
+  {
     if (_inputs) {
       delete _inputs;
       _inputs = 0;
     }
   }
 
-  unsigned int event_number() const {
+  unsigned int event_number() const
+  {
     return _inputs ? _inputs->size() : 0;
   }
 
-  const common::Bag<Time> &get_bag() {
+  const common::Bag<Time> &get_bag()
+  {
     if (_inputs == 0) {
       _inputs = new Bag<Time>;
     }
@@ -221,9 +251,11 @@ public:
   }
 
   // time
-  typename Time::type get_tl() const { return _tl; }
+  typename Time::type get_tl() const
+  { return _tl; }
 
-  typename Time::type get_tn() const { return _tn; }
+  typename Time::type get_tn() const
+  { return _tn; }
 
   // devs methods
   virtual void finish(const typename Time::type &t) = 0;
@@ -240,12 +272,15 @@ public:
 
   virtual typename Time::type transition(const typename Time::type &t) = 0;
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
   // scheduler
-  void handle(SchedulerHandle handle) { _handle.handle(handle); }
+  void handle(SchedulerHandle handle)
+  { _handle.handle(handle); }
 
-  const SchedulerHandle &handle() const { return _handle.handle(); }
+  const SchedulerHandle &handle() const
+  { return _handle.handle(); }
 
 protected:
   typename Time::type _tl;
@@ -264,13 +299,17 @@ private :
 };
 
 template<class Time>
-class ModelMap : public std::map<unsigned int, Model<Time> *> {
+class ModelMap : public std::map<unsigned int, Model<Time> *>
+{
 public:
-  ModelMap() {}
+  ModelMap()
+  {}
 
-  virtual ~ModelMap() {}
+  virtual ~ModelMap()
+  {}
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "{ ";
@@ -285,13 +324,17 @@ public:
 };
 
 template<class Time>
-class Models : public std::vector<Model<Time> *> {
+class Models : public std::vector<Model<Time> *>
+{
 public:
-  Models() {}
+  Models()
+  {}
 
-  virtual ~Models() {}
+  virtual ~Models()
+  {}
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "{ ";
@@ -306,13 +349,17 @@ public:
 };
 
 template<class Time>
-class ModelsMap : public std::map<unsigned int, Models<Time> > {
+class ModelsMap : public std::map<unsigned int, Models<Time> >
+{
 public:
-  ModelsMap() {}
+  ModelsMap()
+  {}
 
-  virtual ~ModelsMap() {}
+  virtual ~ModelsMap()
+  {}
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "{ ";

+ 16 - 8
src/artis-star/common/Node.hpp

@@ -38,30 +38,38 @@ template<class Time>
 class Model;
 
 template<class Time>
-class Node {
+class Node
+{
 public :
   Node(Model<Time> *model, unsigned int port_index)
-      : _model(model), _port_index(port_index) {
+      : _model(model), _port_index(port_index)
+  {
     _id = std::hash<std::string>()(model->get_name() +
         std::to_string(port_index));
   }
 
   Node(const Node<Time> &other)
-      : _model(other._model), _port_index(other._port_index), _id(other._id) {}
+      : _model(other._model), _port_index(other._port_index), _id(other._id)
+  {}
 
-  virtual ~Node() {}
+  virtual ~Node()
+  {}
 
-  bool operator<(const Node<Time> &o) const {
+  bool operator<(const Node<Time> &o) const
+  {
     return _id < o._id;
   }
 
-  bool operator==(const Node<Time> &o) const {
+  bool operator==(const Node<Time> &o) const
+  {
     return _id == o._id;
   }
 
-  unsigned int get_port_index() const { return _port_index; }
+  unsigned int get_port_index() const
+  { return _port_index; }
 
-  Model<Time> *get_model() const { return _model; }
+  Model<Time> *get_model() const
+  { return _model; }
 
 private :
   Model<Time> *_model;

+ 4 - 2
src/artis-star/common/Parameters.hpp

@@ -30,9 +30,11 @@
 namespace artis {
 namespace common {
 
-class NoParameters {
+class NoParameters
+{
 public:
-  NoParameters() {}
+  NoParameters()
+  {}
 };
 
 }

+ 22 - 11
src/artis-star/common/RootCoordinator.hpp

@@ -39,7 +39,8 @@ namespace artis {
 namespace common {
 
 template<class Time, class Coordinator>
-class RootCoordinator {
+class RootCoordinator
+{
 public :
   RootCoordinator(const common::context::Context<Time> &context,
                   const std::string &root_name,
@@ -47,30 +48,37 @@ public :
                   const typename Coordinator::graph_parameters_type &graph_parameters)
       :
       _root(root_name, parameters, graph_parameters), _observer(&_root),
-      _t_max(context.end()), _tn(context.begin()) {}
+      _t_max(context.end()), _tn(context.begin())
+  {}
 
   RootCoordinator(const common::context::Context<Time> &context,
                   const std::string &root_name,
                   const typename Coordinator::parameters_type &parameters)
       :
       _root(root_name, parameters, NoParameters()), _observer(&_root),
-      _t_max(context.end()), _tn(context.begin()) {}
+      _t_max(context.end()), _tn(context.begin())
+  {}
 
   RootCoordinator(const common::context::Context<Time> &context,
                   const std::string &root_name)
       :
       _root(root_name, NoParameters(), NoParameters()), _observer(&_root),
-      _t_max(context.end()), _tn(context.begin()) {}
+      _t_max(context.end()), _tn(context.begin())
+  {}
 
-  virtual ~RootCoordinator() {}
+  virtual ~RootCoordinator()
+  {}
 
-  void attachView(const std::string &name, observer::View<Time> *view) {
+  void attachView(const std::string &name, observer::View<Time> *view)
+  {
     _observer.attachView(name, view);
   }
 
-  const observer::Observer<Time> &observer() const { return _observer; }
+  const observer::Observer<Time> &observer() const
+  { return _observer; }
 
-  void run(const common::context::Context<Time> &context) {
+  void run(const common::context::Context<Time> &context)
+  {
 //             DSDE synchroniser
 //               When receive (START,t)
 //                  send (START,0) to child
@@ -99,14 +107,17 @@ public :
     }
   }
 
-  void save(common::context::Context<Time> &context) const {
+  void save(common::context::Context<Time> &context) const
+  {
     _root.save(context.state());
     context.saved();
   }
 
-  void switch_to_timed_observer(double step) { _observer.switch_to_timed_observer(step); }
+  void switch_to_timed_observer(double step)
+  { _observer.switch_to_timed_observer(step); }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << _root.to_string(0);

+ 10 - 5
src/artis-star/common/Scheduler.hpp

@@ -38,15 +38,20 @@ struct SchedulerHandle;
 typedef typename artis::common::scheduler::HeapScheduler<
     common::DoubleTime, SchedulerHandle>::type SchedulerType;
 
-struct SchedulerHandle {
-  SchedulerHandle() {}
+struct SchedulerHandle
+{
+  SchedulerHandle()
+  {}
 
   SchedulerHandle(const SchedulerType::handle_type &handle)
-      : _handle(handle) {}
+      : _handle(handle)
+  {}
 
-  const SchedulerHandle &handle() const { return *this; }
+  const SchedulerHandle &handle() const
+  { return *this; }
 
-  void handle(const SchedulerHandle &handle) { _handle = handle._handle; }
+  void handle(const SchedulerHandle &handle)
+  { _handle = handle._handle; }
 
   SchedulerType::handle_type _handle;
 };

+ 10 - 5
src/artis-star/common/Simulator.hpp

@@ -35,16 +35,21 @@ namespace artis {
 namespace common {
 
 template<class Time>
-class Simulator : public virtual Model<Time> {
+class Simulator : public virtual Model<Time>
+{
 public :
   Simulator(const std::string &name)
-      : Model<Time>(name) {}
+      : Model<Time>(name)
+  {}
 
-  virtual ~Simulator() {}
+  virtual ~Simulator()
+  {}
 
-  virtual bool is_atomic() const { return true; }
+  virtual bool is_atomic() const
+  { return true; }
 
-  virtual std::string to_string(int /* level */) const {
+  virtual std::string to_string(int /* level */) const
+  {
     std::ostringstream ss;
 
     ss << "Simulator " << Simulator<Time>::get_name();

+ 24 - 12
src/artis-star/common/States.hpp

@@ -37,31 +37,40 @@ namespace artis {
 namespace common {
 
 template<typename Time, typename Dyn>
-class States {
+class States
+{
 public:
   template<class W>
-  struct element {
+  struct element
+  {
     unsigned int index;
     const std::string name;
     W Dyn::* var;
 
     element(unsigned int index, const std::string &name, W Dyn::* var)
         :
-        index(index), name(name), var(var) {}
+        index(index), name(name), var(var)
+    {}
   };
 
-  States() {}
+  States()
+  {}
 
-  virtual ~States() {}
+  virtual ~States()
+  {}
 
-  common::Any &get(unsigned int index) { return states.at(index); }
+  common::Any &get(unsigned int index)
+  { return states.at(index); }
 
-  const common::Any &get(unsigned int index) const { return states.at(index); }
+  const common::Any &get(unsigned int index) const
+  { return states.at(index); }
 
-  unsigned int state_number() const { return states.size(); }
+  unsigned int state_number() const
+  { return states.size(); }
 
   template<class W>
-  void S_(std::initializer_list<element<W> > list) {
+  void S_(std::initializer_list<element<W> > list)
+  {
     for (typename std::initializer_list<element<W> >::iterator it =
         list.begin(); it != list.end(); ++it) {
       if (states.size() <= it->index) {
@@ -73,7 +82,8 @@ public:
     }
   }
 
-  virtual void restore(Dyn *model, const common::context::State<Time> &state) {
+  virtual void restore(Dyn *model, const common::context::State<Time> &state)
+  {
     unsigned int index = 0;
 
     for (typename std::vector<common::Any>::iterator it = states.begin();
@@ -85,7 +95,8 @@ public:
     }
   }
 
-  virtual void save(const Dyn *model, common::context::State<Time> &state) const {
+  virtual void save(const Dyn *model, common::context::State<Time> &state) const
+  {
     unsigned int index = 0;
 
     for (typename std::vector<common::Any>::const_iterator it =
@@ -98,7 +109,8 @@ public:
   }
 
   template<class W>
-  void state_(unsigned int index, const std::string &name, W Dyn::* var) {
+  void state_(unsigned int index, const std::string &name, W Dyn::* var)
+  {
     if (states.size() <= index) {
       states.resize(index + 1, common::Any());
       state_names.resize(index + 1, std::string());

+ 32 - 16
src/artis-star/common/Value.hpp

@@ -39,26 +39,33 @@
 namespace artis {
 namespace common {
 
-class Value {
+class Value
+{
 public:
   Value()
-      : _content(nullptr), _size(0) {}
+      : _content(nullptr), _size(0)
+  {}
 
   template<typename T>
-  Value(T value) { assign(&value, sizeof(T), typeid(T).hash_code()); }
+  Value(T value)
+  { assign(&value, sizeof(T), typeid(T).hash_code()); }
 
   template<typename T>
-  Value(T *value, size_t size) {
+  Value(T *value, size_t size)
+  {
     assign(value, sizeof(T) * size, typeid(T *).hash_code());
   }
 
-  Value(void *content, size_t size) { assign(content, size, typeid(void *).hash_code()); }
+  Value(void *content, size_t size)
+  { assign(content, size, typeid(void *).hash_code()); }
 
-  Value(const char *value, unsigned int size) {
+  Value(const char *value, unsigned int size)
+  {
     assign(value, size * sizeof(char), typeid(char *).hash_code());
   }
 
-  Value(const Value &value) {
+  Value(const Value &value)
+  {
     if (value._content) {
       assign(value._content, value._size, value._type_id);
     } else {
@@ -68,31 +75,37 @@ public:
     }
   }
 
-  virtual ~Value() {
+  virtual ~Value()
+  {
     if (_content != nullptr)
       delete[] _content;
   }
 
-  bool empty() const { return _content == nullptr; }
+  bool empty() const
+  { return _content == nullptr; }
 
   template<typename T>
-  void operator()(T &value) const {
+  void operator()(T &value) const
+  {
     assert(_type_id == typeid(T).hash_code());
 
     value = *(T *) (_content);
   }
 
   template<typename T>
-  void operator()(T *&value) const {
+  void operator()(T *&value) const
+  {
     assert(_type_id == typeid(T *).hash_code());
 
     value = (T *) (_content);
   }
 
   template<typename Z>
-  bool is_type() const { return _type_id == typeid(Z).hash_code(); }
+  bool is_type() const
+  { return _type_id == typeid(Z).hash_code(); }
 
-  Value &operator=(const Value &value) {
+  Value &operator=(const Value &value)
+  {
     if (_content != nullptr) {
       delete _content;
     }
@@ -106,7 +119,8 @@ public:
     return *this;
   }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     if (empty()) {
       return "<null>";
     } else if (is_type<double>()) {
@@ -175,7 +189,8 @@ public:
   }
 
 private:
-  void assign(const void *content, size_t size, size_t type_id) {
+  void assign(const void *content, size_t size, size_t type_id)
+  {
     _content = new char[size];
     std::memcpy(_content, content, size);
     _size = size;
@@ -185,7 +200,8 @@ private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void serialize(Archive &ar, const unsigned int version) {
+  void serialize(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & _size;

+ 28 - 14
src/artis-star/common/context/Context.hpp

@@ -36,23 +36,31 @@ namespace common {
 namespace context {
 
 template<class Time>
-class Context {
+class Context
+{
 public:
   Context()
-      : _begin(-1), _end(-1), _valid(false) {}
+      : _begin(-1), _end(-1), _valid(false)
+  {}
 
   Context(const typename Time::type &begin, const typename Time::type &end)
-      : _begin(begin), _end(end), _valid(false) {}
+      : _begin(begin), _end(end), _valid(false)
+  {}
 
-  virtual ~Context() {}
+  virtual ~Context()
+  {}
 
-  const typename Time::type &begin() const { return _begin; }
+  const typename Time::type &begin() const
+  { return _begin; }
 
-  const typename Time::type &end() const { return _end; }
+  const typename Time::type &end() const
+  { return _end; }
 
-  void end(const typename Time::type &end) { _end = end; }
+  void end(const typename Time::type &end)
+  { _end = end; }
 
-  const Context &operator=(const Context &context) {
+  const Context &operator=(const Context &context)
+  {
     _begin = context._begin;
     _end = context._end;
     _valid = context._valid;
@@ -60,26 +68,32 @@ public:
     return *this;
   }
 
-  void saved() { _valid = true; }
+  void saved()
+  { _valid = true; }
 
-  const State<Time> &state() const { return _state; }
+  const State<Time> &state() const
+  { return _state; }
 
-  State<Time> &state() { return _state; }
+  State<Time> &state()
+  { return _state; }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     return "begin: " + std::to_string(_begin) +
         "; end: " + std::to_string(_end) +
         "; valid: " + (_valid ? "true" : "false") +
         "; state: " + _state.to_string();
   }
 
-  bool valid() const { return _valid; }
+  bool valid() const
+  { return _valid; }
 
 private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void serialize(Archive &ar, const unsigned int version) {
+  void serialize(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & _begin;

+ 26 - 13
src/artis-star/common/context/State.hpp

@@ -40,40 +40,52 @@ namespace common {
 namespace context {
 
 template<class Time>
-class State {
+class State
+{
   typedef std::map<unsigned int, State<Time> > Substates;
 
 public:
   State()
-      : _last_time(-1), _next_time(-1) {}
+      : _last_time(-1), _next_time(-1)
+  {}
 
-  virtual ~State() {}
+  virtual ~State()
+  {}
 
-  void add_state(unsigned int variable_key, const Value &value) {
+  void add_state(unsigned int variable_key, const Value &value)
+  {
     _values.add_state(variable_key, value);
   }
 
-  void add_substate(unsigned int model_key, State &state) {
+  void add_substate(unsigned int model_key, State &state)
+  {
     _substates.insert(std::make_pair(model_key, state));
   }
 
-  const Value &get_state(unsigned int variable_key) const {
+  const Value &get_state(unsigned int variable_key) const
+  {
     return _values.get_state(variable_key);
   }
 
-  const State<Time> &get_substate(unsigned int model_key) const {
+  const State<Time> &get_substate(unsigned int model_key) const
+  {
     return _substates.find(model_key)->second;
   }
 
-  typename Time::type last_time() const { return _last_time; }
+  typename Time::type last_time() const
+  { return _last_time; }
 
-  void last_time(typename Time::type t) { _last_time = t; }
+  void last_time(typename Time::type t)
+  { _last_time = t; }
 
-  typename Time::type next_time() const { return _next_time; }
+  typename Time::type next_time() const
+  { return _next_time; }
 
-  void next_time(typename Time::type t) { _next_time = t; }
+  void next_time(typename Time::type t)
+  { _next_time = t; }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::string str = "last_time: " + std::to_string(_last_time) +
         "; next_time: " + std::to_string(_next_time) +
         "; values: " + _values.to_string() + "; sub_states: [ ";
@@ -90,7 +102,8 @@ private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void serialize(Archive &ar, const unsigned int version) {
+  void serialize(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & _values;

+ 14 - 7
src/artis-star/common/context/StateValues.hpp

@@ -38,15 +38,20 @@ namespace artis {
 namespace common {
 namespace context {
 
-class StateValues {
+class StateValues
+{
 public:
-  StateValues() {}
+  StateValues()
+  {}
 
-  virtual ~StateValues() {}
+  virtual ~StateValues()
+  {}
 
-  void add_state(unsigned int key, const Value &value) { _states[key] = value; }
+  void add_state(unsigned int key, const Value &value)
+  { _states[key] = value; }
 
-  const Value &get_state(unsigned int key) const {
+  const Value &get_state(unsigned int key) const
+  {
     std::map<unsigned int, Value>::const_iterator it =
         _states.find(key);
 
@@ -58,7 +63,8 @@ public:
     }
   }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::string str = "states: [ ";
     for (std::map<unsigned int, Value>::const_iterator it =
         _states.begin(); it != _states.end(); ++it) {
@@ -72,7 +78,8 @@ private:
   friend class boost::serialization::access;
 
   template<class Archive>
-  void serialize(Archive &ar, const unsigned int version) {
+  void serialize(Archive &ar, const unsigned int version)
+  {
     (void) version;
 
     ar & _states;

+ 18 - 9
src/artis-star/common/observer/Iterator.hpp

@@ -33,18 +33,23 @@ namespace artis {
 namespace observer {
 
 template<typename Time>
-class Iterator {
+class Iterator
+{
 public:
   Iterator(const typename View<Time>::Values &view)
-      : _view(view), _iterator(view.begin()) {}
+      : _view(view), _iterator(view.begin())
+  {}
 
   virtual ~Iterator() = default;
 
-  bool has_next() const { return _iterator != _view.end(); }
+  bool has_next() const
+  { return _iterator != _view.end(); }
 
-  virtual void operator++() { _iterator++; }
+  virtual void operator++()
+  { _iterator++; }
 
-  virtual const std::pair<double, common::Value> &operator*() const { return *_iterator; }
+  virtual const std::pair<double, common::Value> &operator*() const
+  { return *_iterator; }
 
 private:
   const typename View<Time>::Values &_view;
@@ -52,11 +57,13 @@ private:
 };
 
 template<typename Time>
-class DiscreteTimeIterator : public Iterator<Time> {
+class DiscreteTimeIterator : public Iterator<Time>
+{
 public:
   DiscreteTimeIterator(const typename View<Time>::Values &view,
                        const typename Time::type &start, const typename Time::type &step)
-      : Iterator<Time>(view), _step(step), _time(start) {
+      : Iterator<Time>(view), _step(step), _time(start)
+  {
     _last_value = &Iterator<Time>::operator*();
     while (Iterator<Time>::operator*().first <= start
         and Iterator<Time>::has_next()) {
@@ -69,7 +76,8 @@ public:
 
   virtual ~DiscreteTimeIterator() = default;
 
-  void operator++() override {
+  void operator++() override
+  {
     _time += _step;
     _last_value = &Iterator<Time>::operator*();
     while (Iterator<Time>::operator*().first <= _time and Iterator<Time>::has_next()) {
@@ -80,7 +88,8 @@ public:
     }
   }
 
-  const std::pair<double, common::Value> &operator*() const override { return *_last_value; }
+  const std::pair<double, common::Value> &operator*() const override
+  { return *_last_value; }
 
 private:
   typename Time::type _step;

+ 22 - 11
src/artis-star/common/observer/Observer.hpp

@@ -36,28 +36,33 @@ namespace artis {
 namespace observer {
 
 template<typename Time>
-class Observer {
+class Observer
+{
 public:
   typedef std::map<std::string, View<Time> *> Views;
 
   Observer(const common::Model<Time> *model)
       :
       _step(0),
-      _model(model) {}
+      _model(model)
+  {}
 
-  virtual ~Observer() {
+  virtual ~Observer()
+  {
     for (typename Views::iterator it = _views.begin(); it != _views.end();
          ++it) {
       delete it->second;
     }
   }
 
-  void attachView(const std::string &name, View<Time> *view) {
+  void attachView(const std::string &name, View<Time> *view)
+  {
     _views[name] = view;
     view->attachModel(_model);
   }
 
-  Views *cloneViews() const {
+  Views *cloneViews() const
+  {
     Views *v = new Views();
 
     for (typename Views::const_iterator it = _views.begin();
@@ -67,15 +72,19 @@ public:
     return v;
   }
 
-  const View<Time> &view(const std::string &name) const {
+  const View<Time> &view(const std::string &name) const
+  {
     return *_views.find(name)->second;
   }
 
-  const Views &views() const { return _views; }
+  const Views &views() const
+  { return _views; }
 
-  void init() {}
+  void init()
+  {}
 
-  void observe(double t, double next_t) {
+  void observe(double t, double next_t)
+  {
     if (_step == 0) {
       observe(t);
     } else {
@@ -88,7 +97,8 @@ public:
     }
   }
 
-  void switch_to_timed_observer(double step) {
+  void switch_to_timed_observer(double step)
+  {
 
     assert(step > 0);
 
@@ -96,7 +106,8 @@ public:
   }
 
 private:
-  void observe(double t) {
+  void observe(double t)
+  {
     for (typename Views::iterator it = _views.begin(); it != _views.end();
          ++it) {
       it->second->observe(t);

+ 8 - 4
src/artis-star/common/observer/Output.hpp

@@ -34,14 +34,18 @@ namespace artis {
 namespace observer {
 
 template<typename Time>
-class Output {
+class Output
+{
 public:
   Output(const Observer<Time> &observer)
-      : _observer(observer) {}
+      : _observer(observer)
+  {}
 
-  virtual ~Output() {}
+  virtual ~Output()
+  {}
 
-  void operator()(double begin, double end, double step) const {
+  void operator()(double begin, double end, double step) const
+  {
     const typename Observer<Time>::Views &views = _observer.views();
 
     for (typename Observer<Time>::Views::const_iterator it =

+ 26 - 13
src/artis-star/common/observer/View.hpp

@@ -38,7 +38,8 @@ namespace artis {
 namespace observer {
 
 template<typename Time>
-class View {
+class View
+{
   typedef std::vector<int> Selector;
 
 public:
@@ -46,18 +47,23 @@ public:
   typedef std::map<std::string, Values> VariableValues;
   typedef std::map<std::string, VariableValues> SelectorValues;
 
-  enum vars {
+  enum vars
+  {
     ALL = -1
   };
 
   View()
-      : _model(0) {}
+      : _model(0)
+  {}
 
-  virtual ~View() {}
+  virtual ~View()
+  {}
 
-  void attachModel(const artis::common::Model<Time> *m) { _model = m; }
+  void attachModel(const artis::common::Model<Time> *m)
+  { _model = m; }
 
-  View *clone() const {
+  View *clone() const
+  {
     View *v = new View();
 
     // v->_selectors = _selectors;
@@ -104,7 +110,8 @@ public:
 //            }
 
   const Values &
-  get(const std::string &selector_name, const std::string &variable_name) const {
+  get(const std::string &selector_name, const std::string &variable_name) const
+  {
     SelectorValues::const_iterator it = _values.find(selector_name);
 
     if (it != _values.end()) {
@@ -120,7 +127,8 @@ public:
     }
   }
 
-  const Values &get(const std::string &selector_name) const {
+  const Values &get(const std::string &selector_name) const
+  {
     SelectorValues::const_iterator it = _values.find(selector_name);
 
     if (it != _values.end()) {
@@ -133,7 +141,8 @@ public:
   }
 
   void observe(double time, const common::Model<common::DoubleTime> *model,
-               const std::string &selector_name, unsigned int variable_index) {
+               const std::string &selector_name, unsigned int variable_index)
+  {
     std::string path = (boost::format("%1%:%2%") % model->path() %
         model->observable_name(variable_index)).str();
     VariableValues &values = _values[selector_name];
@@ -147,7 +156,8 @@ public:
 
   void observe(const Selector &chain, unsigned int i,
                double time, const common::Model<common::DoubleTime> *model,
-               const std::string &selector_name, unsigned int variable_index) {
+               const std::string &selector_name, unsigned int variable_index)
+  {
     assert(model != nullptr);
 
     while (i < chain.size() - 1 and chain[i + 1] != ALL and model) {
@@ -179,7 +189,8 @@ public:
     }
   }
 
-  virtual void observe(double time) {
+  virtual void observe(double time)
+  {
     for (typename Selectors::const_iterator it = _selectors.begin();
          it != _selectors.end(); ++it) {
       const common::Model<common::DoubleTime> *model = _model;
@@ -197,11 +208,13 @@ public:
     }
   }
 
-  void selector(const std::string &name, const Selector &chain) {
+  void selector(const std::string &name, const Selector &chain)
+  {
     _selectors[name] = chain;
   }
 
-  const SelectorValues &values() const { return _values; }
+  const SelectorValues &values() const
+  { return _values; }
 
 private:
   typedef std::map<std::string, Selector> Selectors;

+ 22 - 11
src/artis-star/common/scheduler/HeapScheduler.hpp

@@ -49,22 +49,27 @@ class HeapScheduler :
     public boost::heap::fibonacci_heap<
         InternalEvent<Time>,
         boost::heap::compare<
-            EventCompare<InternalEvent<Time> > > > {
+            EventCompare<InternalEvent<Time> > > >
+{
 public:
   typedef HeapScheduler<Time, T> type;
   typedef Model<Time> model_type;
   typedef Models<Time> models_type;
   typedef InternalEvent<Time> internal_event_type;
 
-  HeapScheduler() {}
+  HeapScheduler()
+  {}
 
-  virtual ~HeapScheduler() {}
+  virtual ~HeapScheduler()
+  {}
 
-  model_type *get_current_model() {
+  model_type *get_current_model()
+  {
     return type::top().get_model();
   }
 
-  models_type get_current_models(const typename Time::type &time) const {
+  models_type get_current_models(const typename Time::type &time) const
+  {
     models_type models;
     typename models_type::iterator it;
 
@@ -84,7 +89,8 @@ public:
   }
 
   models_type get_current_models(const typename Time::type &begin,
-                                 const typename Time::type &end) const {
+                                 const typename Time::type &end) const
+  {
     models_type models;
     typename models_type::iterator it;
 
@@ -105,15 +111,18 @@ public:
     return models;
   }
 
-  typename Time::type get_current_time() const {
+  typename Time::type get_current_time() const
+  {
     return type::top().get_time();
   }
 
-  void init(typename Time::type time, model_type *model) {
+  void init(typename Time::type time, model_type *model)
+  {
     model->handle(T(type::push(internal_event_type(time, model))));
   }
 
-  void put(typename Time::type time, const model_type *model) {
+  void put(typename Time::type time, const model_type *model)
+  {
     typename Time::type previous_time =
         (*model->handle()._handle).get_time();
 
@@ -127,11 +136,13 @@ public:
     }
   }
 
-  void remove_model(model_type *model) {
+  void remove_model(model_type *model)
+  {
     type::erase(model->handle()._handle);
   }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::stringstream ss;
 
     ss << "Scheduler = { ";

+ 8 - 4
src/artis-star/common/scheduler/SchedulerHandle.hpp

@@ -31,12 +31,16 @@ namespace artis {
 namespace common {
 namespace scheduler {
 
-struct NoSchedulerHandle {
-  NoSchedulerHandle() {}
+struct NoSchedulerHandle
+{
+  NoSchedulerHandle()
+  {}
 
-  const NoSchedulerHandle &handle() const { return *this; }
+  const NoSchedulerHandle &handle() const
+  { return *this; }
 
-  void handle(const NoSchedulerHandle & /* handle */) {}
+  void handle(const NoSchedulerHandle & /* handle */)
+  {}
 };
 
 }

+ 20 - 10
src/artis-star/common/scheduler/VectorScheduler.hpp

@@ -39,18 +39,23 @@ namespace scheduler {
 
 template<class Time>
 class VectorScheduler :
-    protected std::vector<InternalEvent<Time, NoSchedulerHandle> > {
+    protected std::vector<InternalEvent<Time, NoSchedulerHandle> >
+{
 public:
-  VectorScheduler() {}
+  VectorScheduler()
+  {}
 
-  virtual ~VectorScheduler() {}
+  virtual ~VectorScheduler()
+  {}
 
-  Model<Time, NoSchedulerHandle> *get_current_model() {
+  Model<Time, NoSchedulerHandle> *get_current_model()
+  {
     return VectorScheduler<Time>::front().get_model();
   }
 
   Models<Time, NoSchedulerHandle> get_current_models(
-      typename Time::type time) const {
+      typename Time::type time) const
+  {
     Models<Time, NoSchedulerHandle> models;
 
     for (typename VectorScheduler<Time>::const_iterator it =
@@ -62,17 +67,20 @@ public:
     return models;
   }
 
-  typename Time::type get_current_time() const { return VectorScheduler<Time>::front().get_time(); }
+  typename Time::type get_current_time() const
+  { return VectorScheduler<Time>::front().get_time(); }
 
   void init(typename Time::type time,
-            Model<Time, NoSchedulerHandle> *model) {
+            Model<Time, NoSchedulerHandle> *model)
+  {
     VectorScheduler<Time>::push_back(
         InternalEvent<Time, NoSchedulerHandle>(time, model));
     std::sort(VectorScheduler<Time>::begin(),
               VectorScheduler<Time>::end());
   }
 
-  void put(typename Time::type time, Model<Time, NoSchedulerHandle> *model) {
+  void put(typename Time::type time, Model<Time, NoSchedulerHandle> *model)
+  {
     remove(model);
     VectorScheduler<Time>::push_back(
         InternalEvent<Time, NoSchedulerHandle>(time, model));
@@ -80,7 +88,8 @@ public:
               VectorScheduler<Time>::end());
   }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::stringstream ss;
 
     ss << "Scheduler = { ";
@@ -95,7 +104,8 @@ public:
   }
 
 private:
-  void remove(Model<Time, NoSchedulerHandle> *model) {
+  void remove(Model<Time, NoSchedulerHandle> *model)
+  {
     typename VectorScheduler<Time>::iterator jt =
         VectorScheduler<Time>::begin();
 

+ 2 - 1
src/artis-star/common/time/Limits.hpp

@@ -33,7 +33,8 @@ namespace artis {
 namespace common {
 
 template<typename T>
-struct Limits {
+struct Limits
+{
   static constexpr T negative_infinity = std::numeric_limits<T>::lowest();
   static constexpr T positive_infinity = std::numeric_limits<T>::max();
   static constexpr T null = 0;

+ 2 - 1
src/artis-star/common/time/RationalTime.hpp

@@ -34,7 +34,8 @@
 namespace artis {
 namespace common {
 
-struct RationalLimits {
+struct RationalLimits
+{
   static constexpr boost::rational<int>
       negative_infinity = boost::rational<int>(std::numeric_limits<int>::lowest());
   static constexpr boost::rational<int>

+ 2 - 1
src/artis-star/common/time/Time.hpp

@@ -31,7 +31,8 @@ namespace artis {
 namespace common {
 
 template<typename Type, typename Limits>
-struct Time {
+struct Time
+{
   static Type negative_infinity;
   static Type infinity;
   static Type null;

+ 6 - 3
src/artis-star/common/utils/FormalismType.hpp

@@ -32,13 +32,16 @@
 namespace artis {
 namespace common {
 
-class FormalismType {
+class FormalismType
+{
 public:
-  enum Values {
+  enum Values
+  {
     NONE = 0, DEVS, DSDE, PDEVS, QSS, DTSS, GDEVS, CELLDEVS, FDDEVS, DESS, SSS
   };
 
-  static std::string to_string(const FormalismType::Values &s) {
+  static std::string to_string(const FormalismType::Values &s)
+  {
     switch (s) {
     case NONE:return "none";
     case DEVS:return "devs";

+ 6 - 3
src/artis-star/common/utils/FunctionType.hpp

@@ -32,14 +32,17 @@
 namespace artis {
 namespace common {
 
-class FunctionType {
+class FunctionType
+{
 public:
-  enum Values {
+  enum Values
+  {
     NONE = 0, CONSTRUCTOR, FINISH, I_MESSAGE, POST_EVENT, S_MESSAGE, Y_MESSAGE,
     DELTA_INT, DELTA_EXT, DELTA_CONF, TA, LAMBDA, START, OUTPUT, TRANSITION
   };
 
-  static std::string to_string(const FunctionType::Values &s) {
+  static std::string to_string(const FunctionType::Values &s)
+  {
     switch (s) {
     case NONE:return "none";
     case CONSTRUCTOR:return "constructor";

+ 6 - 3
src/artis-star/common/utils/LevelType.hpp

@@ -32,13 +32,16 @@
 namespace artis {
 namespace common {
 
-class LevelType {
+class LevelType
+{
 public:
-  enum Values {
+  enum Values
+  {
     NONE = 0, COMMON, FORMALISM, USER
   };
 
-  static std::string to_string(const LevelType::Values &s) {
+  static std::string to_string(const LevelType::Values &s)
+  {
     switch (s) {
     case NONE:return "none";
     case COMMON:return "common";

+ 62 - 31
src/artis-star/common/utils/Multithreading.hpp

@@ -34,34 +34,42 @@
 namespace artis {
 namespace common {
 
-struct BaseMessage {
-  virtual ~BaseMessage() {}
+struct BaseMessage
+{
+  virtual ~BaseMessage()
+  {}
 };
 
 template<typename Msg>
-struct Message : BaseMessage {
+struct Message : BaseMessage
+{
   explicit Message(Msg const &content)
-      : _content(content) {}
+      : _content(content)
+  {}
 
   Msg _content;
 };
 
-class Close {
+class Close
+{
 };
 
-class MessageQueue {
+class MessageQueue
+{
 public:
   MessageQueue() = default;
 
   template<typename T>
-  void push(T const &msg) {
+  void push(T const &msg)
+  {
     std::lock_guard<std::mutex> lock(_mutex);
 
     _queue.push(std::make_shared<Message<T> >(msg));
     _condition.notify_all();
   }
 
-  std::shared_ptr<BaseMessage> wait_and_pop() {
+  std::shared_ptr<BaseMessage> wait_and_pop()
+  {
     std::unique_lock<std::mutex> lock(_mutex);
 
     _condition.wait(lock, [&] { return not _queue.empty(); });
@@ -76,16 +84,20 @@ private:
   std::queue<std::shared_ptr<BaseMessage> > _queue;
 };
 
-class Sender {
+class Sender
+{
 public:
   Sender()
-      : _queue(0) {}
+      : _queue(0)
+  {}
 
   explicit Sender(MessageQueue *queue)
-      : _queue(queue) {}
+      : _queue(queue)
+  {}
 
   template<typename Message>
-  void send(Message const &msg) {
+  void send(Message const &msg)
+  {
     if (_queue) {
       _queue->push(msg);
     }
@@ -96,7 +108,8 @@ private:
 };
 
 template<typename PreviousDispatcher, typename Msg, typename Func>
-class TemplateDispatcher {
+class TemplateDispatcher
+{
   template<typename Dispatcher, typename OtherMsg, typename OtherFunc>
   friend
   class TemplateDispatcher;
@@ -108,7 +121,8 @@ public:
         _function(
             std::move(
                 other._function)),
-        _chained(other._chained) { other._chained = true; }
+        _chained(other._chained)
+  { other._chained = true; }
 
   TemplateDispatcher(MessageQueue *queue,
                      PreviousDispatcher *previous,
@@ -116,9 +130,11 @@ public:
       :
       _queue(queue), _previous(previous),
       _function(std::forward<Func>(function)),
-      _chained(false) { previous->_chained = true; }
+      _chained(false)
+  { previous->_chained = true; }
 
-  bool dispatch(std::shared_ptr<BaseMessage> const &msg) {
+  bool dispatch(std::shared_ptr<BaseMessage> const &msg)
+  {
     Message<Msg> *message =
         dynamic_cast < Message<Msg> * >(msg.get());
 
@@ -133,14 +149,16 @@ public:
   template<typename OtherMsg, typename OtherFunc>
   TemplateDispatcher<TemplateDispatcher<PreviousDispatcher, Msg, Func>,
                      OtherMsg, OtherFunc>
-  handle(OtherFunc &&of) {
+  handle(OtherFunc &&of)
+  {
     return TemplateDispatcher<TemplateDispatcher<PreviousDispatcher,
                                                  Msg, Func>,
                               OtherMsg, OtherFunc>(
         _queue, this, std::forward<OtherFunc>(of));
   }
 
-  ~TemplateDispatcher() noexcept(false) {
+  ~TemplateDispatcher() noexcept(false)
+  {
     if (not _chained) {
       wait_and_dispatch();
     }
@@ -151,7 +169,8 @@ private:
 
   TemplateDispatcher &operator=(TemplateDispatcher const &) = delete;
 
-  void wait_and_dispatch() {
+  void wait_and_dispatch()
+  {
     for (;;) {
       auto msg = _queue->wait_and_pop();
 
@@ -167,7 +186,8 @@ private:
   bool _chained;
 };
 
-class Dispatcher {
+class Dispatcher
+{
   template<typename Dispatcher, typename Msg, typename Func>
   friend
   class TemplateDispatcher;
@@ -175,19 +195,23 @@ class Dispatcher {
 public:
   Dispatcher(Dispatcher &&other)
       : _queue(other._queue),
-        _chained(other._chained) { other._chained = true; }
+        _chained(other._chained)
+  { other._chained = true; }
 
   explicit Dispatcher(MessageQueue *queue)
-      : _queue(queue), _chained(false) {}
+      : _queue(queue), _chained(false)
+  {}
 
   template<typename Message, typename Func>
   TemplateDispatcher<Dispatcher, Message, Func>
-  handle(Func &&function) {
+  handle(Func &&function)
+  {
     return TemplateDispatcher<Dispatcher, Message, Func>(
         _queue, this, std::forward<Func>(function));
   }
 
-  ~Dispatcher() noexcept(false) {
+  ~Dispatcher() noexcept(false)
+  {
     if (not _chained) {
       wait_and_dispatch();
     }
@@ -198,7 +222,8 @@ private:
 
   Dispatcher &operator=(Dispatcher const &) = delete;
 
-  void wait_and_dispatch() {
+  void wait_and_dispatch()
+  {
     for (;;) {
       auto msg = _queue->wait_and_pop();
 
@@ -206,7 +231,8 @@ private:
     }
   }
 
-  bool dispatch(std::shared_ptr<BaseMessage> const &msg) {
+  bool dispatch(std::shared_ptr<BaseMessage> const &msg)
+  {
     if (dynamic_cast < Message<Close> * >(msg.get())) {
       throw Close();
     }
@@ -217,15 +243,20 @@ private:
   bool _chained;
 };
 
-class Receiver {
+class Receiver
+{
 public:
-  Receiver() : _queue(new MessageQueue) {}
+  Receiver() : _queue(new MessageQueue)
+  {}
 
-  ~Receiver() { delete _queue; }
+  ~Receiver()
+  { delete _queue; }
 
-  Sender get_sender() { return Sender(_queue); }
+  Sender get_sender()
+  { return Sender(_queue); }
 
-  Dispatcher wait() { return Dispatcher(_queue); }
+  Dispatcher wait()
+  { return Dispatcher(_queue); }
 
 private:
   MessageQueue *_queue;

+ 4 - 2
src/artis-star/common/utils/String.hpp

@@ -32,9 +32,11 @@
 namespace artis {
 namespace common {
 
-class String {
+class String
+{
 public:
-  static std::string make_spaces(unsigned int number) {
+  static std::string make_spaces(unsigned int number)
+  {
     std::string str;
 
     for (unsigned int i = 0; i < number; ++i) {

+ 68 - 34
src/artis-star/common/utils/Trace.hpp

@@ -42,35 +42,47 @@ namespace artis {
 namespace common {
 
 template<class Time>
-class TraceElement {
+class TraceElement
+{
 public:
   TraceElement()
       : _time(Time::null), _formalism_type(FormalismType::NONE),
-        _function_type(FunctionType::NONE), _level_type(LevelType::NONE) {}
+        _function_type(FunctionType::NONE), _level_type(LevelType::NONE)
+  {}
 
   TraceElement(const std::string &model_name, typename Time::type time,
                const FormalismType::Values &formalism_type,
                const FunctionType::Values &function_type, const LevelType::Values &level_type)
       : _model_name(model_name), _time(time), _formalism_type(formalism_type),
-        _function_type(function_type), _level_type(level_type) {}
+        _function_type(function_type), _level_type(level_type)
+  {}
 
-  virtual ~TraceElement() {}
+  virtual ~TraceElement()
+  {}
 
-  const std::string &get_comment() const { return _comment; }
+  const std::string &get_comment() const
+  { return _comment; }
 
-  const std::string &get_model_name() const { return _model_name; }
+  const std::string &get_model_name() const
+  { return _model_name; }
 
-  typename Time::type get_time() const { return _time; }
+  typename Time::type get_time() const
+  { return _time; }
 
-  const FormalismType::Values &get_formalism_type() const { return _formalism_type; }
+  const FormalismType::Values &get_formalism_type() const
+  { return _formalism_type; }
 
-  const FunctionType::Values &get_function_type() const { return _function_type; }
+  const FunctionType::Values &get_function_type() const
+  { return _function_type; }
 
-  const LevelType::Values &get_level_type() const { return _level_type; }
+  const LevelType::Values &get_level_type() const
+  { return _level_type; }
 
-  void set_comment(const std::string &comment) { _comment = comment; }
+  void set_comment(const std::string &comment)
+  { _comment = comment; }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "TRACE: " << get_model_name() << " at " << get_time() << " <";
@@ -93,13 +105,17 @@ private:
 };
 
 template<class Time>
-class TraceElements : public std::vector<TraceElement<Time> > {
+class TraceElements : public std::vector<TraceElement<Time> >
+{
 public:
-  TraceElements() {}
+  TraceElements()
+  {}
 
-  virtual ~TraceElements() {}
+  virtual ~TraceElements()
+  {}
 
-  TraceElements filter_model_name(const std::string &model_name) const {
+  TraceElements filter_model_name(const std::string &model_name) const
+  {
     TraceElements<Time> result;
 
     std::copy_if(TraceElements<Time>::begin(),
@@ -110,7 +126,8 @@ public:
     return result;
   }
 
-  TraceElements filter_time(typename Time::type time) const {
+  TraceElements filter_time(typename Time::type time) const
+  {
     TraceElements result;
 
     std::copy_if(TraceElements<Time>::begin(),
@@ -119,7 +136,8 @@ public:
     return result;
   }
 
-  TraceElements filter_formalism_type(const FormalismType::Values &type) const {
+  TraceElements filter_formalism_type(const FormalismType::Values &type) const
+  {
     TraceElements result;
 
     std::copy_if(TraceElements<Time>::begin(),
@@ -128,7 +146,8 @@ public:
     return result;
   }
 
-  TraceElements filter_function_type(const FunctionType::Values &type) const {
+  TraceElements filter_function_type(const FunctionType::Values &type) const
+  {
     TraceElements result;
 
     std::copy_if(TraceElements<Time>::begin(),
@@ -137,7 +156,8 @@ public:
     return result;
   }
 
-  TraceElements filter_level_type(const LevelType::Values &type) const {
+  TraceElements filter_level_type(const LevelType::Values &type) const
+  {
     TraceElements result;
 
     std::copy_if(TraceElements<Time>::begin(),
@@ -146,7 +166,8 @@ public:
     return result;
   }
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     for (typename TraceElements<Time>::const_iterator it = TraceElements<Time>::begin();
@@ -165,11 +186,14 @@ public:
 };
 
 template<class Time>
-class Trace {
+class Trace
+{
 public:
-  virtual ~Trace() {}
+  virtual ~Trace()
+  {}
 
-  static Trace &trace() {
+  static Trace &trace()
+  {
 //                std::call_once(_flag, []() { _instance.reset(new Trace()); });
     if (!_instance) {
       _instance.reset(new Trace());
@@ -177,11 +201,14 @@ public:
     return *_instance;
   }
 
-  void clear() { _trace.clear(); }
+  void clear()
+  { _trace.clear(); }
 
-  const TraceElements<Time> &elements() const { return _trace; }
+  const TraceElements<Time> &elements() const
+  { return _trace; }
 
-  void flush() {
+  void flush()
+  {
     std::lock_guard<std::mutex> lock(_mutex);
 
     if (_sstream) {
@@ -192,11 +219,14 @@ public:
     _trace.push_back(_element);
   }
 
-  std::mutex &mutex() { return _mutex; }
+  std::mutex &mutex()
+  { return _mutex; }
 
-  void set_element(const TraceElement<Time> &element) { _element = element; }
+  void set_element(const TraceElement<Time> &element)
+  { _element = element; }
 
-  std::ostringstream &sstream() {
+  std::ostringstream &sstream()
+  {
     if (_sstream == 0) {
       _sstream = new std::ostringstream();
     }
@@ -204,7 +234,8 @@ public:
   }
 
 private:
-  Trace() { _sstream = 0; }
+  Trace()
+  { _sstream = 0; }
 
   static std::shared_ptr<Trace<Time> > _instance;
 //            static std::once_flag _flag;
@@ -220,7 +251,8 @@ private:
 
 template<class Time>
 artis::common::Trace<Time> &
-operator<<(artis::common::Trace<Time> &trace, const artis::common::TraceElement<Time> &e) {
+operator<<(artis::common::Trace<Time> &trace, const artis::common::TraceElement<Time> &e)
+{
   std::lock_guard<std::mutex> lock(trace.mutex());
 
   trace.set_element(e);
@@ -228,7 +260,8 @@ operator<<(artis::common::Trace<Time> &trace, const artis::common::TraceElement<
 }
 
 template<class Time>
-artis::common::Trace<Time> &operator<<(artis::common::Trace<Time> &trace, const std::string &str) {
+artis::common::Trace<Time> &operator<<(artis::common::Trace<Time> &trace, const std::string &str)
+{
   std::lock_guard<std::mutex> lock(trace.mutex());
 
   trace.sstream() << str;
@@ -236,7 +269,8 @@ artis::common::Trace<Time> &operator<<(artis::common::Trace<Time> &trace, const
 }
 
 template<class Time>
-artis::common::Trace<Time> &operator<<(artis::common::Trace<Time> &trace, typename Time::type t) {
+artis::common::Trace<Time> &operator<<(artis::common::Trace<Time> &trace, typename Time::type t)
+{
   std::lock_guard<std::mutex> lock(trace.mutex());
 
   trace.sstream() << t;

+ 34 - 17
src/artis-star/kernel/devs/Coordinator.hpp

@@ -43,7 +43,8 @@ template<class Time,
     class Select,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class Coordinator : public common::Coordinator<Time> {
+class Coordinator : public common::Coordinator<Time>
+{
   typedef Coordinator<Time, GraphManager, Parameters, GraphParameters> type;
 
 public:
@@ -56,15 +57,19 @@ public:
       common::Model<Time>(name),
       common::Coordinator<Time>(name),
       _graph_manager(this, parameters, graph_parameters),
-      _d_star(nullptr) {}
+      _d_star(nullptr)
+  {}
 
   virtual ~Coordinator() = default;
 
-  GraphManager &get_graph_manager() { return _graph_manager; }
+  GraphManager &get_graph_manager()
+  { return _graph_manager; }
 
-  const GraphManager &get_graph_manager() const { return _graph_manager; }
+  const GraphManager &get_graph_manager() const
+  { return _graph_manager; }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "p-devs coordinator \""
@@ -73,14 +78,16 @@ public:
     return ss.str();
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::Coordinator<Time>::restore(state);
     for (auto &child : _graph_manager.children()) {
       _event_table.init(child->get_tn(), child);
     }
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #else
@@ -93,7 +100,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message (i, t) at time t
 //                  for-each d ∈ D do
 //                    send i-message (i, t) to child d
@@ -135,7 +143,8 @@ public:
     return this->_tn;
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message (*, t)
 //                  if t != tn then Error
 //                  d* = first({d | (d, th,d) ∈ (event-list & tn,d = tn) })
@@ -184,7 +193,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message (x, t)
 //                  if not (tl <= t <= tn) then Error
 //                  receivers = { r | r ∈ D, N ∈ Ir, Z(N,r)(x) isn't empty }
@@ -251,7 +261,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -281,7 +292,8 @@ public:
   }
 
   typename Time::type dispatch_events(const common::Bag<Time> &bag,
-                                      const typename Time::type &t) {
+                                      const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -314,17 +326,20 @@ public:
   }
 
   common::Value observe(const typename Time::type & /* t */,
-                        unsigned int /* index */) const {
+                        unsigned int /* index */) const
+  {
     assert(false);
     return common::Value();
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _graph_manager.lookahead(t);
   }
 
   common::Models<Time> get_imm_without_receivers(const common::Models<Time> &IMM,
-                                                 const common::Models<Time> &receivers) const {
+                                                 const common::Models<Time> &receivers) const
+  {
     common::Models<Time> imm;
 
     for (auto &model : IMM) {
@@ -336,7 +351,8 @@ public:
     return imm;
   }
 
-  common::Models<Time> get_receivers() const {
+  common::Models<Time> get_receivers() const
+  {
     common::Models<Time> receivers;
 
     for (auto &model : _graph_manager.children()) {
@@ -347,7 +363,8 @@ public:
     return receivers;
   }
 
-  void update_event_table(typename Time::type t) {
+  void update_event_table(typename Time::type t)
+  {
     for (auto &model : _graph_manager.children()) {
       if (model->event_number() > 0) {
         _event_table.put(t, model);

+ 34 - 17
src/artis-star/kernel/devs/Dynamics.hpp

@@ -37,11 +37,13 @@ namespace artis {
 namespace devs {
 
 template<class Time, class Dyn, class Parameters = common::NoParameters>
-class Dynamics : public common::States<Time, Dyn> {
+class Dynamics : public common::States<Time, Dyn>
+{
   typedef devs::Simulator<Time, Dyn, Parameters> Simulator;
 
 public:
-  struct Observable {
+  struct Observable
+  {
     unsigned int index;
     std::string name;
   };
@@ -50,35 +52,47 @@ public:
 
   Dynamics(const std::string &name, const Context<Time, Dyn, Parameters> &context)
       :
-      _name(name), _simulator(context.simulator()) {}
+      _name(name), _simulator(context.simulator())
+  {}
 
-  virtual ~Dynamics() {}
+  virtual ~Dynamics()
+  {}
 
-  virtual void dint(typename Time::type /* t */) {}
+  virtual void dint(typename Time::type /* t */)
+  {}
 
   virtual void dext(typename Time::type /* t */, typename Time::type /* e */,
-                    const common::ExternalEvent<Time> & /* event */) {}
+                    const common::ExternalEvent<Time> & /* event */)
+  {}
 
-  virtual void start(typename Time::type /* time */) {}
+  virtual void start(typename Time::type /* time */)
+  {}
 
   virtual typename Time::type
-  ta(typename Time::type /* time */) const { return Time::infinity; }
+  ta(typename Time::type /* time */) const
+  { return Time::infinity; }
 
   virtual common::ExternalEvent<Time>
-  lambda(typename Time::type /* time */) const { return common::ExternalEvent<Time>(); }
+  lambda(typename Time::type /* time */) const
+  { return common::ExternalEvent<Time>(); }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const { return common::Value(); }
+                                unsigned int /* index */) const
+  { return common::Value(); }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void observable(Observable observable) {
+  void observable(Observable observable)
+  {
     _observables[observable.index] = observable.name;
   }
 
-  void observables(std::initializer_list<Observable> list) {
+  void observables(std::initializer_list<Observable> list)
+  {
     for (typename std::initializer_list<Observable>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -86,17 +100,20 @@ public:
     }
   }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     assert(_observables.find(observable_index) != _observables.end());
 
     return _observables.find(observable_index)->second;
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
   }
 

+ 18 - 9
src/artis-star/kernel/devs/GraphManager.hpp

@@ -41,7 +41,8 @@ namespace devs {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public common::GraphManager<Time> {
+class GraphManager : public common::GraphManager<Time>
+{
 public:
   typedef GraphManager<Time, Parameters, GraphParameters> type;
   typedef std::pair<common::Model<Time> *, common::Model<Time> *> Link;
@@ -51,11 +52,13 @@ public:
                const Parameters & /* parameters */,
                const GraphParameters & /* graph_parameters */)
       :
-      common::GraphManager<Time>(coordinator) {}
+      common::GraphManager<Time>(coordinator)
+  {}
 
   ~GraphManager() override = default;
 
-  void dispatch_events(common::Bag<Time> bag, typename Time::type t) {
+  void dispatch_events(common::Bag<Time> bag, typename Time::type t)
+  {
     for (auto &ymsg : bag) {
       auto it = std::find_if(_links.begin(), _links.end(),
                              [&ymsg](const Link &link) { return link.first == ymsg.get_model(); });
@@ -72,7 +75,8 @@ public:
   }
 
   virtual void
-  dispatch_events_to_parent(const common::Value &content, typename Time::type t) {
+  dispatch_events_to_parent(const common::Value &content, typename Time::type t)
+  {
     common::Bag<Time> ymessages;
 
     ymessages.push_back(common::ExternalEvent<Time>(content));
@@ -83,13 +87,16 @@ public:
     }
   }
 
-  bool exist_link(common::Model<Time> *src_model, common::Model<Time> *dst_model) const {
+  bool exist_link(common::Model<Time> *src_model, common::Model<Time> *dst_model) const
+  {
     return _links.find(std::make_pair(src_model, dst_model));
   }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event) {
+  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event)
+  {
     auto it = std::find_if(_links.begin(), _links.end(),
                            [this](const Link &link) {
                              return link.first == common::GraphManager<Time>::_coordinator;
@@ -101,7 +108,8 @@ public:
     }
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "Children :" << std::endl;
@@ -117,7 +125,8 @@ public:
     return ss.str();
   }
 
-  void add_link(common::Model<Time> *src_model, common::Model<Time> *dst_model) {
+  void add_link(common::Model<Time> *src_model, common::Model<Time> *dst_model)
+  {
     assert((src_model != common::GraphManager<Time>::_coordinator and
         dst_model != common::GraphManager<Time>::_coordinator and
         src_model != dst_model) or

+ 40 - 20
src/artis-star/kernel/devs/Simulator.hpp

@@ -41,19 +41,24 @@ class Simulator;
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Context {
+class Context
+{
   typedef devs::Simulator<Time, Dynamics, Parameters> Simulator;
 
 public:
   Context(const Parameters &parameters, Simulator *simulator)
       :
-      _parameters(parameters), _simulator(simulator) {}
+      _parameters(parameters), _simulator(simulator)
+  {}
 
-  virtual ~Context() {}
+  virtual ~Context()
+  {}
 
-  const Parameters &parameters() const { return _parameters; }
+  const Parameters &parameters() const
+  { return _parameters; }
 
-  Simulator *simulator() const { return _simulator; }
+  Simulator *simulator() const
+  { return _simulator; }
 
 private:
   const Parameters &_parameters;
@@ -62,7 +67,8 @@ private:
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Simulator : public common::Simulator<Time> {
+class Simulator : public common::Simulator<Time>
+{
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public :
@@ -70,23 +76,29 @@ public :
       :
       common::Model<Time>(name),
       common::Simulator<Time>(name),
-      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this)) {}
+      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this))
+  {}
 
-  ~Simulator() override {}
+  ~Simulator() override
+  {}
 
-  const Dynamics &dynamics() const { return _dynamics; }
+  const Dynamics &dynamics() const
+  { return _dynamics; }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "p-devs simulator \""
@@ -94,7 +106,8 @@ public :
     return ss.str();
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #else
@@ -107,7 +120,8 @@ public :
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message(t)
 //                  tl = t - e
 //                  tn = tl + ta(s)
@@ -148,13 +162,16 @@ public :
   }
 
   common::Value observe(const typename Time::type &t,
-                        unsigned int index) const { return _dynamics.observe(t, index); }
+                        unsigned int index) const
+  { return _dynamics.observe(t, index); }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     return _dynamics.observable_name(observable_index);
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message(t)
 //                  if (t != tn) then Error
 //                  y = lambda(s)
@@ -193,7 +210,8 @@ public :
 
   }
 
-  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event) {
+  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -210,7 +228,8 @@ public :
     type::add_event(event);
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message(t)
 //                  if not (tl <= t <= tn) then Error
 //                  if (x is empty and t = tn) then
@@ -269,7 +288,8 @@ public :
     return type::_tn;
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _dynamics.lookahead(t);
   }
 

+ 34 - 17
src/artis-star/kernel/dsde/Coordinator.hpp

@@ -46,7 +46,8 @@ template<class Time,
     class Executive,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class Coordinator : public common::Coordinator<Time> {
+class Coordinator : public common::Coordinator<Time>
+{
   typedef Coordinator<Time, GraphManager, Executive, Parameters, GraphParameters> type;
 
 public:
@@ -59,17 +60,22 @@ public:
       common::Model<Time>(name),
       common::Coordinator<Time>(name),
       _graph_manager(this, parameters, graph_parameters),
-      _executive(parameters, graph_parameters, _graph_manager) {
+      _executive(parameters, graph_parameters, _graph_manager)
+  {
     _graph_manager.add_child(0, &_executive);
   }
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  GraphManager &get_graph_manager() { return _graph_manager; }
+  GraphManager &get_graph_manager()
+  { return _graph_manager; }
 
-  const GraphManager &get_graph_manager() const { return _graph_manager; }
+  const GraphManager &get_graph_manager() const
+  { return _graph_manager; }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "dsde coordinator \""
@@ -78,14 +84,16 @@ public:
     return ss.str();
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::Coordinator<Time>::restore(state);
     for (auto &child : _graph_manager.children()) {
       _event_table.init(child->get_tn(), child);
     }
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -100,7 +108,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //             Network Simulator Start Message
 //                When receive (START,t)
 //                  send (START,t) to {I | I ∈ C}
@@ -141,7 +150,8 @@ public:
     return type::_tn;
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //             Network Simulator Output Function
 //                When receive (OUTPUT,t)
 //                  if t = tn then
@@ -194,7 +204,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //             Network Simulator Transition
 //                When receive (TRANSITION,t,x)
 //                  if t ∉ [tl ,tn ] then ERROR endIf
@@ -274,7 +285,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -305,7 +317,8 @@ public:
 
   typename Time::type dispatch_events(
       const common::Bag<Time> &bag,
-      const typename Time::type &t) {
+      const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -338,12 +351,14 @@ public:
   }
 
   common::Value observe(const typename Time::type & /* t */,
-                        unsigned int /* index */) const {
+                        unsigned int /* index */) const
+  {
     assert(false);
     return common::Value();
   }
 
-  void add_models_with_inputs(common::Models<Time> &receivers) {
+  void add_models_with_inputs(common::Models<Time> &receivers)
+  {
     for (auto &model : _graph_manager.children()) {
       if (model->event_number() > 0) {
         if (std::find(receivers.begin(), receivers.end(), model)
@@ -354,12 +369,14 @@ public:
     }
   }
 
-  void remove_model(const typename Time::type &t, common::Model<Time> *model) override {
+  void remove_model(const typename Time::type &t, common::Model<Time> *model) override
+  {
     common::Coordinator<Time>::remove_model(t, model);
     _event_table.remove_model(model);
   }
 
-  void update_event_table(typename Time::type t) {
+  void update_event_table(typename Time::type t)
+  {
     for (auto &model : _graph_manager.children()) {
       if (model->event_number() > 0) {
         _event_table.put(t, model);

+ 70 - 35
src/artis-star/kernel/dsde/Executive.hpp

@@ -39,7 +39,8 @@ class ExecutiveSimulator;
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class ExecutiveContext {
+class ExecutiveContext
+{
   typedef ExecutiveSimulator<Time, Dynamics, Parameters, GraphParameters> Simulator;
 
 public:
@@ -47,15 +48,20 @@ public:
                    Simulator *simulator)
       :
       _parameters(parameters), _graph_parameters(graph_parameters),
-      _simulator(simulator) {}
+      _simulator(simulator)
+  {}
 
-  virtual ~ExecutiveContext() {}
+  virtual ~ExecutiveContext()
+  {}
 
-  const GraphParameters &graph_parameters() const { return _graph_parameters; }
+  const GraphParameters &graph_parameters() const
+  { return _graph_parameters; }
 
-  const Parameters &parameters() const { return _parameters; }
+  const Parameters &parameters() const
+  { return _parameters; }
 
-  Simulator *simulator() const { return _simulator; }
+  Simulator *simulator() const
+  { return _simulator; }
 
 private:
   const Parameters &_parameters;
@@ -66,7 +72,8 @@ private:
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class ExecutiveSimulator : public common::Simulator<Time> {
+class ExecutiveSimulator : public common::Simulator<Time>
+{
   typedef ExecutiveSimulator<Time, Dynamics, Parameters, GraphParameters> type;
 
 public :
@@ -77,23 +84,29 @@ public :
       common::Model<Time>("executive"),
       common::Simulator<Time>("executive"),
       _dynamics(ExecutiveContext<Time, Dynamics, Parameters, GraphParameters>(
-          parameters, graph_parameters, this), graph_manager) {}
+          parameters, graph_parameters, this), graph_manager)
+  {}
 
-  ~ExecutiveSimulator() {}
+  ~ExecutiveSimulator()
+  {}
 
-  const Dynamics &dynamics() const { return _dynamics; }
+  const Dynamics &dynamics() const
+  { return _dynamics; }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "executive simulator \""
@@ -101,7 +114,8 @@ public :
     return ss.str();
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -116,7 +130,8 @@ public :
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message(t)
 //                  tl = t - e
 //                  tn = tl + ta(s)
@@ -151,9 +166,11 @@ public :
   }
 
   common::Value observe(const typename Time::type &t,
-                        unsigned int index) const { return _dynamics.observe(t, index); }
+                        unsigned int index) const
+  { return _dynamics.observe(t, index); }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message(t)
 //                  if (t = tn) then
 //                    y = lambda(s)
@@ -195,7 +212,8 @@ public :
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -225,7 +243,8 @@ public :
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message(t)
 //                  if (x is empty and t = tn) then
 //                    s = delta_int(s)
@@ -282,44 +301,57 @@ private :
 };
 
 template<class Time, class Dyn, class Parameters = common::NoParameters, class GraphParameters = common::NoParameters>
-class ExecutiveDynamics : public common::States<Time, Dyn> {
+class ExecutiveDynamics : public common::States<Time, Dyn>
+{
   typedef dsde::ExecutiveSimulator<Time, Dyn, Parameters, GraphParameters> Simulator;
 
 public:
   ExecutiveDynamics(
       const ExecutiveContext<Time, Dyn, Parameters, GraphParameters> &context)
       :
-      _simulator(context.simulator()), _name("executive") {}
+      _simulator(context.simulator()), _name("executive")
+  {}
 
-  virtual ~ExecutiveDynamics() {}
+  virtual ~ExecutiveDynamics()
+  {}
 
   virtual void dconf(typename Time::type /* t */, typename Time::type /* e */,
-                     const common::Bag<Time> & /* bag */) {}
+                     const common::Bag<Time> & /* bag */)
+  {}
 
-  virtual void dint(typename Time::type /* t */) {}
+  virtual void dint(typename Time::type /* t */)
+  {}
 
   virtual void dext(typename Time::type /* t */, typename Time::type /* e */,
-                    const common::Bag<Time> & /* bag */) {}
+                    const common::Bag<Time> & /* bag */)
+  {}
 
   virtual typename Time::type
-  start(typename Time::type /* time */) { return Time::infinity; }
+  start(typename Time::type /* time */)
+  { return Time::infinity; }
 
   virtual typename Time::type
-  ta(typename Time::type /* time */) const { return Time::infinity; }
+  ta(typename Time::type /* time */) const
+  { return Time::infinity; }
 
   virtual common::Bag<Time>
-  lambda(typename Time::type /* time */) const { return common::Bag<Time>(); }
+  lambda(typename Time::type /* time */) const
+  { return common::Bag<Time>(); }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const { return common::Value(); }
+                                unsigned int /* index */) const
+  { return common::Value(); }
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
   }
 
@@ -329,18 +361,21 @@ private:
 };
 
 template<class Time, class Dyn, class Parameters = common::NoParameters, class GraphParameters = common::NoParameters>
-class Executive : public dsde::ExecutiveDynamics<Time, Dyn, Parameters, GraphParameters> {
+class Executive : public dsde::ExecutiveDynamics<Time, Dyn, Parameters, GraphParameters>
+{
 public:
   Executive(const ExecutiveContext<Time, Dyn, Parameters, GraphParameters> &context,
             dsde::GraphManager<Time, Parameters, GraphParameters> &graph_manager)
       :
       dsde::ExecutiveDynamics<Time, Dyn, Parameters, GraphParameters>(context),
-      _graph_manager(graph_manager) {}
+      _graph_manager(graph_manager)
+  {}
 
   ~Executive() override = default;
 
 protected:
-  dsde::GraphManager<Time, Parameters, GraphParameters> &graph_manager() { return _graph_manager; }
+  dsde::GraphManager<Time, Parameters, GraphParameters> &graph_manager()
+  { return _graph_manager; }
 
 private:
   dsde::GraphManager<Time, Parameters, GraphParameters> &_graph_manager;

+ 20 - 10
src/artis-star/kernel/dsde/GraphManager.hpp

@@ -37,7 +37,8 @@ namespace dsde {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters> {
+class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters>
+{
 public:
   typedef pdevs::GraphManager<Time, Parameters, GraphParameters> super;
   typedef GraphManager<Time, Parameters, GraphParameters> type;
@@ -47,28 +48,33 @@ public:
                const GraphParameters &graph_parameters)
       :
       pdevs::GraphManager<Time, Parameters, GraphParameters>(coordinator, parameters,
-                                                             graph_parameters) {}
+                                                             graph_parameters)
+  {}
 
-  ~GraphManager() override {
+  ~GraphManager() override
+  {
     for (auto m: _models) {
       delete m;
     }
   }
 
-  virtual void add_dynamic_child(unsigned int index, common::Model<Time> *child) {
+  virtual void add_dynamic_child(unsigned int index, common::Model<Time> *child)
+  {
     super::add_child(index, child);
     _models.push_back(child);
     _new_models.push_back(child);
   }
 
-  virtual void add_dynamic_children(unsigned int index, common::Model<Time> *child) {
+  virtual void add_dynamic_children(unsigned int index, common::Model<Time> *child)
+  {
     super::add_children(index, child);
     _models.push_back(child);
     _new_models.push_back(child);
   }
 
   void add_link(unsigned int source_model_index, unsigned int source_port_index,
-                unsigned int destination_model_index, unsigned int destination_port_index) {
+                unsigned int destination_model_index, unsigned int destination_port_index)
+  {
     common::Model<Time> *source_model = super::child_map(source_model_index);
     common::Model<Time> *destination_model = super::child_map(destination_model_index);
 
@@ -78,11 +84,14 @@ public:
         >> this->in({destination_model, destination_port_index});
   }
 
-  void clear_new_models() { _new_models.clear(); }
+  void clear_new_models()
+  { _new_models.clear(); }
 
-  std::vector<common::Model<Time> *> &new_models() { return _new_models; }
+  std::vector<common::Model<Time> *> &new_models()
+  { return _new_models; }
 
-  void remove_dynamic_child(const typename Time::type &t, unsigned int index) {
+  void remove_dynamic_child(const typename Time::type &t, unsigned int index)
+  {
     size_t new_index = index
         - (pdevs::GraphManager<Time, Parameters, GraphParameters>::_children.size()
             - _models.size());
@@ -97,7 +106,8 @@ public:
   }
 
   void remove_link(unsigned int source_model_index, unsigned int source_port_index,
-                   unsigned int destination_model_index, unsigned int destination_port_index) {
+                   unsigned int destination_model_index, unsigned int destination_port_index)
+  {
     common::Model<Time> *source_model = super::child_map(source_model_index);
     common::Model<Time> *destination_model = super::child_map(destination_model_index);
 

+ 28 - 14
src/artis-star/kernel/dtss/Coordinator.hpp

@@ -37,14 +37,16 @@ namespace artis {
 namespace dtss {
 
 template<class Time>
-struct Parameters {
+struct Parameters
+{
   typename Time::type time_step;
 };
 
 template<class Time, class Policy, class GraphManager,
     class Parameters = Parameters<Time>,
     class GraphParameters = common::NoParameters>
-class Coordinator : public common::Coordinator<Time> {
+class Coordinator : public common::Coordinator<Time>
+{
   typedef Coordinator<Time, Policy, GraphManager, Parameters, GraphParameters> type;
 
 public:
@@ -57,15 +59,20 @@ public:
       common::Model<Time>(name),
       common::Coordinator<Time>(name),
       _graph_manager(this, parameters, graph_parameters),
-      _time_step(parameters.time_step) {}
+      _time_step(parameters.time_step)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  GraphManager &get_graph_manager() { return _graph_manager; }
+  GraphManager &get_graph_manager()
+  { return _graph_manager; }
 
-  const GraphManager &get_graph_manager() const { return _graph_manager; }
+  const GraphManager &get_graph_manager() const
+  { return _graph_manager; }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -80,7 +87,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -116,7 +124,8 @@ public:
   }
 
   typename Time::type dispatch_events(const common::Bag<Time> &bag,
-                                      const typename Time::type &t) {
+                                      const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -146,16 +155,19 @@ public:
   }
 
   common::Value observe(const typename Time::type & /* t */,
-                        unsigned int /* index */) const {
+                        unsigned int /* index */) const
+  {
     assert(false);
     return common::Value();
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _graph_manager.lookahead(t);
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -187,7 +199,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -217,7 +230,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()

+ 40 - 20
src/artis-star/kernel/dtss/Dynamics.hpp

@@ -38,11 +38,13 @@ namespace dtss {
 
 template<class Time, class Dyn,
     class Parameters = common::NoParameters>
-class Dynamics : public common::States<Time, Dyn> {
+class Dynamics : public common::States<Time, Dyn>
+{
   typedef dtss::Simulator<Time, Dyn, Parameters> Simulator;
 
 public:
-  struct Observable {
+  struct Observable
+  {
     unsigned int index;
     std::string name;
   };
@@ -51,41 +53,53 @@ public:
 
   Dynamics(const std::string &name, const Context<Time, Dyn, Parameters> &context)
       :
-      _name(name), _simulator(context.simulator()) {}
+      _name(name), _simulator(context.simulator())
+  {}
 
-  virtual ~Dynamics() {}
+  virtual ~Dynamics()
+  {}
 
   virtual void transition(const common::Bag<Time> & /* x */,
-                          const typename Time::type & /* t */) {}
+                          const typename Time::type & /* t */)
+  {}
 
-  virtual void start(const typename Time::type & /* time */) {}
+  virtual void start(const typename Time::type & /* time */)
+  {}
 
   virtual common::Bag<Time> lambda(
-      const typename Time::type & /* time */) const { return common::Bag<Time>(); }
+      const typename Time::type & /* time */) const
+  { return common::Bag<Time>(); }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const { return common::Value(); }
+                                unsigned int /* index */) const
+  { return common::Value(); }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void input_port(common::Port p) {
+  void input_port(common::Port p)
+  {
     _simulator->add_in_port(p);
   }
 
-  void input_ports(std::initializer_list<common::Port> list) {
+  void input_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it =
         list.begin(); it != list.end(); ++it) {
       _simulator->add_in_port(*it);
     }
   }
 
-  void observable(Observable observable) {
+  void observable(Observable observable)
+  {
     _observables[observable.index] = observable.name;
   }
 
-  void observables(std::initializer_list<Observable> list) {
+  void observables(std::initializer_list<Observable> list)
+  {
     for (typename std::initializer_list<Observable>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -93,32 +107,38 @@ public:
     }
   }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     assert(_observables.find(observable_index) != _observables.end());
 
     return _observables.find(observable_index)->second;
   }
 
-  void output_port(common::Port p) {
+  void output_port(common::Port p)
+  {
     _simulator->add_out_port(p);
   }
 
-  void output_ports(std::initializer_list<common::Port> list) {
+  void output_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it =
         list.begin(); it != list.end(); ++it) {
       _simulator->add_out_port(*it);
     }
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
   }
 
-  const typename Time::type &time_step() const { return _simulator->time_step(); }
+  const typename Time::type &time_step() const
+  { return _simulator->time_step(); }
 
 private:
   std::string _name;

+ 26 - 13
src/artis-star/kernel/dtss/GraphManager.hpp

@@ -39,11 +39,13 @@ namespace dtss {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public common::GraphManager<Time> {
+class GraphManager : public common::GraphManager<Time>
+{
 public:
   typedef GraphManager<Time, Parameters, GraphParameters> type;
 
-  struct ModelPort {
+  struct ModelPort
+  {
     common::Model<Time> *model;
     unsigned int port_index;
     type *graph_manager;
@@ -51,9 +53,11 @@ public:
     ModelPort(common::Model<Time> *model, unsigned int port_index)
         : model(model),
           port_index(port_index),
-          graph_manager(nullptr) {}
+          graph_manager(nullptr)
+    {}
 
-    void operator>>(const ModelPort &dst) {
+    void operator>>(const ModelPort &dst)
+    {
       graph_manager->add_link(model, port_index, dst.model, dst.port_index);
     }
   };
@@ -62,21 +66,25 @@ public:
                const Parameters & /* parameters */,
                const GraphParameters & /* graph_parameters */)
       :
-      common::GraphManager<Time>(coordinator) {}
+      common::GraphManager<Time>(coordinator)
+  {}
 
   ~GraphManager() override = default;
 
-  ModelPort in(ModelPort p) {
+  ModelPort in(ModelPort p)
+  {
     p.graph_manager = this;
     return p;
   }
 
-  ModelPort out(ModelPort p) {
+  ModelPort out(ModelPort p)
+  {
     p.graph_manager = this;
     return p;
   }
 
-  void dispatch_events(common::Bag<Time> bag, typename Time::type t) {
+  void dispatch_events(common::Bag<Time> bag, typename Time::type t)
+  {
     for (auto &ymsg : bag) {
       typename common::Links<Time>::Result result_model = _link_list.find(
           ymsg.get_model(),
@@ -97,7 +105,8 @@ public:
 
   virtual void
   dispatch_events_to_parent(common::Node<Time> node, const common::Value &content,
-                            typename Time::type t) {
+                            typename Time::type t)
+  {
     common::Bag<Time> ymessages;
 
     ymessages.push_back(common::ExternalEvent<Time>(node, content));
@@ -109,9 +118,11 @@ public:
     }
   }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event) {
+  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event)
+  {
     typename common::Links<Time>::Result result =
         _link_list.find(common::GraphManager<Time>::_coordinator,
                         event.port_index());
@@ -124,7 +135,8 @@ public:
     }
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "Children :" << std::endl;
@@ -137,7 +149,8 @@ public:
 
 private:
   void add_link(common::Model<Time> *src_model, unsigned int src_port_index,
-                common::Model<Time> *dst_model, unsigned int dst_port_index) {
+                common::Model<Time> *dst_model, unsigned int dst_port_index)
+  {
     assert((src_model != common::GraphManager<Time>::_coordinator and
         dst_model != common::GraphManager<Time>::_coordinator and
         src_model->exist_out_port(src_port_index) and

+ 20 - 10
src/artis-star/kernel/dtss/Policy.hpp

@@ -34,23 +34,28 @@
 namespace artis {
 namespace dtss {
 
-class Policy {
+class Policy
+{
 public:
   Policy() = default;
 
   virtual ~Policy() = default;
 
-  const common::Bag<common::DoubleTime> &bag() const { return _bag; }
+  const common::Bag<common::DoubleTime> &bag() const
+  { return _bag; }
 
-  void clear() { _bag.clear(); }
+  void clear()
+  { _bag.clear(); }
 
-  void push(const common::ExternalEvent<common::DoubleTime> &event) { _bag.push_back(event); }
+  void push(const common::ExternalEvent<common::DoubleTime> &event)
+  { _bag.push_back(event); }
 
 private:
   common::Bag<common::DoubleTime> _bag;
 };
 
-class AllEventsPolicy : public Policy {
+class AllEventsPolicy : public Policy
+{
 public:
   AllEventsPolicy() = default;
 
@@ -60,12 +65,14 @@ public:
       typename common::DoubleTime::type /* t */,
       const common::ExternalEvent<common::DoubleTime> &event,
       typename common::DoubleTime::type /* tl */,
-      typename common::DoubleTime::type /* tn */) {
+      typename common::DoubleTime::type /* tn */)
+  {
     push(event);
   }
 };
 
-class LastBagPolicy : public Policy {
+class LastBagPolicy : public Policy
+{
 public:
   LastBagPolicy() = default;
 
@@ -75,13 +82,15 @@ public:
       typename common::DoubleTime::type /* t */,
       const common::ExternalEvent<common::DoubleTime> &event,
       typename common::DoubleTime::type /* tl */,
-      typename common::DoubleTime::type /* tn */) {
+      typename common::DoubleTime::type /* tn */)
+  {
     clear();
     push(event);
   }
 };
 
-class IgnorePolicy : public Policy {
+class IgnorePolicy : public Policy
+{
 public:
   IgnorePolicy() = default;
   virtual ~IgnorePolicy() = default;
@@ -90,7 +99,8 @@ public:
       typename common::DoubleTime::type /* t */,
       const common::ExternalEvent<common::DoubleTime> & /* event */,
       typename common::DoubleTime::type /* tl */,
-      typename common::DoubleTime::type /* tn */) {}
+      typename common::DoubleTime::type /* tn */)
+  {}
 };
 
 }

+ 38 - 19
src/artis-star/kernel/dtss/Simulator.hpp

@@ -42,19 +42,24 @@ class Simulator;
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Context {
+class Context
+{
   typedef dtss::Simulator<Time, Dynamics, Parameters> Simulator;
 
 public:
   Context(const Parameters &parameters, Simulator *simulator)
       :
-      _parameters(parameters), _simulator(simulator) {}
+      _parameters(parameters), _simulator(simulator)
+  {}
 
-  virtual ~Context() {}
+  virtual ~Context()
+  {}
 
-  const Parameters &parameters() const { return _parameters; }
+  const Parameters &parameters() const
+  { return _parameters; }
 
-  Simulator *simulator() const { return _simulator; }
+  Simulator *simulator() const
+  { return _simulator; }
 
 private:
   const Parameters &_parameters;
@@ -63,7 +68,8 @@ private:
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Simulator : public common::Simulator<Time> {
+class Simulator : public common::Simulator<Time>
+{
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public:
@@ -72,19 +78,24 @@ public:
       common::Model<Time>(name),
       common::Simulator<Time>(name),
       _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this)),
-      _time_step(parameters.time_step) {}
+      _time_step(parameters.time_step)
+  {}
 
-  ~Simulator() {}
+  ~Simulator()
+  {}
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     _dynamics.save(state);
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -99,7 +110,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -130,18 +142,22 @@ public:
     return type::_tn;
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _dynamics.lookahead(t);
   }
 
   common::Value observe(const typename Time::type &t,
-                        unsigned int index) const { return _dynamics.observe(t, index); }
+                        unsigned int index) const
+  { return _dynamics.observe(t, index); }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     return _dynamics.observable_name(observable_index);
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -178,7 +194,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -208,7 +225,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -242,7 +260,8 @@ public:
     return type::_tn;
   }
 
-  const typename Time::type &time_step() const { return _time_step; }
+  const typename Time::type &time_step() const
+  { return _time_step; }
 
 private :
   Dynamics _dynamics;

+ 8 - 4
src/artis-star/kernel/fddevs/Coordinator.hpp

@@ -37,7 +37,8 @@ template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
 class Coordinator
-    : public pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters> {
+    : public pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters>
+{
 public:
   Coordinator(const std::string &name, const Parameters &parameters,
               const GraphParameters &graph_parameters)
@@ -45,11 +46,14 @@ public:
       common::Model<Time>(name),
       pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters>(name,
                                                                           parameters,
-                                                                          graph_parameters) {}
+                                                                          graph_parameters)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "fddevs coordinator \""

+ 46 - 23
src/artis-star/kernel/fddevs/Dynamics.hpp

@@ -40,52 +40,68 @@ namespace artis {
 namespace fddevs {
 
 template<class Time, class Dyn, class StateValues, class Parameters = common::NoParameters>
-class Dynamics : public common::States<Time, Dyn> {
+class Dynamics : public common::States<Time, Dyn>
+{
   typedef fddevs::Simulator<Time, Dyn, Parameters> Simulator;
 
 public:
   Dynamics(const std::string &name, const Context<Time, Dyn, Parameters> &context)
       :
-      _name(name), _simulator(context.simulator()) {}
+      _name(name), _simulator(context.simulator())
+  {}
 
-  virtual ~Dynamics() {}
+  virtual ~Dynamics()
+  {}
 
   // definition
-  void initial_state(const StateValues &state) { _initial_state = state; }
+  void initial_state(const StateValues &state)
+  { _initial_state = state; }
 
   // < X, Y, S, s0, tau, delta_x, sigma, delta_tau, lambda >
-  virtual void delta_tau(typename Time::type /* t */) {}
+  virtual void delta_tau(typename Time::type /* t */)
+  {}
 
   virtual void delta_x(typename Time::type /* t */, typename Time::type /* e */,
-                       const common::Bag<Time> & /* bag */) {}
+                       const common::Bag<Time> & /* bag */)
+  {}
 
-  virtual void initial_state(typename Time::type /* time */) { state(_initial_state); }
+  virtual void initial_state(typename Time::type /* time */)
+  { state(_initial_state); }
 
   virtual common::Bag<Time>
-  lambda(typename Time::type /* time */) const { return common::Bag<Time>(); }
+  lambda(typename Time::type /* time */) const
+  { return common::Bag<Time>(); }
 
   virtual bool rho(typename Time::type /* time */,
-                   const common::Bag<common::DoubleTime> & /* bag */) const { return false; }
+                   const common::Bag<common::DoubleTime> & /* bag */) const
+  { return false; }
 
   virtual typename Time::type
-  tau(typename Time::type /* time */) const { return Time::infinity; }
+  tau(typename Time::type /* time */) const
+  { return Time::infinity; }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
   // observation
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const { return common::Value(); }
+                                unsigned int /* index */) const
+  { return common::Value(); }
 
   // structure
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void input_port(common::Port p) {
+  void input_port(common::Port p)
+  {
     _simulator->add_in_port(p);
   }
 
-  size_t input_port_number() const { return _simulator->get_in_port_number(); }
+  size_t input_port_number() const
+  { return _simulator->get_in_port_number(); }
 
-  void input_ports(std::initializer_list<common::Port> list) {
+  void input_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -93,13 +109,16 @@ public:
     }
   }
 
-  void output_port(common::Port p) {
+  void output_port(common::Port p)
+  {
     _simulator->add_out_port(p);
   }
 
-  size_t output_port_number() const { return _simulator->get_out_port_number(); }
+  size_t output_port_number() const
+  { return _simulator->get_out_port_number(); }
 
-  void output_ports(std::initializer_list<common::Port> list) {
+  void output_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it =
         list.begin(); it != list.end(); ++it) {
       _simulator->add_out_port(*it);
@@ -107,19 +126,23 @@ public:
   }
 
   // state
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
   }
 
-  void state(const StateValues &new_state) {
+  void state(const StateValues &new_state)
+  {
     _state = new_state;
   }
 
-  const StateValues &state() const { return _state; }
+  const StateValues &state() const
+  { return _state; }
 
 private:
   std::string _name;

+ 4 - 2
src/artis-star/kernel/fddevs/GraphManager.hpp

@@ -35,14 +35,16 @@ namespace fddevs {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters> {
+class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters>
+{
 public:
   GraphManager(common::Coordinator<Time> *coordinator,
                const Parameters &parameters,
                const GraphParameters &graph_parameters)
       :
       pdevs::GraphManager<Time, Parameters, GraphParameters>(coordinator, parameters,
-                                                             graph_parameters) {}
+                                                             graph_parameters)
+  {}
 
   ~GraphManager() override = default;
 };

+ 38 - 19
src/artis-star/kernel/fddevs/Simulator.hpp

@@ -43,19 +43,24 @@ class Simulator;
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Context {
+class Context
+{
   typedef fddevs::Simulator<Time, Dynamics, Parameters> Simulator;
 
 public:
   Context(const Parameters &parameters, Simulator *simulator)
       :
-      _parameters(parameters), _simulator(simulator) {}
+      _parameters(parameters), _simulator(simulator)
+  {}
 
-  virtual ~Context() {}
+  virtual ~Context()
+  {}
 
-  const Parameters &parameters() const { return _parameters; }
+  const Parameters &parameters() const
+  { return _parameters; }
 
-  Simulator *simulator() const { return _simulator; }
+  Simulator *simulator() const
+  { return _simulator; }
 
 private:
   const Parameters &_parameters;
@@ -64,7 +69,8 @@ private:
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Simulator : public common::Simulator<Time> {
+class Simulator : public common::Simulator<Time>
+{
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public :
@@ -72,23 +78,29 @@ public :
       :
       common::Model<Time>(name),
       common::Simulator<Time>(name),
-      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this)) {}
+      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this))
+  {}
 
-  ~Simulator() {}
+  ~Simulator()
+  {}
 
-  const Dynamics &dynamics() const { return _dynamics; }
+  const Dynamics &dynamics() const
+  { return _dynamics; }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "p-devs simulator \""
@@ -96,7 +108,8 @@ public :
     return ss.str();
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -111,7 +124,8 @@ public :
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message(t)
 //                  tl = t - e
 //                  tn = tl + ta(s)
@@ -152,9 +166,11 @@ public :
   }
 
   common::Value observe(const typename Time::type &t,
-                        unsigned int index) const { return _dynamics.observe(t, index); }
+                        unsigned int index) const
+  { return _dynamics.observe(t, index); }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message(t)
 //                  if (t = tn) then
 //                    y = lambda(s)
@@ -197,7 +213,8 @@ common::Trace<Time>::trace().flush();
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -227,7 +244,8 @@ common::Trace<Time>::trace().flush();
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message(t)
 //                  if (x is empty and t = tn) then
 //                    s = delta_int(s)
@@ -292,7 +310,8 @@ common::Trace<Time>::trace().flush();
     return type::_tn;
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _dynamics.lookahead(t);
   }
 

+ 10 - 5
src/artis-star/kernel/pdevs/Context.hpp

@@ -35,19 +35,24 @@ class Simulator;
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Context {
+class Context
+{
   typedef pdevs::Simulator<Time, Dynamics, Parameters> Simulator;
 
 public:
   Context(const Parameters &parameters, Simulator *simulator)
       :
-      _parameters(parameters), _simulator(simulator) {}
+      _parameters(parameters), _simulator(simulator)
+  {}
 
-  virtual ~Context() {}
+  virtual ~Context()
+  {}
 
-  const Parameters &parameters() const { return _parameters; }
+  const Parameters &parameters() const
+  { return _parameters; }
 
-  Simulator *simulator() const { return _simulator; }
+  Simulator *simulator() const
+  { return _simulator; }
 
 private:
   const Parameters &_parameters;

+ 34 - 17
src/artis-star/kernel/pdevs/Coordinator.hpp

@@ -42,7 +42,8 @@ template<class Time,
     class GraphManager,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class Coordinator : public common::Coordinator<Time> {
+class Coordinator : public common::Coordinator<Time>
+{
   typedef Coordinator<Time, GraphManager, Parameters, GraphParameters> type;
 
 public:
@@ -54,15 +55,20 @@ public:
       :
       common::Model<Time>(name),
       common::Coordinator<Time>(name),
-      _graph_manager(this, parameters, graph_parameters) {}
+      _graph_manager(this, parameters, graph_parameters)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  GraphManager &get_graph_manager() { return _graph_manager; }
+  GraphManager &get_graph_manager()
+  { return _graph_manager; }
 
-  const GraphManager &get_graph_manager() const { return _graph_manager; }
+  const GraphManager &get_graph_manager() const
+  { return _graph_manager; }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "p-devs coordinator \""
@@ -71,14 +77,16 @@ public:
     return ss.str();
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::Coordinator<Time>::restore(state);
     for (auto &child : _graph_manager.children()) {
       _event_table.init(child->get_tn(), child);
     }
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -93,7 +101,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message (i, t) at time t
 //                  for-each d ∈ D do
 //                    send i-message to child d
@@ -135,7 +144,8 @@ public:
     return type::_tn;
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message (*, t)
 //                  if t != tn then Error
 //                  IMM = {d | (d, th,d) ∈ (event-list & tn,d = tn) }
@@ -185,7 +195,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message (x, t)
 //                  if not (tl <= t <= tn) then Error
 //                  receivers = { r | r ∈ children, N ∈ Ir, Z(N,r)(x) isn't empty }
@@ -252,7 +263,8 @@ public:
     return type::_tn;
   }
 
-  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event) {
+  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -282,7 +294,8 @@ public:
   }
 
   typename Time::type dispatch_events(const common::Bag<Time> &bag,
-                                      const typename Time::type &t) {
+                                      const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -315,16 +328,19 @@ public:
   }
 
   common::Value observe(const typename Time::type & /* t */,
-                        unsigned int /* index */) const {
+                        unsigned int /* index */) const
+  {
     assert(false);
     return common::Value();
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _graph_manager.lookahead(t);
   }
 
-  common::Models<Time> get_receivers() const {
+  common::Models<Time> get_receivers() const
+  {
     common::Models<Time> receivers;
 
     for (auto &model : _graph_manager.children()) {
@@ -335,7 +351,8 @@ public:
     return receivers;
   }
 
-  void update_event_table(typename Time::type t) {
+  void update_event_table(typename Time::type t)
+  {
     for (auto &model : _graph_manager.children()) {
       if (model->event_number() > 0) {
         _event_table.put(t, model);

+ 48 - 24
src/artis-star/kernel/pdevs/Dynamics.hpp

@@ -40,11 +40,13 @@ namespace artis {
 namespace pdevs {
 
 template<class Time, class Dyn, class Parameters = common::NoParameters>
-class Dynamics : public common::States<Time, Dyn> {
+class Dynamics : public common::States<Time, Dyn>
+{
   typedef pdevs::Simulator<Time, Dyn, Parameters> Simulator;
 
 public:
-  struct Observable {
+  struct Observable
+  {
     unsigned int index;
     std::string name;
   };
@@ -53,42 +55,56 @@ public:
 
   Dynamics(const std::string &name, const Context<Time, Dyn, Parameters> &context)
       :
-      _name(name), _simulator(context.simulator()) {}
+      _name(name), _simulator(context.simulator())
+  {}
 
-  virtual ~Dynamics() {}
+  virtual ~Dynamics()
+  {}
 
   virtual void
   dconf(const typename Time::type & /* t */, const typename Time::type & /* e */,
-        const common::Bag<Time> & /* bag */) {}
+        const common::Bag<Time> & /* bag */)
+  {}
 
-  virtual void dint(const typename Time::type & /* t */) {}
+  virtual void dint(const typename Time::type & /* t */)
+  {}
 
   virtual void
   dext(const typename Time::type & /* t */, const typename Time::type & /* e */,
-       const common::Bag<Time> & /* bag */) {}
+       const common::Bag<Time> & /* bag */)
+  {}
 
-  virtual void start(const typename Time::type & /* time */) {}
+  virtual void start(const typename Time::type & /* time */)
+  {}
 
   virtual typename Time::type
-  ta(const typename Time::type & /* time */) const { return Time::infinity; }
+  ta(const typename Time::type & /* time */) const
+  { return Time::infinity; }
 
   virtual common::Bag<Time>
-  lambda(const typename Time::type & /* time */) const { return common::Bag<Time>(); }
+  lambda(const typename Time::type & /* time */) const
+  { return common::Bag<Time>(); }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const { return common::Value(); }
+                                unsigned int /* index */) const
+  { return common::Value(); }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void input_port(common::Port p) {
+  void input_port(common::Port p)
+  {
     _simulator->add_in_port(p);
   }
 
-  size_t input_port_number() const { return _simulator->get_in_port_number(); }
+  size_t input_port_number() const
+  { return _simulator->get_in_port_number(); }
 
-  void input_ports(std::initializer_list<common::Port> list) {
+  void input_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -96,11 +112,13 @@ public:
     }
   }
 
-  void observable(Observable observable) {
+  void observable(Observable observable)
+  {
     _observables[observable.index] = observable.name;
   }
 
-  void observables(std::initializer_list<Observable> list) {
+  void observables(std::initializer_list<Observable> list)
+  {
     for (typename std::initializer_list<Observable>::iterator it = list.begin();
          it != list.end();
          ++it) {
@@ -108,30 +126,36 @@ public:
     }
   }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     assert(_observables.find(observable_index) != _observables.end());
 
     return _observables.find(observable_index)->second;
   }
 
-  void output_port(common::Port p) {
+  void output_port(common::Port p)
+  {
     _simulator->add_out_port(p);
   }
 
-  size_t output_port_number() const { return _simulator->get_out_port_number(); }
+  size_t output_port_number() const
+  { return _simulator->get_out_port_number(); }
 
-  void output_ports(std::initializer_list<common::Port> list) {
+  void output_ports(std::initializer_list<common::Port> list)
+  {
     for (typename std::initializer_list<common::Port>::iterator it =
         list.begin(); it != list.end(); ++it) {
       _simulator->add_out_port(*it);
     }
   }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
   }
 

+ 32 - 16
src/artis-star/kernel/pdevs/GraphManager.hpp

@@ -42,11 +42,13 @@ namespace pdevs {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public common::GraphManager<Time> {
+class GraphManager : public common::GraphManager<Time>
+{
 public:
   typedef GraphManager<Time, Parameters, GraphParameters> type;
 
-  struct ModelPort {
+  struct ModelPort
+  {
     common::Model<Time> *model;
     unsigned int port_index;
     type *graph_manager;
@@ -54,9 +56,11 @@ public:
     ModelPort(common::Model<Time> *model, unsigned int port_index)
         : model(model),
           port_index(port_index),
-          graph_manager(nullptr) {}
+          graph_manager(nullptr)
+    {}
 
-    void operator>>(const ModelPort &dst) {
+    void operator>>(const ModelPort &dst)
+    {
       graph_manager->add_link(model, port_index, dst.model, dst.port_index);
     }
   };
@@ -65,21 +69,25 @@ public:
                const Parameters & /* parameters */,
                const GraphParameters & /* graph_parameters */)
       :
-      common::GraphManager<Time>(coordinator) {}
+      common::GraphManager<Time>(coordinator)
+  {}
 
   ~GraphManager() override = default;
 
-  ModelPort in(ModelPort p) {
+  ModelPort in(ModelPort p)
+  {
     p.graph_manager = this;
     return p;
   }
 
-  ModelPort out(ModelPort p) {
+  ModelPort out(ModelPort p)
+  {
     p.graph_manager = this;
     return p;
   }
 
-  void dispatch_events(common::Bag<Time> bag, typename Time::type t) {
+  void dispatch_events(common::Bag<Time> bag, typename Time::type t)
+  {
     for (auto &ymsg : bag) {
       typename common::Links<Time>::Result result_model = _link_list.find(
           ymsg.get_model(),
@@ -100,7 +108,8 @@ public:
 
   virtual void
   dispatch_events_to_parent(common::Node<Time> node, const common::Value &content,
-                            typename Time::type t) {
+                            typename Time::type t)
+  {
     common::Bag<Time> ymessages;
 
     ymessages.push_back(common::ExternalEvent<Time>(node, content));
@@ -113,13 +122,16 @@ public:
   }
 
   bool exist_link(common::Model<Time> *src_model, unsigned int src_port_index,
-                  common::Model<Time> *dst_model, unsigned int dst_port_index) const {
+                  common::Model<Time> *dst_model, unsigned int dst_port_index) const
+  {
     return _link_list.exist(src_model, src_port_index, dst_model, dst_port_index);
   }
 
-  virtual typename Time::type lookahead(const typename Time::type &t) const { return t; }
+  virtual typename Time::type lookahead(const typename Time::type &t) const
+  { return t; }
 
-  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event) {
+  void post_event(typename Time::type t, const common::ExternalEvent<Time> &event)
+  {
     typename common::Links<Time>::Result result =
         _link_list.find(common::GraphManager<Time>::_coordinator,
                         event.port_index());
@@ -132,7 +144,8 @@ public:
     }
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "Children :" << std::endl;
@@ -145,19 +158,22 @@ public:
 
 protected:
   void remove_link(common::Model<Time> *src_model, unsigned int src_port_index,
-                   common::Model<Time> *dst_model, unsigned int dst_port_index) {
+                   common::Model<Time> *dst_model, unsigned int dst_port_index)
+  {
     assert(exist_link(src_model, src_port_index, dst_model, dst_port_index));
 
     _link_list.remove(src_model, src_port_index, dst_model, dst_port_index);
   }
 
-  void remove_links(common::Model<Time> *model) {
+  void remove_links(common::Model<Time> *model)
+  {
     _link_list.remove_links(model);
   }
 
 private:
   void add_link(common::Model<Time> *src_model, unsigned int src_port_index,
-                common::Model<Time> *dst_model, unsigned int dst_port_index) {
+                common::Model<Time> *dst_model, unsigned int dst_port_index)
+  {
     assert((src_model != common::GraphManager<Time>::_coordinator and
         dst_model != common::GraphManager<Time>::_coordinator and
         src_model->exist_out_port(src_port_index) and

+ 30 - 15
src/artis-star/kernel/pdevs/Simulator.hpp

@@ -39,7 +39,8 @@ namespace pdevs {
 
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
-class Simulator : public common::Simulator<Time> {
+class Simulator : public common::Simulator<Time>
+{
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public :
@@ -47,23 +48,29 @@ public :
       :
       common::Model<Time>(name),
       common::Simulator<Time>(name),
-      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this)) {}
+      _dynamics(name, Context<Time, Dynamics, Parameters>(parameters, this))
+  {}
 
-  ~Simulator() {}
+  ~Simulator()
+  {}
 
-  const Dynamics &dynamics() const { return _dynamics; }
+  const Dynamics &dynamics() const
+  { return _dynamics; }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     std::ostringstream ss;
 
     ss << common::String::make_spaces(level * 2) << "p-devs simulator \""
@@ -71,7 +78,8 @@ public :
     return ss.str();
   }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #else
@@ -84,7 +92,8 @@ public :
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 //                When i-message(t)
 //                  tl = t - e
 //                  tn = tl + ta(s)
@@ -124,15 +133,18 @@ public :
     return type::_tn;
   }
 
-  common::Value observe(const typename Time::type &t, unsigned int index) const {
+  common::Value observe(const typename Time::type &t, unsigned int index) const
+  {
     return _dynamics.observe(t, index);
   }
 
-  virtual std::string observable_name(unsigned int observable_index) const {
+  virtual std::string observable_name(unsigned int observable_index) const
+  {
     return _dynamics.observable_name(observable_index);
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 //                When *-message(t)
 //                  if (t = tn) then
 //                    y = lambda(s)
@@ -173,7 +185,8 @@ public :
 
   }
 
-  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event) {
+  void post_event(const typename Time::type &t, const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -201,7 +214,8 @@ public :
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 //                When x-message(t)
 //                  if (x is empty and t = tn) then
 //                    s = delta_int(s)
@@ -258,7 +272,8 @@ public :
     return type::_tn;
   }
 
-  typename Time::type lookahead(const typename Time::type &t) const {
+  typename Time::type lookahead(const typename Time::type &t) const
+  {
     return _dynamics.lookahead(t);
   }
 

+ 10 - 5
src/artis-star/kernel/pdevs/mpi/Coordinator.hpp

@@ -39,7 +39,8 @@ template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
 class Coordinator : public pdevs::Coordinator<Time, GraphManager,
-                                              Parameters, GraphParameters> {
+                                              Parameters, GraphParameters>
+{
   typedef pdevs::Coordinator<Time, GraphManager,
                              Parameters, GraphParameters> parent_type;
   typedef Coordinator<Time, GraphManager,
@@ -53,13 +54,17 @@ public:
       common::Model<Time>(name),
       pdevs::Coordinator<Time, GraphManager,
                          Parameters, GraphParameters>(name, parameters,
-                                                      graph_parameters) {}
+                                                      graph_parameters)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  virtual bool is_remote() const { return true; }
+  virtual bool is_remote() const
+  { return true; }
 
-  void set_logical_processor(LogicalProcessor<Time> *logical_processor) {
+  void set_logical_processor(LogicalProcessor<Time> *logical_processor)
+  {
     parent_type::_graph_manager.set_logical_processor(logical_processor);
   }
 };

+ 10 - 5
src/artis-star/kernel/pdevs/mpi/GraphManager.hpp

@@ -39,24 +39,29 @@ namespace mpi {
 template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
-class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters> {
+class GraphManager : public pdevs::GraphManager<Time, Parameters, GraphParameters>
+{
 public:
   GraphManager(common::Coordinator<Time> *coordinator,
                const Parameters &parameters,
                const GraphParameters &graph_parameters)
       :
-      pdevs::GraphManager<Time, GraphParameters>(coordinator, parameters, graph_parameters) {}
+      pdevs::GraphManager<Time, GraphParameters>(coordinator, parameters, graph_parameters)
+  {}
 
-  virtual ~GraphManager() {}
+  virtual ~GraphManager()
+  {}
 
   virtual void dispatch_events_to_parent(common::Node<Time> node,
                                          const common::Value &content,
-                                         typename Time::type t) {
+                                         typename Time::type t)
+  {
     _logical_processor->dispatch_events_to_parent(node, content, t);
   }
 
   void set_logical_processor(
-      LogicalProcessor<Time> *logical_processor) { _logical_processor = logical_processor; }
+      LogicalProcessor<Time> *logical_processor)
+  { _logical_processor = logical_processor; }
 
 private:
   LogicalProcessor<Time> *_logical_processor;

+ 10 - 5
src/artis-star/kernel/pdevs/mpi/LogicalProcessor.hpp

@@ -36,7 +36,8 @@ namespace pdevs {
 namespace mpi {
 
 template<class Time>
-class LogicalProcessor {
+class LogicalProcessor
+{
   typedef LogicalProcessor<Time> type;
 
 public:
@@ -44,20 +45,24 @@ public:
       :
       _rank(rank),
       _parent(parent),
-      _model(model) {}
+      _model(model)
+  {}
 
-  virtual ~LogicalProcessor() {}
+  virtual ~LogicalProcessor()
+  {}
 
   void dispatch_events_to_parent(common::Node<Time> node,
                                  const common::Value &content,
-                                 typename Time::type t) {
+                                 typename Time::type t)
+  {
     (void) t;
 
     _output_bag.push_back(
         common::ExternalEvent<Time>(node, content));
   }
 
-  void loop() {
+  void loop()
+  {
     typename Time::type t;
 
     for (;;) {

+ 30 - 15
src/artis-star/kernel/pdevs/mpi/ModelProxy.hpp

@@ -36,7 +36,8 @@ namespace artis {
 namespace pdevs {
 namespace mpi {
 
-enum Tags {
+enum Tags
+{
   finish_send_tag,
   output_send_tag,
   post_event_send_tag,
@@ -47,37 +48,46 @@ enum Tags {
 };
 
 template<class Time>
-class ModelProxy : public common::Model<Time> {
+class ModelProxy : public common::Model<Time>
+{
   typedef common::Model<Time> parent_type;
   typedef ModelProxy<Time> type;
 
 public:
   ModelProxy(const std::string &name, int rank, bool atomic)
       :
-      common::Model<Time>(name), _atomic(atomic), _rank(rank) {}
+      common::Model<Time>(name), _atomic(atomic), _rank(rank)
+  {}
 
-  virtual ~ModelProxy() { _communicator.send(_rank, finish_send_tag); }
+  virtual ~ModelProxy()
+  { _communicator.send(_rank, finish_send_tag); }
 
-  virtual bool is_atomic() const { return _atomic; }
+  virtual bool is_atomic() const
+  { return _atomic; }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
 // TODO
   }
 
-  virtual void save(common::context::State<Time> &state) const {
+  virtual void save(common::context::State<Time> &state) const
+  {
 // TODO
   }
 
-  virtual std::string to_string(int level) const {
+  virtual std::string to_string(int level) const
+  {
     (void) level;
 
     return std::string();
   }
 
-  virtual void finish(const typename Time::type & /* t */) {}
+  virtual void finish(const typename Time::type & /* t */)
+  {}
 
   virtual common::Value observe(const typename Time::type &t,
-                                unsigned int index) const {
+                                unsigned int index) const
+  {
     (void) t;
     (void) index;
 
@@ -86,7 +96,8 @@ public:
     return common::Value();
   }
 
-  virtual void output(const typename Time::type &t) {
+  virtual void output(const typename Time::type &t)
+  {
     try {
       typename common::Bag<Time> bag;
 
@@ -100,7 +111,8 @@ public:
   }
 
   virtual void post_event(const typename Time::type &t,
-                          const common::ExternalEvent<Time> &event) {
+                          const common::ExternalEvent<Time> &event)
+  {
     try {
       _communicator.send(_rank, post_event_send_tag, t);
       _communicator.send(_rank, post_event_send_tag, event);
@@ -111,7 +123,8 @@ public:
   }
 
   virtual typename Time::type dispatch_events(common::Bag<Time> &bag,
-                                              const typename Time::type &t) {
+                                              const typename Time::type &t)
+  {
     for (auto &event : bag) {
       event.set_model(this);
     }
@@ -119,7 +132,8 @@ public:
         parent_type::get_parent())->dispatch_events(bag, t);
   }
 
-  virtual typename Time::type start(const typename Time::type &t) {
+  virtual typename Time::type start(const typename Time::type &t)
+  {
     try {
       _communicator.send(_rank, start_send_tag, t);
 
@@ -135,7 +149,8 @@ public:
     return type::_tn;
   }
 
-  virtual typename Time::type transition(const typename Time::type &t) {
+  virtual typename Time::type transition(const typename Time::type &t)
+  {
     try {
       _communicator.send(_rank, transition_send_tag, t);
 

+ 36 - 18
src/artis-star/kernel/pdevs/multithreading/Coordinator.hpp

@@ -37,38 +37,46 @@ namespace pdevs {
 namespace multithreading {
 
 template<class Time>
-struct start_message {
+struct start_message
+{
   explicit start_message(typename Time::type t)
-      : _t(t) {}
+      : _t(t)
+  {}
 
   typename Time::type _t;
 };
 
 template<class Time>
-struct transition_message {
+struct transition_message
+{
   explicit transition_message(typename Time::type t)
-      : _t(t) {}
+      : _t(t)
+  {}
 
   typename Time::type _t;
 };
 
 template<class Time>
-struct done_start_message {
+struct done_start_message
+{
   explicit done_start_message(typename Time::type tn,
                               common::Model<Time> *child)
       :
-      _tn(tn), _child(child) {}
+      _tn(tn), _child(child)
+  {}
 
   typename Time::type _tn;
   common::Model<Time> *_child;
 };
 
 template<class Time>
-struct done_transition_message {
+struct done_transition_message
+{
   explicit done_transition_message(typename Time::type tn,
                                    common::Model<Time> *child)
       :
-      _tn(tn), _child(child) {}
+      _tn(tn), _child(child)
+  {}
 
   typename Time::type _tn;
   common::Model<Time> *_child;
@@ -79,7 +87,8 @@ template<class Time,
     class Parameters = common::NoParameters,
     class GraphParameters = common::NoParameters>
 class Coordinator
-    : public pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters> {
+    : public pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters>
+{
   typedef pdevs::Coordinator<Time, GraphManager,
                              Parameters, GraphParameters> parent_type;
   typedef Coordinator<Time, GraphManager,
@@ -95,24 +104,30 @@ public:
       :
       common::Model<Time>(name),
       pdevs::Coordinator<Time, GraphManager, Parameters, GraphParameters>(
-          name, parameters, graph_parameters) {
+          name, parameters, graph_parameters)
+  {
     type::_graph_manager.init();
     _thread = new std::thread([&] { loop(); });
   }
 
-  virtual ~Coordinator() {
+  virtual ~Coordinator()
+  {
     done();
     _thread->join();
     delete _thread;
   }
 
-  void done() { get_sender().send(artis::common::Close()); }
+  void done()
+  { get_sender().send(artis::common::Close()); }
 
-  artis::common::Sender get_sender() { return _incoming.get_sender(); }
+  artis::common::Sender get_sender()
+  { return _incoming.get_sender(); }
 
-  void set_sender(common::Sender sender) { _sender = sender; }
+  void set_sender(common::Sender sender)
+  { _sender = sender; }
 
-  void loop() {
+  void loop()
+  {
     try {
       for (;;) {
         _incoming.wait()
@@ -152,7 +167,8 @@ public:
     }
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
     _received = 0;
     for (auto &child : parent_type::_graph_manager.children()) {
       if (child->is_atomic()) {
@@ -175,11 +191,13 @@ public:
   }
 
   // TODO: to remove
-  virtual int get_receiver_number(typename Time::type t) {
+  virtual int get_receiver_number(typename Time::type t)
+  {
     return type::_event_table.get_current_models(t).size();
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
     assert(t >= type::_tl and t <= type::_tn);
 
     common::Models<Time> receivers = type::get_receivers();

+ 1 - 1
src/artis-star/kernel/qss/CMakeLists.txt

@@ -6,6 +6,6 @@ INCLUDE_DIRECTORIES(
 LINK_DIRECTORIES(
         ${Boost_LIBRARY_DIRS})
 
-SET(QSS_HPP Data.hpp Derivative.hpp Integrator.hpp Quantifier.hpp)
+SET(QSS_HPP Data.hpp Derivative.hpp Integrator.hpp MultiDerivative.hpp Quantifier.hpp)
 
 INSTALL(FILES ${QSS_HPP} DESTINATION ${ARTIS_INCLUDE_DIRS}/kernel/qss)

+ 6 - 3
src/artis-star/kernel/qss/Data.hpp

@@ -30,15 +30,18 @@
 namespace artis {
 namespace qss {
 
-struct IntegratorData {
+struct IntegratorData
+{
   double value;
 };
 
-struct DerivativeData {
+struct DerivativeData
+{
   double x_dot;
 };
 
-struct QuantifierData {
+struct QuantifierData
+{
   double up;
   double down;
 };

+ 107 - 72
src/artis-star/kernel/qss/Derivative.hpp

@@ -34,22 +34,31 @@ namespace artis {
 namespace qss {
 
 template<class Time, class Dyn, class Parameters = common::NoParameters>
-class Derivative : public artis::pdevs::Dynamics<Time, Dyn, Parameters> {
-  typedef enum {
-    INIT = 0, WAIT, RESPONSE
-  } State;
-
+class Derivative : public artis::pdevs::Dynamics<Time, Dyn, Parameters>
+{
 public:
-  enum inputs {
-    RESET = 0, IN
+  struct input
+  {
+    enum values
+    {
+      RESET = 0, IN
+    };
   };
 
-  enum outputs {
-    OUT = 0
+  struct output
+  {
+    enum values
+    {
+      OUT = 0
+    };
   };
 
-  enum states {
-    STATE = 0, INPUT_NUMBER, OUTPUT_VALUE, LAST_OUTPUT
+  struct var
+  {
+    enum values
+    {
+      VALUE
+    };
   };
 
   typedef Derivative<Time, Dyn, Parameters> type;
@@ -57,134 +66,160 @@ public:
   Derivative(const std::string &name, const artis::pdevs::Context<Time, Dyn, Parameters> &context)
       :
       artis::pdevs::Dynamics<Time, Dyn, Parameters>(name, context),
-      _external_number(0), _internal_number(0) {
+      _external_number(0), _internal_number(0)
+  {
     DECLARE_STATES(int,
-                   ((STATE, &type::_state)));
+                   ((state::PHASE, &type::_phase)));
     DECLARE_STATES(unsigned int,
-                   ((INPUT_NUMBER, &type::_input_number)));
+                   ((state::INPUT_NUMBER, &type::_input_number)));
     DECLARE_STATES(double,
-                   ((OUTPUT_VALUE, &type::_output_value),
-                       (LAST_OUTPUT, &type::_output_value)));
+                   ((state::OUTPUT_VALUE, &type::_output_value),
+                       (state::LAST_OUTPUT, &type::_last_output)));
 
-    this->input_ports({{RESET, "reset"},
-                       {IN, "in"}});
-    this->output_port({OUT, "out"});
+    this->input_ports({{input::RESET, "reset"},
+                       {input::IN, "in"}});
+    this->output_port({output::OUT, "out"});
+    this->observable({var::VALUE, "value"});
   }
 
-  virtual ~Derivative() {}
+  virtual ~Derivative()
+  {}
 
-  int external(const std::string &name, double Dyn::* var) {
+  int external(const std::string &name, double Dyn::* var)
+  {
     ++_external_number;
-    this->state_(LAST_OUTPUT + _external_number + 1, name, var);
-    this->input_port({IN + _external_number, name});
-    return IN + _external_number;
+    this->state_(state::LAST_OUTPUT + _external_number + 1, name, var);
+    this->input_port({input::IN + _external_number, name});
+    return input::IN + _external_number;
   }
 
-  void internal(const std::string &name, double Dyn::* var) {
+  void internal(const std::string &name, double Dyn::* var)
+  {
     assert(_internal_number == 0);
 
     ++_internal_number;
-    this->state_(LAST_OUTPUT + 1, name, var);
+    this->state_(state::LAST_OUTPUT + 1, name, var);
   }
 
   virtual double compute() const = 0;
 
   virtual void dconf(const typename Time::type &t, typename Time::type e,
-                     const common::Bag<Time> &bag) {
+                     const common::Bag<Time> &bag)
+  {
     dint(t);
     dext(t, e, bag);
   }
 
-  virtual void dint(const typename Time::type & /* time */) {
-    if (_state == RESPONSE) {
+  virtual void dint(const typename Time::type & /* time */)
+  {
+    if (_phase == phase::RESPONSE) {
       _last_output = _output_value;
     }
-    _state = WAIT;
+    _phase = phase::WAIT;
   }
 
   virtual void dext(const typename Time::type &t, typename Time::type e,
-                    const common::Bag<Time> &bag) {
+                    const common::Bag<Time> &bag)
+  {
     std::for_each(bag.begin(), bag.end(),
                   [this, t, e](const common::ExternalEvent<Time> &event) {
-                    if (event.on_port(RESET)) {
-                      if (_input_number == 0) {
-                        _output_value = compute();
-                        _state = RESPONSE;
-                      } else {
-                        _state = INIT;
-                      }
+                    if (event.on_port(input::RESET)) {
+                      _input_number = 0;
+                      _phase = phase::INIT;
                     } else {
                       IntegratorData data;
 
                       event.data()(data);
-                      this->get((event.port_index() - 1) + LAST_OUTPUT + 1).put(
-                          dynamic_cast<Dyn *>(this),
-                          data.value);
-                      switch (_state) {
-                      case INIT:
-                        if (_input_number
-                            == this->state_number() - (LAST_OUTPUT + 1)) {
+                      this->get((event.port_index() - 1) + state::LAST_OUTPUT + 1).put(
+                          dynamic_cast<Dyn *>(this), data.value);
+                      switch (_phase) {
+                      case phase::INIT: {
+                        ++_input_number;
+                        if (_input_number == this->state_number() - (state::LAST_OUTPUT + 1)) {
                           _output_value = compute();
-                          _state = RESPONSE;
+                          _phase = phase::RESPONSE;
                         }
                         break;
-                      case WAIT:
-                      case RESPONSE:double value = compute();
+                      }
+                      case phase::WAIT:
+                      case phase::RESPONSE: {
+                        double value = compute();
 
                         if (value != _last_output) {
                           _output_value = value;
-                          _state = RESPONSE;
+                          _phase = phase::RESPONSE;
                         } else {
-                          _state = WAIT;
+                          _phase = phase::WAIT;
                         }
                       }
+                      }
                     }
                   });
   }
 
-  virtual void start(const typename Time::type & /* time */) {
-    _input_number = this->input_port_number() - 1;
-    if (_input_number == 0) {
-      _output_value = compute();
-      _state = RESPONSE;
-    } else {
-      _state = INIT;
-    }
+  virtual void start(const typename Time::type & /* time */)
+  {
+    _input_number = 0;
+    _phase = phase::INIT;
   }
 
-  virtual typename Time::type ta(const typename Time::type & /* time */) {
-    switch (_state) {
-    case INIT:return Time::infinity;
-    case WAIT:return Time::infinity;
-    case RESPONSE:return 0;
+  virtual typename Time::type ta(const typename Time::type & /* time */)
+  {
+    switch (_phase) {
+    case phase::INIT:return Time::infinity;
+    case phase::WAIT:return Time::infinity;
+    case phase::RESPONSE:return 0;
     }
     return Time::infinity;
   }
 
-  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const {
+  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const
+  {
     common::Bag<Time> msgs;
 
-    switch (_state) {
-    case INIT:break;
-    case WAIT:break;
-    case RESPONSE:const DerivativeData data = {_output_value};
+    switch (_phase) {
+    case phase::INIT:break;
+    case phase::WAIT:break;
+    case phase::RESPONSE: {
+      const DerivativeData data = {_output_value};
 
-      msgs.push_back(common::ExternalEvent<Time>(OUT, data));
+      msgs.push_back(common::ExternalEvent<Time>(output::OUT, data));
+    }
     }
     return msgs;
   }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int /* index */) const {
-    return common::Value();
+                                unsigned int index) const
+  {
+    switch (index) {
+    case var::VALUE:return (double) (_output_value);
+    default:return common::Value();
+    }
   }
 
 private:
+  struct phase
+  {
+    enum values
+    {
+      INIT = 0, WAIT, RESPONSE
+    };
+  };
+
+  struct state
+  {
+    enum values
+    {
+      PHASE = 0, INPUT_NUMBER, OUTPUT_VALUE, LAST_OUTPUT
+    };
+  };
+
   unsigned int _external_number;
   unsigned int _internal_number;
 
   // state
-  int _state;
+  int _phase;
   unsigned int _input_number;
   double _output_value;
   double _last_output;

+ 117 - 85
src/artis-star/kernel/qss/Integrator.hpp

@@ -33,88 +33,84 @@
 namespace artis {
 namespace qss {
 
-struct IntegratorParameters {
+struct IntegratorParameters
+{
   double x_0;
 };
 
 template<class Time>
 class Integrator
-    : public artis::pdevs::Dynamics<Time, Integrator<Time>, IntegratorParameters> {
-
-  typedef enum {
-    INIT,
-    WAIT_FOR_QUANTA,
-    WAIT_FOR_X_DOT,
-    WAIT_FOR_BOTH,
-    RUNNING
-  } State;
-
+    : public artis::pdevs::Dynamics<Time, Integrator<Time>, IntegratorParameters>
+{
 public:
-  enum inputs {
-    QUANTA, X_DOT, RESET
+  struct input
+  {
+    enum values
+    {
+      QUANTA, X_DOT, RESET
+    };
   };
 
-  enum outputs {
-    OUT
+  struct output
+  {
+    enum values
+    {
+      OUT
+    };
   };
 
-  typedef enum vars {
-    VALUE
-  } Observable;
-
-  enum states {
-    STATE,
-    LAST_OUT_DATE,
-    UP_THRESHOLD,
-    DOWN_THRESHOLD,
-    LAST_OUT_VALUE,
-    INIT_VALUE,
-    CURRENT_VALUE,
-    EXPECTED_VALUE,
-    ARCHIVE_X_DOT,
-    ARCHIVE_DATE
+  struct var
+  {
+    enum values
+    {
+      VALUE
+    };
   };
 
   Integrator(const std::string &name,
              const artis::pdevs::Context<Time, Integrator<Time>, IntegratorParameters> &context)
       :
       artis::pdevs::Dynamics<Time, Integrator<Time>, IntegratorParameters>(name,
-                                                                           context) {
-    DECLARE_STATES(int, ((STATE, &Integrator<Time>::_state)));
+                                                                           context)
+  {
+    DECLARE_STATES(int, ((state::PHASE, &Integrator<Time>::_phase)));
     DECLARE_STATES(typename Time::type,
-                   ((LAST_OUT_DATE, &Integrator<Time>::_last_output_date)));
-    DECLARE_STATES(double, ((UP_THRESHOLD, &Integrator<Time>::_up_threshold),
-        (DOWN_THRESHOLD, &Integrator<Time>::_down_threshold),
-        (LAST_OUT_VALUE, &Integrator<Time>::_last_output_value),
-        (INIT_VALUE, &Integrator<Time>::_init_value),
-        (CURRENT_VALUE, &Integrator<Time>::_current_value),
-        (EXPECTED_VALUE, &Integrator<Time>::_expected_value)));
+                   ((state::LAST_OUT_DATE, &Integrator<Time>::_last_output_date)));
+    DECLARE_STATES(double, ((state::UP_THRESHOLD, &Integrator<Time>::_up_threshold),
+        (state::DOWN_THRESHOLD, &Integrator<Time>::_down_threshold),
+        (state::LAST_OUT_VALUE, &Integrator<Time>::_last_output_value),
+        (state::INIT_VALUE, &Integrator<Time>::_init_value),
+        (state::CURRENT_VALUE, &Integrator<Time>::_current_value),
+        (state::EXPECTED_VALUE, &Integrator<Time>::_expected_value)));
     DECLARE_STATES(std::vector<double>,
-                   ((ARCHIVE_X_DOT, &Integrator<Time>::_archive_x_dot)));
+                   ((state::ARCHIVE_X_DOT, &Integrator<Time>::_archive_x_dot)));
     DECLARE_STATES(std::vector<typename Time::type>,
-                   ((ARCHIVE_DATE, &Integrator<Time>::_archive_date)));
+                   ((state::ARCHIVE_DATE, &Integrator<Time>::_archive_date)));
 
     this->input_ports({
-                          {QUANTA, "quanta"},
-                          {X_DOT, "x_dot"},
-                          {RESET, "reset"}});
-    this->output_port({OUT, "out"});
-    this->observable({VALUE, "value"});
+                          {input::QUANTA, "quanta"},
+                          {input::X_DOT, "x_dot"},
+                          {input::RESET, "reset"}});
+    this->output_port({output::OUT, "out"});
+    this->observable({var::VALUE, "value"});
 
     _init_value = context.parameters().x_0;
   }
 
-  virtual ~Integrator() {}
+  virtual ~Integrator()
+  {}
 
   virtual void dconf(typename Time::type t, typename Time::type e,
-                     const common::Bag<Time> &bag) {
+                     const common::Bag<Time> &bag)
+  {
     dint(t);
     dext(t, e, bag);
   }
 
-  virtual void dint(const typename Time::type &time) {
-    switch (_state) {
-    case RUNNING: {
+  virtual void dint(const typename Time::type &time)
+  {
+    switch (_phase) {
+    case phase::RUNNING: {
       double last_derivative_value = _archive_x_dot.back();
 
       _last_output_value = _expected_value;
@@ -124,11 +120,11 @@ public:
       _archive_x_dot.push_back(last_derivative_value);
       _archive_date.push_back(time);
       _current_value = _expected_value;
-      _state = WAIT_FOR_QUANTA;
+      _phase = phase::WAIT_FOR_QUANTA;
       break;
     }
-    case INIT: {
-      _state = WAIT_FOR_BOTH;
+    case phase::INIT: {
+      _phase = phase::WAIT_FOR_BOTH;
       _last_output_value = _current_value;
       _last_output_date = time;
       break;
@@ -138,36 +134,37 @@ public:
   }
 
   virtual void dext(const typename Time::type &t, const typename Time::type &e,
-                    const common::Bag<Time> &bag) {
+                    const common::Bag<Time> &bag)
+  {
     bool reset = false;
 
     std::for_each(bag.begin(), bag.end(),
                   [this, t, e, &reset](const common::ExternalEvent<Time> &event) {
-                    if (event.on_port(QUANTA)) {
+                    if (event.on_port(input::QUANTA)) {
                       QuantifierData data;
 
                       event.data()(data);
                       _up_threshold = data.up;
                       _down_threshold = data.down;
-                      if (_state == WAIT_FOR_QUANTA) {
-                        _state = RUNNING;
+                      if (_phase == phase::WAIT_FOR_QUANTA) {
+                        _phase = phase::RUNNING;
                       }
-                      if (_state == WAIT_FOR_BOTH) {
-                        _state = WAIT_FOR_X_DOT;
+                      if (_phase == phase::WAIT_FOR_BOTH) {
+                        _phase = phase::WAIT_FOR_X_DOT;
                       }
-                    } else if (event.on_port(X_DOT)) {
+                    } else if (event.on_port(input::X_DOT)) {
                       DerivativeData data;
 
                       event.data()(data);
                       _archive_x_dot.push_back(data.x_dot);
                       _archive_date.push_back(t);
-                      if (_state == WAIT_FOR_X_DOT) {
-                        _state = RUNNING;
+                      if (_phase == phase::WAIT_FOR_X_DOT) {
+                        _phase = phase::RUNNING;
                       }
-                      if (_state == WAIT_FOR_BOTH) {
-                        _state = WAIT_FOR_QUANTA;
+                      if (_phase == phase::WAIT_FOR_BOTH) {
+                        _phase = phase::WAIT_FOR_QUANTA;
                       }
-                    } else if (event.on_port(RESET)) {
+                    } else if (event.on_port(input::RESET)) {
                       IntegratorData data;
 
                       event.data()(data);
@@ -178,26 +175,28 @@ public:
                     }
                   });
     if (reset) {
-      _state = INIT;
+      _phase = phase::INIT;
     } else {
-      if (_state == RUNNING) {
+      if (_phase == phase::RUNNING) {
         _current_value = current_value(t);
         _expected_value = expected_value(t);
       }
     }
   }
 
-  virtual void start(const typename Time::type & /* time */) {
+  virtual void start(const typename Time::type & /* time */)
+  {
     _current_value = _init_value;
-    _state = INIT;
+    _phase = phase::INIT;
   }
 
-  virtual typename Time::type ta(const typename Time::type & /* time */) {
+  virtual typename Time::type ta(const typename Time::type & /* time */)
+  {
     double current_derivative;
 
-    switch (_state) {
-    case INIT:return 0;
-    case RUNNING:
+    switch (_phase) {
+    case phase::INIT:return 0;
+    case phase::RUNNING:
 
       assert(_archive_date.size() > 0);
 
@@ -220,20 +219,21 @@ public:
     }
   }
 
-  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const {
+  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const
+  {
     common::Bag<Time> msgs;
 
-    switch (_state) {
-    case RUNNING: {
+    switch (_phase) {
+    case phase::RUNNING: {
       const IntegratorData data = {_expected_value};
 
-      msgs.push_back(common::ExternalEvent<Time>(OUT, data));
+      msgs.push_back(common::ExternalEvent<Time>(output::OUT, data));
       break;
     }
-    case INIT: {
+    case phase::INIT: {
       const IntegratorData data = {_current_value};
 
-      msgs.push_back(common::ExternalEvent<Time>(OUT, data));
+      msgs.push_back(common::ExternalEvent<Time>(output::OUT, data));
       break;
     }
     default:break;
@@ -242,15 +242,17 @@ public:
   }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int index) const {
+                                unsigned int index) const
+  {
     switch (index) {
-    case VALUE:return (double) (_current_value);
+    case var::VALUE:return (double) (_current_value);
     default:return common::Value();
     }
   }
 
 private:
-  double current_value(const typename Time::type &time) const {
+  double current_value(const typename Time::type &time) const
+  {
     double val = _last_output_value;
 
     if (_archive_date.size() > 0) {
@@ -263,7 +265,8 @@ private:
     return val;
   }
 
-  double expected_value(const typename Time::type & /* time */) const {
+  double expected_value(const typename Time::type & /* time */) const
+  {
     double current_derivative = _archive_x_dot.back();
 
     if (current_derivative == 0) {
@@ -274,7 +277,36 @@ private:
     return _down_threshold;
   }
 
-  int _state;
+  struct phase
+  {
+    enum values
+    {
+      INIT,
+      WAIT_FOR_QUANTA,
+      WAIT_FOR_X_DOT,
+      WAIT_FOR_BOTH,
+      RUNNING
+    };
+  };
+
+  struct state
+  {
+    enum values
+    {
+      PHASE,
+      LAST_OUT_DATE,
+      UP_THRESHOLD,
+      DOWN_THRESHOLD,
+      LAST_OUT_VALUE,
+      INIT_VALUE,
+      CURRENT_VALUE,
+      EXPECTED_VALUE,
+      ARCHIVE_X_DOT,
+      ARCHIVE_DATE
+    };
+  };
+
+  int _phase;
 
   typename Time::type _last_output_date;
 

+ 275 - 0
src/artis-star/kernel/qss/MultiDerivative.hpp

@@ -0,0 +1,275 @@
+/**
+ * @file kernel/qss/MultiDerivative.hpp
+ * @author The ARTIS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * ARTIS - the multimodeling and simulation environment
+ * This file is a part of the ARTIS environment
+ *
+ * Copyright (C) 2013-2019 ULCO http://www.univ-littoral.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 QSS_MULTI_DERIVATIVE
+#define QSS_MULTI_DERIVATIVE
+
+#include <artis-star/kernel/pdevs/Dynamics.hpp>
+
+namespace artis {
+namespace qss {
+
+template<class Time, class Dyn, class Parameters = common::NoParameters>
+class MultiDerivative : public artis::pdevs::Dynamics<Time, Dyn, Parameters>
+{
+public:
+  struct input
+  {
+    enum values
+    {
+      RESET = 0, INTERNAL = 1, EXTERNAL = 1000
+    };
+  };
+
+  struct var
+  {
+    enum values
+    {
+      VALUE
+    };
+  };
+
+  typedef MultiDerivative<Time, Dyn, Parameters> type;
+
+  MultiDerivative(const std::string &name,
+                  const artis::pdevs::Context<Time, Dyn, Parameters> &context)
+      :
+      artis::pdevs::Dynamics<Time, Dyn, Parameters>(name, context),
+      _external_number(0), _internal_number(0), _variable_number(0)
+  {
+    DECLARE_STATES(int,
+                   ((state::PHASE, &type::_phase)));
+    DECLARE_STATES(unsigned int,
+                   ((state::INPUT_NUMBER, &type::_input_number)));
+    DECLARE_STATES(std::vector<double>,
+                   ((state::OUTPUT_VALUES, &type::_output_values),
+                       (state::LAST_OUTPUTS, &type::_last_outputs)));
+
+    this->input_port({input::RESET, "reset"});
+  }
+
+  virtual ~MultiDerivative()
+  {}
+
+  int external(const std::string &name, double Dyn::* var)
+  {
+    this->state_(state::LAST_OUTPUTS + _variable_number + 1, name, var);
+    this->input_port({input::EXTERNAL + _external_number, name});
+    ++_variable_number;
+    ++_external_number;
+    return input::EXTERNAL + _external_number - 1;
+  }
+
+  void internal(const std::string &name, double Dyn::* var)
+  {
+
+    assert(_external_number == 0);
+
+    this->state_(state::LAST_OUTPUTS + _variable_number + 1, name, var);
+    this->input_port({input::INTERNAL + _internal_number, name});
+    this->output_port({_internal_number, name});
+    this->observable({var::VALUE + _internal_number, name});
+    ++_variable_number;
+    ++_internal_number;
+  }
+
+  virtual std::vector<double> compute() = 0;
+
+  virtual void dconf(const typename Time::type &t, typename Time::type e,
+                     const common::Bag<Time> &bag)
+  {
+    dint(t);
+    dext(t, e, bag);
+  }
+
+  virtual void dint(const typename Time::type & /* t */)
+  {
+    if (_phase == phase::RESPONSE) {
+      _last_outputs.assign(_output_values.begin(), _output_values.end());
+    }
+    _phase = phase::WAIT;
+  }
+
+  virtual void dext(const typename Time::type &t, typename Time::type e,
+                    const common::Bag<Time> &bag)
+  {
+    std::for_each(bag.begin(), bag.end(),
+                  [this, t, e](const common::ExternalEvent<Time> &event) {
+                    if (event.on_port(input::RESET)) {
+                      _input_number = 0;
+                      _phase = phase::INIT;
+                    } else {
+                      IntegratorData data;
+
+                      event.data()(data);
+                      if (event.port_index() >= input::INTERNAL
+                          and event.port_index() < input::EXTERNAL) {
+                        this->get((event.port_index() - input::INTERNAL) + state::LAST_OUTPUTS + 1)
+                            .put(
+                                static_cast<Dyn *>(this), data.value);
+                      } else {
+
+                        assert(event.port_index() >= input::EXTERNAL);
+
+                        this->get((event.port_index() - input::EXTERNAL) + state::LAST_OUTPUTS + 1)
+                            .put(
+                                static_cast<Dyn *>(this), data.value);
+                      }
+                      switch (_phase) {
+                      case phase::INIT: {
+                        ++_input_number;
+                        if (_input_number == this->state_number() - (state::LAST_OUTPUTS + 1)) {
+                          std::vector<double> values = compute();
+
+                          assign_values(values);
+                          _phase = phase::RESPONSE;
+                        }
+                        break;
+                      }
+                      case phase::WAIT:
+                      case phase::RESPONSE: {
+                        std::vector<double> values = compute();
+
+                        if (is_different_values(values)) {
+                          assign_values(values);
+                          _phase = phase::RESPONSE;
+                        } else {
+                          _phase = phase::WAIT;
+                        }
+                      }
+                      }
+                    }
+                  });
+  }
+
+  virtual void start(const typename Time::type & /* time */)
+  {
+    _output_values = std::vector<double>(_internal_number);
+    _last_outputs = std::vector<double>(_internal_number);
+    _input_number = 0;
+    _phase = phase::INIT;
+  }
+
+  virtual typename Time::type ta(const typename Time::type & /* time */)
+  {
+    switch (_phase) {
+    case phase::INIT:return Time::infinity;
+    case phase::WAIT:return Time::infinity;
+    case phase::RESPONSE:return 0;
+    }
+    return Time::infinity;
+  }
+
+  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const
+  {
+    common::Bag<Time> msgs;
+
+    switch (_phase) {
+    case phase::INIT:break;
+    case phase::WAIT:break;
+    case phase::RESPONSE: {
+      unsigned int index = 0;
+
+      for (double value: _output_values) {
+        if (value != _last_outputs[index]) {
+          const DerivativeData data = {value};
+
+          msgs.push_back(common::ExternalEvent<Time>(index, data));
+        }
+        ++index;
+      }
+    }
+    }
+    return msgs;
+  }
+
+  virtual common::Value observe(const typename Time::type & /* t */,
+                                unsigned int index) const
+  {
+    if (index >= var::VALUE and index <= var::VALUE + _internal_number) {
+      return (double) (_output_values[index - var::VALUE]);
+    } else {
+      return common::Value();
+    }
+  }
+
+  unsigned int variable_number() const
+  { return _internal_number; }
+
+private:
+  void assign_values(const std::vector<double> &values)
+  {
+    for (unsigned int index = 0; index < _internal_number; ++index) {
+      _output_values[index] = values[index];
+    }
+  }
+
+  bool is_different_values(const std::vector<double> &values)
+  {
+    bool different = false;
+    unsigned int index = 0;
+
+    while (not different and index < _internal_number) {
+      if (_output_values[index] != values[index]) {
+        different = true;
+      } else {
+        ++index;
+      }
+    }
+    return different;
+  }
+
+  struct phase
+  {
+    enum values
+    {
+      INIT = 0, WAIT, RESPONSE
+    };
+  };
+
+  struct state
+  {
+    enum values
+    {
+      PHASE = 0, INPUT_NUMBER, OUTPUT_VALUES, LAST_OUTPUTS
+    };
+  };
+
+  unsigned int _external_number;
+  unsigned int _internal_number;
+  unsigned int _variable_number;
+
+  // state
+  int _phase;
+  unsigned int _input_number;
+  std::vector<double> _output_values;
+  std::vector<double> _last_outputs;
+};
+
+}
+}
+
+#endif

+ 131 - 82
src/artis-star/kernel/qss/Quantifier.hpp

@@ -35,7 +35,8 @@
 namespace artis {
 namespace qss {
 
-struct QuantifierParameters {
+struct QuantifierParameters
+{
   bool allow_offsets;
   bool zero_init_offset;
   double quantum;
@@ -44,42 +45,49 @@ struct QuantifierParameters {
 
 template<class Time>
 class Quantifier
-    : public artis::pdevs::Dynamics<Time, Quantifier<Time>, QuantifierParameters> {
+    : public artis::pdevs::Dynamics<Time, Quantifier<Time>, QuantifierParameters>
+{
 public:
-  enum inputs {
-    IN, RESET
+  struct input
+  {
+    enum values
+    {
+      IN, RESET
+    };
   };
 
-  enum outputs {
-    OUT
-  };
-
-  enum states {
-    STATE, ADAPTIVE_STATE, STEP_NUMBER, OFFSET, UP_THRESHOLD, DOWN_THRESHOLD
+  struct output
+  {
+    enum values
+    {
+      OUT
+    };
   };
 
   Quantifier(const std::string &name,
              const artis::pdevs::Context<Time, Quantifier<Time>, QuantifierParameters> &context)
       :
-      artis::pdevs::Dynamics<Time, Quantifier<Time>, QuantifierParameters>(name,
-                                                                           context) {
+      artis::pdevs::Dynamics<Time, Quantifier<Time>, QuantifierParameters>(name, context)
+  {
     DECLARE_STATES(int,
-                   ((STATE, &Quantifier<Time>::_state), (ADAPTIVE_STATE, &Quantifier<Time>::_adaptive_state)));
+                   ((state::PHASE, &Quantifier<Time>::_phase),
+                       (state::ADAPTIVE_STATE, &Quantifier<Time>::_adaptive_state)));
     DECLARE_STATES(unsigned int,
-                   ((STEP_NUMBER, &Quantifier<Time>::_step_number)));
+                   ((state::STEP_NUMBER, &Quantifier<Time>::_step_number)));
     DECLARE_STATES(double,
-                   ((OFFSET, &Quantifier<Time>::_offset), (UP_THRESHOLD, &Quantifier<Time>::_up_threshold), (DOWN_THRESHOLD, &Quantifier<
-                       Time>::_down_threshold)));
+                   ((state::OFFSET, &Quantifier<Time>::_offset),
+                       (state::UP_THRESHOLD, &Quantifier<Time>::_up_threshold),
+                       (state::DOWN_THRESHOLD, &Quantifier<Time>::_down_threshold)));
 
-    this->input_ports({{IN, "in"},
-                       {RESET, "reset"}});
-    this->output_port({OUT, "out"});
-    this->observables({{UP, "up"},
-                       {DOWN, "down"},
-                       {VALUE, "value"}});
+    this->input_ports({{input::IN, "in"},
+                       {input::RESET, "reset"}});
+    this->output_port({output::OUT, "out"});
+    this->observables({{var::UP, "up"},
+                       {var::DOWN, "down"},
+                       {var::VALUE, "value"}});
 
     _adaptive = context.parameters().allow_offsets;
-    _adaptive_state = _adaptive ? POSSIBLE : IMPOSSIBLE;
+    _adaptive_state = _adaptive ? adaptive_state::POSSIBLE : adaptive_state::IMPOSSIBLE;
     _zero_init_offset = context.parameters().zero_init_offset;
     _step_size = context.parameters().quantum;
 
@@ -90,30 +98,34 @@ public:
     assert(_past_length > 2);
   }
 
-  virtual ~Quantifier() {}
+  virtual ~Quantifier()
+  {}
 
   virtual void dconf(const typename Time::type &t, const typename Time::type &e,
-                     const common::Bag<Time> &bag) {
+                     const common::Bag<Time> &bag)
+  {
     dint(t);
     dext(t, e, bag);
   }
 
-  virtual void dint(const typename Time::type & /* t */) {
-    switch (_state) {
-    case INIT:break;
-    case IDLE:break;
-    case RESPONSE:_state = IDLE;
+  virtual void dint(const typename Time::type & /* t */)
+  {
+    switch (_phase) {
+    case phase::INIT:break;
+    case phase::IDLE:break;
+    case phase::RESPONSE:_phase = phase::IDLE;
       break;
     }
   }
 
   virtual void dext(const typename Time::type &t, const typename Time::type &e,
-                    const common::Bag<Time> &bag) {
+                    const common::Bag<Time> &bag)
+  {
     bool reset = false;
 
     std::for_each(bag.begin(), bag.end(),
                   [this, t, e, &reset](const common::ExternalEvent<Time> &event) {
-                    if (event.on_port(IN)) {
+                    if (event.on_port(input::IN)) {
                       IntegratorData data;
                       double shifting_factor;
                       double value;
@@ -121,10 +133,10 @@ public:
 
                       event.data()(data);
                       value = data.value;
-                      if (_state == INIT) {
+                      if (_phase == phase::INIT) {
                         init_step_number_and_offset(value);
                         update_thresholds();
-                        _state = RESPONSE;
+                        _phase = phase::RESPONSE;
                       } else {
                         cnt = 0;
                         while (value >= _up_threshold or value <= _down_threshold) {
@@ -135,9 +147,9 @@ public:
                             _step_number--;
                           }
                           switch (_adaptive_state) {
-                          case IMPOSSIBLE:update_thresholds();
+                          case adaptive_state::IMPOSSIBLE:update_thresholds();
                             break;
-                          case POSSIBLE:
+                          case adaptive_state::POSSIBLE:
                             if (value >= _up_threshold) {
                               store_change(_step_size, t);
                             } else {
@@ -151,74 +163,75 @@ public:
                             if (shifting_factor != 0 and shifting_factor != 1) {
                               if (value >= _up_threshold) {
                                 update_thresholds(shifting_factor,
-                                                  DIRECTION_DOWN);
+                                                  direction::DIRECTION_DOWN);
                               } else {
                                 update_thresholds(shifting_factor,
-                                                  DIRECTION_UP);
+                                                  direction::DIRECTION_UP);
                               }
-                              _adaptive_state = DONE;
+                              _adaptive_state = adaptive_state::DONE;
                             } else {
                               update_thresholds();
                             }
                             break;
-                          case DONE:init_step_number_and_offset(value);
-                            _adaptive_state = POSSIBLE;
+                          case adaptive_state::DONE:init_step_number_and_offset(value);
+                            _adaptive_state = adaptive_state::POSSIBLE;
                             update_thresholds();
                             break;
                           }
                         }
                       }
-                    } else if (event.on_port(RESET)) {
+                    } else if (event.on_port(input::RESET)) {
                       _offset = 0;
                       reset = true;
                       _archive.clear();
                     }
                   });
     if (reset) {
-      _state = INIT;
+      _phase = phase::INIT;
     } else {
-      _state = RESPONSE;
+      _phase = phase::RESPONSE;
     }
   }
 
-  virtual void start(const typename Time::type & /* time */) {
+  virtual void start(const typename Time::type & /* time */)
+  {
     _offset = 0;
-    _state = INIT;
+    _phase = phase::INIT;
   }
 
-  virtual typename Time::type ta(const typename Time::type & /* time */) {
-    switch (_state) {
-    case INIT:
-    case IDLE:return Time::infinity;
-    case RESPONSE:return 0.0;
+  virtual typename Time::type ta(const typename Time::type & /* time */)
+  {
+    switch (_phase) {
+    case phase::INIT:
+    case phase::IDLE:return Time::infinity;
+    case phase::RESPONSE:return 0.0;
     }
     return Time::infinity;
   }
 
-  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const {
+  virtual common::Bag<Time> lambda(const typename Time::type & /* time */) const
+  {
     common::Bag<Time> msgs;
     const QuantifierData data = {_up_threshold, _down_threshold};
 
-    msgs.push_back(common::ExternalEvent<Time>(OUT, data));
+    msgs.push_back(common::ExternalEvent<Time>(output::OUT, data));
     return msgs;
   }
 
   virtual common::Value observe(const typename Time::type & /* t */,
-                                unsigned int index) const {
+                                unsigned int index) const
+  {
     switch (index) {
-    case UP:return (double) _up_threshold;
-    case DOWN:return (double) _down_threshold;
-    case VALUE:return (double) (_up_threshold - _down_threshold);
+    case var::UP:return (double) _up_threshold;
+    case var::DOWN:return (double) _down_threshold;
+    case var::VALUE:return (double) (_up_threshold - _down_threshold);
     default:return common::Value();
     }
   }
 
 private:
-  typedef enum {
-    DIRECTION_UP, DIRECTION_DOWN
-  } Direction;
-
-  void init_step_number_and_offset(double value) {
+  void init_step_number_and_offset(double value)
+  {
     _step_number = static_cast<long int>(std::floor(value / _step_size));
     if (_zero_init_offset) {
       _offset = 0;
@@ -227,7 +240,8 @@ private:
     }
   }
 
-  bool monotonous(unsigned int range) {
+  bool monotonous(unsigned int range)
+  {
     if ((range + 1) > _archive.size()) {
       return false;
     }
@@ -239,7 +253,8 @@ private:
     return true;
   }
 
-  bool oscillating(unsigned int range) {
+  bool oscillating(unsigned int range)
+  {
     if ((range + 1) > _archive.size()) {
       return false;
     }
@@ -251,7 +266,8 @@ private:
     return true;
   }
 
-  double shift_quanta() {
+  double shift_quanta()
+  {
     double factor = 0;
 
     if (oscillating(_past_length - 1) and
@@ -283,7 +299,8 @@ private:
     return factor;
   }
 
-  void store_change(double val, const typename Time::type &time) {
+  void store_change(double val, const typename Time::type &time)
+  {
     record_t record;
 
     record.date = time;
@@ -294,24 +311,35 @@ private:
     }
   }
 
-  void update_thresholds() {
+  void update_thresholds()
+  {
     auto step_number = static_cast<double>(_step_number);
 
     _up_threshold = _offset + _step_size * (step_number + 1);
     _down_threshold = _offset + _step_size * (step_number - 1);
   }
 
-  void update_thresholds(double factor) {
+  void update_thresholds(double factor)
+  {
     auto step_number = static_cast<double>(_step_number);
 
     _up_threshold = _offset + _step_size * (step_number + (1 - factor));
     _down_threshold = _offset + _step_size * (step_number - (1 - factor));
   }
 
-  void update_thresholds(double factor, Direction d) {
+  struct direction
+  {
+    enum values
+    {
+      DIRECTION_UP, DIRECTION_DOWN
+    };
+  };
+
+  void update_thresholds(double factor, const typename direction::values &d)
+  {
     auto step_number = static_cast<double>(_step_number);
 
-    if (d == DIRECTION_UP) {
+    if (d == direction::DIRECTION_UP) {
       _up_threshold = _offset + _step_size * (step_number + (1 - factor));
       _down_threshold = _offset + _step_size * (step_number - 1);
     } else {
@@ -320,19 +348,40 @@ private:
     }
   }
 
-  typedef enum vars {
-    UP, DOWN, VALUE
-  } Observable;
+  struct state
+  {
+    enum values
+    {
+      PHASE, ADAPTIVE_STATE, STEP_NUMBER, OFFSET, UP_THRESHOLD, DOWN_THRESHOLD
+    };
+  };
 
-  typedef enum {
-    INIT, IDLE, RESPONSE
-  } State;
+  struct var
+  {
+    enum values
+    {
+      UP, DOWN, VALUE
+    };
+  };
 
-  typedef enum {
-    IMPOSSIBLE, POSSIBLE, DONE
-  } AdaptiveState;
+  struct phase
+  {
+    enum values
+    {
+      INIT, IDLE, RESPONSE
+    };
+  };
+
+  struct adaptive_state
+  {
+    enum values
+    {
+      IMPOSSIBLE, POSSIBLE, DONE
+    };
+  };
 
-  struct record_t {
+  struct record_t
+  {
     double value;
     typename Time::type date;
   };
@@ -344,7 +393,7 @@ private:
   double _step_size;
 
   // state
-  int _state;
+  int _phase;
   int _adaptive_state;
 
   unsigned int _step_number; // long int
@@ -359,4 +408,4 @@ private:
 }
 }
 
-#endif
+#endif

+ 32 - 16
src/artis-star/kernel/sss/Coordinator.hpp

@@ -39,10 +39,12 @@ namespace artis {
 namespace sss {
 
 template<class Time>
-class Parameters {
+class Parameters
+{
 public:
   Parameters(typename Time::type time_step)
-      : _time_step(time_step) {}
+      : _time_step(time_step)
+  {}
 
   typename Time::type _time_step;
 };
@@ -51,7 +53,8 @@ template<class Time, class Policy, class GraphManager,
     class Parameters = Parameters<Time>,
     class GraphParameters = common::NoParameters>
 class Coordinator : public common::Coordinator<Time>,
-                    public sss::Model<Time> {
+                    public sss::Model<Time>
+{
   typedef Coordinator<Time, Policy, GraphManager,
                       Parameters, GraphParameters> type;
 
@@ -67,19 +70,26 @@ public:
       common::Coordinator<Time>(name),
       sss::Model<Time>(name),
       _graph_manager(this, graph_parameters),
-      _time_step(parameters._time_step) {}
+      _time_step(parameters._time_step)
+  {}
 
-  virtual ~Coordinator() {}
+  virtual ~Coordinator()
+  {}
 
-  GraphManager &get_graph_manager() { return _graph_manager; }
+  GraphManager &get_graph_manager()
+  { return _graph_manager; }
 
-  const GraphManager &get_graph_manager() const { return _graph_manager; }
+  const GraphManager &get_graph_manager() const
+  { return _graph_manager; }
 
-  virtual bool is_atomic() const { return common::Coordinator<Time>::is_atomic(); }
+  virtual bool is_atomic() const
+  { return common::Coordinator<Time>::is_atomic(); }
 
-  virtual std::string to_string(int level) const { return common::Coordinator<Time>::to_string(level); }
+  virtual std::string to_string(int level) const
+  { return common::Coordinator<Time>::to_string(level); }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
     assert(_graph_manager.children().size() > 0);
 
     type::_tl = t;
@@ -91,18 +101,21 @@ public:
   }
 
   typename Time::type dispatch_events(const common::Bag<Time> &bag,
-                                      const typename Time::type &t) {
+                                      const typename Time::type &t)
+  {
     _graph_manager.dispatch_events(bag, t);
     return type::_tn;
   }
 
-  void observation(std::ostream &file) const {
+  void observation(std::ostream &file) const
+  {
     for (auto &child : _graph_manager.children()) {
       child->observation(file);
     }
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
     if (t == type::_tn) {
       for (auto &model : _graph_manager.children()) {
         model->update_buffer(t);
@@ -117,7 +130,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
     if (t == type::_tn) {
       _graph_manager.post_event(t, event);
     } else {
@@ -125,7 +139,8 @@ public:
     }
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
     if (t == type::_tn) {
       bool end = true;
 
@@ -165,7 +180,8 @@ public:
     return type::_tn;
   }
 
-  virtual void update_buffer(typename Time::type /* time */) {}
+  virtual void update_buffer(typename Time::type /* time */)
+  {}
 
 private:
   GraphManager _graph_manager;

+ 22 - 11
src/artis-star/kernel/sss/Dynamics.hpp

@@ -37,40 +37,51 @@ namespace sss {
 
 template<class Time,
     class Parameters = common::NoParameters>
-class Dynamics : public common::States<Time, Dyn> {
+class Dynamics : public common::States<Time, Dyn>
+{
 public:
   Dynamics(const std::string &name, const Parameters & /* parameters */)
       :
-      _name(name) {}
+      _name(name)
+  {}
 
-  virtual ~Dynamics() {}
+  virtual ~Dynamics()
+  {}
 
   virtual void transition(const common::Bag<Time> & /* x */,
-                          typename Time::type /* t */) {}
+                          typename Time::type /* t */)
+  {}
 
   virtual typename Time::type
-  start(typename Time::type/* time */) { return Time::infinity; }
+  start(typename Time::type/* time */)
+  { return Time::infinity; }
 
   common::Bag<Time> lambda(
-      typename Time::type /* time */) const { return common::Bag<Time>(); }
+      typename Time::type /* time */) const
+  { return common::Bag<Time>(); }
 
-  virtual void observation(std::ostream & /* file */) const {}
+  virtual void observation(std::ostream & /* file */) const
+  {}
 
-  const std::string &get_name() const { return _name; }
+  const std::string &get_name() const
+  { return _name; }
 
-  void restore(const common::context::State<Time> &state) {
+  void restore(const common::context::State<Time> &state)
+  {
     common::States<Time, Dyn>::restore(static_cast<Dyn *>(this), state);
     _simulator->set_tn(state.last_time());
     _simulator->set_tl(state.next_time());
   }
 
-  void save(common::context::State<Time> &state) const {
+  void save(common::context::State<Time> &state) const
+  {
     common::States<Time, Dyn>::save(static_cast<const Dyn *>(this), state);
     state.last_time(_simulator->get_tn());
     state.next_time(_simulator->get_tl());
   }
 
-  virtual void update_buffer(typename Time::type /* time */) {}
+  virtual void update_buffer(typename Time::type /* time */)
+  {}
 
 private:
   std::string _name;

+ 12 - 6
src/artis-star/kernel/sss/GraphManager.hpp

@@ -39,19 +39,23 @@ namespace sss {
 
 template<class Time,
     class GraphParameters = common::NoParameters>
-class GraphManager : public common::GraphManager<Time> {
+class GraphManager : public common::GraphManager<Time>
+{
 public:
   GraphManager(common::Coordinator<Time> *coordinator,
                const GraphParameters & /* parameters */)
       :
-      common::GraphManager<Time>(coordinator) {}
+      common::GraphManager<Time>(coordinator)
+  {}
 
-  virtual ~GraphManager() {}
+  virtual ~GraphManager()
+  {}
 
   void add_link(common::Model<Time> *src_model,
                 const std::string &src_port_name,
                 common::Model<Time> *dst_model,
-                const std::string &dst_port_name) {
+                const std::string &dst_port_name)
+  {
     assert((src_model != _coordinator and
         dst_model != _coordinator and
         src_model->exist_out_port(src_port_name) and
@@ -69,7 +73,8 @@ public:
   }
 
   void dispatch_events(common::Bag<Time> bag,
-                       typename Time::type t) {
+                       typename Time::type t)
+  {
     for (auto &ymsg : bag) {
       typename common::Links<Time>::Result result_model =
           _link_list.find(ymsg.get_model(),
@@ -101,7 +106,8 @@ public:
   }
 
   void post_event(typename Time::type t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
     typename common::Links<Time>::Result result =
         _link_list.find(_coordinator, event.get_port_name());
 

+ 34 - 17
src/artis-star/kernel/sss/Model.hpp

@@ -33,21 +33,25 @@ namespace artis {
 namespace sss {
 
 template<class Time>
-class Model : public virtual common::Model<Time> {
+class Model : public virtual common::Model<Time>
+{
 public:
   Model(const std::string &name)
       :
-      common::Model<Time>(name) {
+      common::Model<Time>(name)
+  {
     assigned = 0;
     _mark = false;
     _send = false;
   }
 
-  virtual ~Model() {}
+  virtual ~Model()
+  {}
 
   virtual void update_buffer(typename Time::type /* time */) = 0;
 
-  void add_event(const common::ExternalEvent<Time> &message) {
+  void add_event(const common::ExternalEvent<Time> &message)
+  {
     common::Model<Time>::add_event(message);
     std::map<std::string, bool>::iterator it =
         port_assigned.find(message.get_port_name());
@@ -58,16 +62,19 @@ public:
     }
   }
 
-  void add_in_port(const std::string &port_name, bool sync) {
+  void add_in_port(const std::string &port_name, bool sync)
+  {
     common::Model<Time>::add_in_port(port_name);
     if (sync) {
       port_assigned[port_name] = false;
     }
   }
 
-  bool all_ports_are_assigned() const { return assigned == port_assigned.size(); }
+  bool all_ports_are_assigned() const
+  { return assigned == port_assigned.size(); }
 
-  void clear_bag() {
+  void clear_bag()
+  {
     common::Model<Time>::clear_bag();
 
     for (auto &p: port_assigned) {
@@ -76,17 +83,23 @@ public:
     assigned = 0;
   }
 
-  bool is_marked() const { return _mark; }
+  bool is_marked() const
+  { return _mark; }
 
-  bool is_send() const { return _send; }
+  bool is_send() const
+  { return _send; }
 
-  void mark() { _mark = true; }
+  void mark()
+  { _mark = true; }
 
-  void send() { _send = true; }
+  void send()
+  { _send = true; }
 
-  void unmark() { _mark = false; }
+  void unmark()
+  { _mark = false; }
 
-  void unsend() { _send = false; }
+  void unsend()
+  { _send = false; }
 
 private:
   std::map<std::string, bool> port_assigned;
@@ -96,13 +109,17 @@ private:
 };
 
 template<class Time>
-class Models : public std::vector<sss::Model<Time> *> {
+class Models : public std::vector<sss::Model<Time> *>
+{
 public:
-  Models() {}
+  Models()
+  {}
 
-  virtual ~Models() {}
+  virtual ~Models()
+  {}
 
-  std::string to_string() const {
+  std::string to_string() const
+  {
     std::ostringstream ss;
 
     ss << "{ ";

+ 28 - 14
src/artis-star/kernel/sss/Simulator.hpp

@@ -42,7 +42,8 @@ namespace sss {
 template<class Time, class Dynamics,
     class Parameters = common::NoParameters>
 class Simulator : public common::Simulator<Time>,
-                  public sss::Model<Time> {
+                  public sss::Model<Time>
+{
   typedef Simulator<Time, Dynamics, Parameters> type;
 
 public:
@@ -53,25 +54,32 @@ public:
       common::Simulator<Time>(name),
       sss::Model<Time>(name),
       _dynamics(name, parameters),
-      _time_step(time_step) {}
+      _time_step(time_step)
+  {}
 
-  ~Simulator() {}
+  ~Simulator()
+  {}
 
-  virtual bool is_atomic() const { return common::Simulator<Time>::is_atomic(); }
+  virtual bool is_atomic() const
+  { return common::Simulator<Time>::is_atomic(); }
 
-  virtual void restore(const common::context::State<Time> &state) {
+  virtual void restore(const common::context::State<Time> &state)
+  {
     common::Simulator<Time>::restore(state);
     _dynamics.restore(state);
   }
 
-  virtual void save(context::State <Time> &state) const {
+  virtual void save(context::State <Time> &state) const
+  {
     common::Simulator<Time>::save(state);
     _dynamics.save(state);
   }
 
-  virtual std::string to_string(int level) const { return common::Simulator<Time>::to_string(level); }
+  virtual std::string to_string(int level) const
+  { return common::Simulator<Time>::to_string(level); }
 
-  virtual void finish(const typename Time::type &t) {
+  virtual void finish(const typename Time::type &t)
+  {
 #ifndef WITH_TRACE
     (void) t;
 #endif
@@ -86,7 +94,8 @@ public:
 #endif
   }
 
-  typename Time::type start(const typename Time::type &t) {
+  typename Time::type start(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -113,11 +122,13 @@ public:
     return type::_tn;
   }
 
-  void observation(std::ostream &file) const {
+  void observation(std::ostream &file) const
+  {
     _dynamics.observation(file);
   }
 
-  void output(const typename Time::type &t) {
+  void output(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -148,7 +159,8 @@ public:
   }
 
   void post_event(const typename Time::type &t,
-                  const common::ExternalEvent<Time> &event) {
+                  const common::ExternalEvent<Time> &event)
+  {
 
 #ifndef WITH_TRACE
     (void) t;
@@ -174,7 +186,8 @@ public:
 
   }
 
-  typename Time::type transition(const typename Time::type &t) {
+  typename Time::type transition(const typename Time::type &t)
+  {
 
 #ifdef WITH_TRACE
     common::Trace<Time>::trace()
@@ -209,7 +222,8 @@ public:
     return type::_tn;
   }
 
-  virtual void update_buffer(typename Time::type time) { _dynamics.update_buffer(time); }
+  virtual void update_buffer(typename Time::type time)
+  { _dynamics.update_buffer(time); }
 
 private :
   Dynamics _dynamics;