Parcourir la source

Fix: wrong connections in hierarchical case

Eric Ramat il y a 11 ans
Parent
commit
097863a593

+ 68 - 15
src/common/Model.hpp

@@ -51,6 +51,9 @@ class InternalEvent;
 template < class Time >
 class Bag;
 
+typedef std::string Port;
+typedef std::vector < Port > Ports;
+
 template < class Time >
 class Model
 {
@@ -66,6 +69,60 @@ public:
         }
     }
 
+    // structure
+    void add_in_port(const std::string& port_name)
+    {
+        assert(not exist_in_port(port_name));
+
+        _in_ports.push_back(port_name);
+    }
+
+    void add_out_port(const std::string& port_name)
+    {
+        assert(not exist_out_port(port_name));
+
+        _out_ports.push_back(port_name);
+    }
+
+    void delete_in_port(const std::string& port_name)
+    {
+        assert(not exist_in_port(port_name));
+
+        _in_ports.erase(std::find(_in_ports.begin(), _in_ports.end(),
+                                  port_name));
+    }
+
+    void delete_out_port(const std::string& port_name)
+    {
+        assert(not exist_out_port(port_name));
+
+        _out_ports.erase(std::find(_out_ports.begin(), _out_ports.end(),
+                                   port_name));
+    }
+
+    bool exist_in_port(const std::string& port_name)
+    {
+        return std::find(_in_ports.begin(), _in_ports.end(),
+                         port_name) != _in_ports.end();
+    }
+
+    bool exist_out_port(const std::string& port_name)
+    {
+        return std::find(_out_ports.begin(), _out_ports.end(),
+                         port_name) != _out_ports.end();
+    }
+
+    const std::string& get_name() const
+    { return _name; }
+
+    Model < Time >* get_parent() const
+    { return _parent; }
+
+
+    void set_parent(Model < Time >* parent)
+    { _parent = parent; }
+
+    // event
     void add_event(const common::ExternalEvent < Time >& message)
     {
         if (_inputs == 0) {
@@ -99,6 +156,14 @@ public:
         }
     }
 
+    // time
+    typename Time::type get_tl() const
+    { return _tl; }
+
+    typename Time::type get_tn() const
+    { return _tn; }
+
+    // devs methods
     virtual void observation(std::ostream& file) const =0;
     virtual void output(typename Time::type t) =0;
     virtual void post_event(typename Time::type t,
@@ -106,18 +171,6 @@ public:
     virtual typename Time::type start(typename Time::type t) =0;
     virtual typename Time::type transition(typename Time::type t) =0;
 
-    virtual const std::string& get_name() const
-    { return _name; }
-
-    Model < Time >* get_parent() const
-    { return _parent; }
-
-    typename Time::type get_tl() const
-    { return _tl; }
-
-    typename Time::type get_tn() const
-    { return _tn; }
-
     void heap_id(typename boost::heap::fibonacci_heap <
                      InternalEvent < Time >,
                      boost::heap::compare <
@@ -132,9 +185,6 @@ public:
                                Time > > > >::handle_type heap_id()
                                { return _heap_id; }
 
-    void set_parent(Model < Time >* parent)
-    { _parent = parent; }
-
 protected:
     typename Time::type _tl;
     typename Time::type _tn;
@@ -142,6 +192,9 @@ protected:
 private :
     Model < Time >*     _parent;
     std::string         _name;
+    Ports               _in_ports;
+    Ports               _out_ports;
+
     Bag < Time >*       _inputs;
     typename boost::heap::fibonacci_heap <
         InternalEvent < Time >,

+ 2 - 1
src/dtss/Dynamics.hpp

@@ -29,6 +29,7 @@
 
 #include <common/Bag.hpp>
 #include <common/ExternalEvent.hpp>
+#include <common/Parameters.hpp>
 
 #include <limits>
 #include <string>
@@ -36,7 +37,7 @@
 
 namespace paradevs { namespace dtss {
 
-template < class Time, class Parameters >
+template < class Time, class Parameters = common::NoParameters >
 class Dynamics
 {
 public:

+ 18 - 5
src/dtss/GraphManager.hpp

@@ -52,12 +52,25 @@ public:
         child->set_parent(_coordinator);
     }
 
-    void add_link(common::Model < Time >* out_model,
-                  const std::string& out_port_name,
-                  common::Model < Time >* in_model,
-                  const std::string& in_port_name)
+    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)
     {
-        _link_list.add(out_model, out_port_name, in_model, in_port_name);
+        assert((src_model != _coordinator and
+                dst_model != _coordinator and
+                src_model->exist_out_port(src_port_name) and
+                dst_model->exist_in_port(dst_port_name)) or
+               (src_model == _coordinator and
+                dst_model != _coordinator and
+                src_model->exist_in_port(src_port_name) and
+                dst_model->exist_in_port(dst_port_name)) or
+               (src_model != _coordinator and
+                dst_model == _coordinator and
+                src_model->exist_out_port(src_port_name) and
+                dst_model->exist_out_port(dst_port_name)));
+
+        _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
     }
 
     const common::Models < Time >& children() const

+ 18 - 5
src/pdevs/GraphManager.hpp

@@ -52,12 +52,25 @@ public:
         child->set_parent(_coordinator);
     }
 
-    void add_link(common::Model < Time >* out_model,
-                  const std::string& out_port_name,
-                  common::Model < Time >* in_model,
-                  const std::string& in_port_name)
+    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)
     {
-        _link_list.add(out_model, out_port_name, in_model, in_port_name);
+        assert((src_model != _coordinator and
+                dst_model != _coordinator and
+                src_model->exist_out_port(src_port_name) and
+                dst_model->exist_in_port(dst_port_name)) or
+               (src_model == _coordinator and
+                dst_model != _coordinator and
+                src_model->exist_in_port(src_port_name) and
+                dst_model->exist_in_port(dst_port_name)) or
+               (src_model != _coordinator and
+                dst_model == _coordinator and
+                src_model->exist_out_port(src_port_name) and
+                dst_model->exist_out_port(dst_port_name)));
+
+        _link_list.add(src_model, src_port_name, dst_model, dst_port_name);
     }
 
     const common::Models < Time >& children() const

+ 220 - 0
src/tests/boost_graph/graph_builder.hpp

@@ -0,0 +1,220 @@
+/**
+ * @file tests/boost_graph/graph_builder.hpp
+ * @author The PARADEVS Development Team
+ * See the AUTHORS or Authors.txt file
+ */
+
+/*
+ * PARADEVS - the multimodeling and simulation environment
+ * This file is a part of the PARADEVS environment
+ *
+ * Copyright (C) 2013 ULCO http://www.univ-litoral.fr
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP
+#define __TESTS_BOOST_GRAPH_GRAPH_BUILDER_HPP 1
+
+#include <boost/graph/adjacency_list.hpp>
+
+namespace paradevs { namespace tests { namespace boost_graph {
+
+struct VertexProperties
+{
+    int          _index;
+    double       _weight;
+    DynamicsType _type;
+
+    VertexProperties() : _index(0), _weight(0), _type(NORMAL_PIXEL)
+    { }
+    VertexProperties(int index, double weight, DynamicsType type) :
+        _index(index), _weight(weight), _type(type)
+    { }
+};
+
+struct EdgeProperties
+{
+    double       _weight;
+
+    EdgeProperties() : _weight(0)
+    { }
+    EdgeProperties(double weight) : _weight(weight)
+    { }
+};
+
+typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::directedS,
+                                VertexProperties, EdgeProperties> Graph;
+typedef std::vector < Graph > Graphs;
+
+typedef std::pair < int, int > Edge;
+typedef std::vector < Edge > Edges;
+typedef Edges OutputEdges;
+typedef Edges InputEdges;
+typedef std::vector < OutputEdges > OutputEdgeList;
+typedef std::vector < InputEdges > InputEdgeList;
+
+typedef std::pair < int, int > Port;
+typedef std::pair < Port, Port > Connection;
+typedef std::vector < Connection > Connections;
+
+class FlatGraphBuilder
+{
+public:
+    FlatGraphBuilder()
+    { }
+
+    void build(Graphs& graphs, InputEdgeList& /* input_edges */,
+               OutputEdgeList& /* output_edges */,
+               Connections& /* parent_connections */)
+    {
+        Graph graph;
+
+        Graph::vertex_descriptor v0 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v1 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v2 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v3 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v4 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v5 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v6 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v7 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v8 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v9 = boost::add_vertex(graph);
+        Graph::vertex_descriptor v10 = boost::add_vertex(graph);
+
+        boost::add_edge(v0, v1, 1, graph);
+	boost::add_edge(v0, v2, 1, graph);
+	boost::add_edge(v0, v3, 1, graph);
+	boost::add_edge(v1, v2, 1, graph);
+	boost::add_edge(v1, v4, 1, graph);
+	boost::add_edge(v1, v5, 1, graph);
+	boost::add_edge(v1, v6, 1, graph);
+	boost::add_edge(v2, v6, 1, graph);
+	boost::add_edge(v2, v3, 1, graph);
+	boost::add_edge(v3, v9, 1, graph);
+	boost::add_edge(v3, v10, 1, graph);
+	boost::add_edge(v4, v5, 1, graph);
+	boost::add_edge(v5, v6, 1, graph);
+	boost::add_edge(v4, v7, 1, graph);
+	boost::add_edge(v4, v8, 1, graph);
+	boost::add_edge(v7, v8, 1, graph);
+	boost::add_edge(v9, v10, 1, graph);
+
+        graph[v6] = VertexProperties(6, 1, TOP_PIXEL);
+        graph[v8] = VertexProperties(8, 1, TOP_PIXEL);
+        graph[v10] = VertexProperties(10, 1, TOP_PIXEL);
+        graph[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+        graph[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+        graph[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+        graph[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+        graph[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+        graph[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+        graph[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+        graph[v9] = VertexProperties(9, 1, NORMAL_PIXEL);
+
+        graphs.push_back(graph);
+    }
+};
+
+class HierarchicalGraphBuilder
+{
+public:
+    HierarchicalGraphBuilder()
+    { }
+
+    void build(Graphs& graphs, InputEdgeList& input_edges,
+               OutputEdgeList& output_edges, Connections& parent_connections)
+    {
+        // S1
+        {
+            Graph graph;
+
+            Graph::vertex_descriptor v1 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v2 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v4 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v5 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v6 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v7 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v8 = boost::add_vertex(graph);
+
+            boost::add_edge(v1, v2, 1, graph);
+            boost::add_edge(v1, v4, 1, graph);
+            boost::add_edge(v1, v5, 1, graph);
+            boost::add_edge(v1, v6, 1, graph);
+            boost::add_edge(v2, v6, 1, graph);
+            boost::add_edge(v4, v5, 1, graph);
+            boost::add_edge(v5, v6, 1, graph);
+            boost::add_edge(v4, v7, 1, graph);
+            boost::add_edge(v4, v8, 1, graph);
+            boost::add_edge(v7, v8, 1, graph);
+
+            graph[v6] = VertexProperties(6, 1, TOP_PIXEL);
+            graph[v8] = VertexProperties(8, 1, TOP_PIXEL);
+            graph[v1] = VertexProperties(1, 1, NORMAL_PIXEL);
+            graph[v2] = VertexProperties(2, 1, NORMAL_PIXEL);
+            graph[v4] = VertexProperties(4, 1, NORMAL_PIXEL);
+            graph[v5] = VertexProperties(5, 1, NORMAL_PIXEL);
+            graph[v7] = VertexProperties(7, 1, NORMAL_PIXEL);
+
+            graphs.push_back(graph);
+        }
+        // S2
+        {
+            Graph graph;
+
+            Graph::vertex_descriptor v0 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v3 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v9 = boost::add_vertex(graph);
+            Graph::vertex_descriptor v10 = boost::add_vertex(graph);
+
+            boost::add_edge(v0, v3, 1, graph);
+            boost::add_edge(v3, v10, 1, graph);
+            boost::add_edge(v9, v10, 1, graph);
+            boost::add_edge(v3, v9, 1, graph);
+
+            graph[v10] = VertexProperties(10, 1, TOP_PIXEL);
+            graph[v0] = VertexProperties(0, 1, NORMAL_PIXEL);
+            graph[v3] = VertexProperties(3, 1, NORMAL_PIXEL);
+            graph[v9] = VertexProperties(9, 1, NORMAL_PIXEL);
+
+            graphs.push_back(graph);
+        }
+        {
+            // input S1
+            input_edges.push_back(InputEdges());
+            input_edges[0].push_back(Edge(3, 2));
+            // input S2
+            input_edges.push_back(InputEdges());
+            input_edges[1].push_back(Edge(1, 0));
+            input_edges[1].push_back(Edge(2, 0));
+
+            // output S1
+            output_edges.push_back(OutputEdges());
+            output_edges[0].push_back(Edge(1, 0));
+            output_edges[0].push_back(Edge(2, 0));
+            // output S2
+            output_edges.push_back(OutputEdges());
+            output_edges[1].push_back(Edge(3, 2));
+
+            // parent
+            parent_connections.push_back(Connection(Port(1,1),Port(2,0)));
+            parent_connections.push_back(Connection(Port(1,2),Port(2,0)));
+            parent_connections.push_back(Connection(Port(2,3),Port(1,2)));
+        }
+    }
+};
+
+} } } // namespace paradevs tests boost_graph
+
+#endif

+ 24 - 8
src/tests/boost_graph/graph_manager.hpp

@@ -75,7 +75,7 @@ public:
         }
     }
 
-    void build_flat_graph(const Graph& g)
+    void build_flat_graph(const Graph& g, const InputEdges& inputs)
     {
         Graph::vertex_iterator vertexIt, vertexEnd;
 
@@ -91,6 +91,7 @@ public:
                     new pdevs::Simulator <
                         MyTime, TopPixel, TopPixelParameters >(
                             ss.str(), TopPixelParameters());
+                _top_simulators[g[*vertexIt]._index]->add_out_port("out");
                 FlatGraphManager < Parameters >::add_child(
                     _top_simulators[g[*vertexIt]._index]);
                 break;
@@ -103,10 +104,19 @@ public:
                 for (; neighbourIt != neighbourEnd; ++neighbourIt) {
                     ++n;
                 }
+                for (InputEdges::const_iterator it = inputs.begin();
+                     it != inputs.end(); ++it) {
+                    if (g[*vertexIt]._index == it->second) {
+                        ++n;
+                    }
+                }
+
                 _normal_simulators[g[*vertexIt]._index] =
                     new pdevs::Simulator <
                         MyTime, NormalPixel, NormalPixelParameters >(
                             ss.str(), NormalPixelParameters(n));
+                _normal_simulators[g[*vertexIt]._index]->add_in_port("in");
+                _normal_simulators[g[*vertexIt]._index]->add_out_port("out");
                 FlatGraphManager < Parameters >::add_child(
                         _normal_simulators[g[*vertexIt]._index]);
                 break;
@@ -160,13 +170,16 @@ public:
         FlatGraphManager < GraphParameters >(
             coordinator, parameters)
     {
-        build_flat_graph(parameters._graph);
+        build_flat_graph(parameters._graph, parameters._input_edges);
         // input
         for (Edges::const_iterator it = parameters._input_edges.begin();
              it != parameters._input_edges.end(); ++it) {
             std::ostringstream ss_in;
 
             ss_in << "in_" << it->first;
+            if (not coordinator->exist_in_port(ss_in.str())) {
+                coordinator->add_in_port(ss_in.str());
+            }
             BuiltFlatGraphManager::add_link(coordinator, ss_in.str(),
                                             _normal_simulators[it->second],
                                             "in");
@@ -176,7 +189,10 @@ public:
              it != parameters._output_edges.end(); ++it) {
             std::ostringstream ss_out;
 
-            ss_out << "out_" << it->second;
+            ss_out << "out_" << it->first;
+            if (not coordinator->exist_out_port(ss_out.str())) {
+                coordinator->add_out_port(ss_out.str());
+            }
             BuiltFlatGraphManager::add_link(_normal_simulators[it->first],
                                             "out", coordinator, ss_out.str());
         }
@@ -203,7 +219,7 @@ public:
         Connections    parent_connections;
 
         builder.build(graphs, input_edges, output_edges, parent_connections);
-        build_flat_graph(graphs.front());
+        build_flat_graph(graphs.front(), InputEdges());
     }
 
     virtual ~InBuildFlatGraphManager()
@@ -236,7 +252,7 @@ public:
             Coordinator* coordinator = 0;
             std::ostringstream ss;
 
-            ss << "S" << i;
+            ss << "S" << (i + 1);
             coordinator =
                 new Coordinator(ss.str(), paradevs::common::NoParameters(),
                                 GraphParameters(graphs[i], input_edges[i],
@@ -255,10 +271,10 @@ public:
             std::ostringstream ss_in;
 
             ss_out << "out_" << connection.first.second;
-            ss_in << "in_" << connection.second.second;
+            ss_in << "in_" << connection.first.second;
             HierarchicalGraphManager < GraphBuilder >::add_link(
-                _coordinators[connection.first.first], ss_out.str(),
-                _coordinators[connection.second.first], ss_in.str());
+                _coordinators[connection.first.first - 1], ss_out.str(),
+                _coordinators[connection.second.first - 1], ss_in.str());
         }
     }
 

+ 7 - 1
src/tests/boost_graph/models.hpp

@@ -125,7 +125,8 @@ public:
                       const common::Bag < MyTime >& bag)
     {
 
-        std::cout << get_name() << " at " << t << ": dext" << std::endl;
+        std::cout << get_name() << " at " << t << ": dext -> "
+                  << bag.to_string() << std::endl;
 
         for (common::Bag < MyTime >::const_iterator it = bag.begin();
              it != bag.end(); ++it) {
@@ -136,6 +137,11 @@ public:
                 }
             }
         }
+
+        std::cout << get_name() << " at " << t << ": dext -> "
+                  << _received << "/" << _neighbour_number
+                  << std::endl;
+
     }
 
     virtual typename MyTime::type start(typename MyTime::type /* t */)

+ 1 - 1
src/tests/boost_graph/tests.cpp

@@ -58,7 +58,7 @@ void hierarchical_test()
 
 int main()
 {
-    flat_test();
+    // flat_test();
     hierarchical_test();
     return 0;
 }

+ 7 - 5
src/tests/dtss/graph_manager.hpp

@@ -63,7 +63,7 @@ public:
         paradevs::dtss::GraphManager < MyTime,
                                        paradevs::common::NoParameters >(
                                            coordinator, parameters),
-        a("a", 1, NoParameters())
+        a("a", 1, common::NoParameters())
     {
         add_child(&a);
     }
@@ -72,7 +72,7 @@ public:
     { }
 
 private:
-    paradevs::dtss::Simulator < MyTime, A, NoParameters > a;
+    paradevs::dtss::Simulator < MyTime, A > a;
 };
 
 class TwoGraphManager :
@@ -85,10 +85,12 @@ public:
         paradevs::dtss::GraphManager < MyTime,
                                        paradevs::common::NoParameters >(
                                            coordinator, parameters),
-        a("a", 1, NoParameters()), b("b", 1, NoParameters())
+        a("a", 1, common::NoParameters()), b("b", 1, common::NoParameters())
     {
         add_child(&a);
         add_child(&b);
+        a.add_out_port("out");
+        b.add_in_port("in");
         add_link(&a, "out", &b, "in");
     }
 
@@ -96,8 +98,8 @@ public:
     { }
 
 private:
-    paradevs::dtss::Simulator < MyTime, A, NoParameters > a;
-    paradevs::dtss::Simulator < MyTime, B, NoParameters > b;
+    paradevs::dtss::Simulator < MyTime, A > a;
+    paradevs::dtss::Simulator < MyTime, B > b;
 };
 
 } } } // namespace paradevs tests dtss

+ 16 - 12
src/tests/dtss/models.hpp

@@ -44,17 +44,16 @@ struct Limits
 
 typedef paradevs::common::Time < double, Limits < double > > MyTime;
 
-struct NoParameters
-{
-    NoParameters()
-    { }
-};
-
-class A : public paradevs::dtss::Dynamics < MyTime, NoParameters >
+class A :
+        public paradevs::dtss::Dynamics < MyTime,
+                                          paradevs::common::NoParameters >
 {
 public:
-    A(const std::string& name, const NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime, NoParameters >(name, parameters)
+    A(const std::string& name,
+      const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < MyTime,
+                                   paradevs::common::NoParameters >(name,
+                                                                    parameters)
     { }
     virtual ~A()
     { }
@@ -93,11 +92,16 @@ public:
     }
 };
 
-class B : public paradevs::dtss::Dynamics < MyTime, NoParameters >
+class B :
+        public paradevs::dtss::Dynamics < MyTime,
+                                          paradevs::common::NoParameters >
 {
 public:
-    B(const std::string& name, const NoParameters& parameters) :
-        paradevs::dtss::Dynamics < MyTime, NoParameters >(name, parameters)
+    B(const std::string& name,
+      const paradevs::common::NoParameters& parameters) :
+        paradevs::dtss::Dynamics < MyTime,
+                                   paradevs::common::NoParameters >(name,
+                                                                    parameters)
     { }
     virtual ~B()
     { }

+ 22 - 0
src/tests/mixed/graph_manager.hpp

@@ -89,6 +89,12 @@ public:
     {
         add_child(&a);
         add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
         add_link(&a, "out", &b, "in");
         add_link(&b, "out", coordinator, "out");
     }
@@ -114,6 +120,12 @@ public:
     {
         add_child(&a);
         add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
         add_link(&a, "out", &b, "in");
         add_link(coordinator, "in", &a, "in");
     }
@@ -183,6 +195,9 @@ public:
         }
         for (unsigned int i = 0; i < size; ++i) {
             add_child(_models[i]);
+
+            _models[i]->add_in_port("in");
+            _models[i]->add_out_port("out");
         }
         for (unsigned int i = 0; i < size - 1; ++i) {
             add_link(_models[i], "out", _models[i + 1], "in");
@@ -220,10 +235,17 @@ public:
         }
         for (unsigned int i = 0; i < 100; ++i) {
             add_child(_models[i]);
+
+            _models[i]->add_in_port("in");
+            _models[i]->add_out_port("out");
         }
         for (unsigned int i = 0; i < 99; ++i) {
             add_link(_models[i], "out", _models[i + 1], "in");
         }
+
+        coordinator->add_in_port("in");
+        coordinator->add_out_port("out");
+
         add_link(coordinator, "in", _models[0], "in");
         add_link(_models[49], "out", coordinator, "out");
     }

+ 19 - 0
src/tests/pdevs/graph_manager.hpp

@@ -49,6 +49,12 @@ public:
     {
         add_child(&a);
         add_child(&b);
+
+        a.add_out_port("out");
+        b.add_in_port("in");
+        b.add_out_port("out");
+        coordinator->add_out_port("out");
+
         add_link(&a, "out", &b, "in");
         add_link(&b, "out", coordinator, "out");
     }
@@ -72,6 +78,12 @@ public:
     {
         add_child(&a);
         add_child(&b);
+
+        a.add_in_port("in");
+        a.add_out_port("out");
+        b.add_in_port("in");
+        coordinator->add_in_port("in");
+
         add_link(&a, "out", &b, "in");
         add_link(coordinator, "in", &a, "in");
     }
@@ -98,6 +110,7 @@ public:
     {
         add_child(&S1);
         add_child(&S2);
+
         add_link(&S1, "out", &S2, "in");
     }
 
@@ -146,6 +159,12 @@ public:
         add_child(&b1);
         add_child(&a2);
         add_child(&b2);
+        a1.add_out_port("out");
+        b1.add_in_port("in");
+        b1.add_out_port("out");
+        a2.add_in_port("in");
+        a2.add_out_port("out");
+        b2.add_in_port("in");
         add_link(&a1, "out", &b1, "in");
         add_link(&b1, "out", &a2, "in");
         add_link(&a2, "out", &b2, "in");