def collect_data(self):
        # Initialize data
        data = {}

        # Iterate through all nodes
        for nid, node in self.env.nodes.items():
            # If no generators in this node, return
            if not node.generators:
                data[nid] = pd.DataFrame()
                continue

            # Get all the bundles sent
            sent = concat_dfs(
                {
                    gid: gen.list_bundles()
                    for gid, gen in node.generators.items()
                }, 'generator_id')

            # Store data
            data[nid] = sent

        # Create the total data frame
        df = concat_dfs(data, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
    def collect_data(self):
        # Get the bundles stored in all the node's radios
        df = concat_dfs({nid: concat_dfs({rid: r.stored for rid, r in node.radios.items()}, 'radio')
                         for nid, node in self.env.nodes.items()}, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
Exemple #3
0
    def collect_data(self):
        # Get the bundles stored in all the node's neighbor queues
        df = concat_dfs({nid: concat_dfs({(n, b, t): d.stored for n, v in node.ducts.items()
                                          for b, vv in v.items() for t, d in vv.items()},
                                         ('neighbor', 'band', 'duct_type', 'idx'))
                                          for nid, node in self.env.nodes.items()}, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
Exemple #4
0
    def collect_data(self):
        # Initialize variables
        res = {}

        # Iterate over nodes
        for nid, node in self.env.nodes.items():
            q = node.limbo_queue

            # No items in this queue
            if not any(q.items):
                continue

            # The first element of the item is the bundle in the limbo queue
            d = {i: d[0].to_dict() for i, d in enumerate(q.items)}

            # Save data
            res[nid] = pd.DataFrame.from_dict(d, orient='index')

        # Get the bundles stored in all the node's radios
        df = concat_dfs(res, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
    def collect_data(self):
        # Get the bundles stored in all the node's neighbor queues
        df = concat_dfs(
            {
                nid: concat_dfs(
                    {
                        neighbor: node.queues[neighbor].stored
                        for neighbor in node.neighbors
                    }, 'neighbor')
                for nid, node in self.env.nodes.items()
            }, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
Exemple #6
0
    def collect_data(self):
        # Get all the bundles that arrived in this node
        df = concat_dfs(
            {
                nid: pd.DataFrame(bundle.to_dict() for bundle in node.dropped)
                for nid, node in self.env.nodes.items()
            }, 'node')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df
    def collect_data(self):
        # Get the bundles lost in a connection
        df = concat_dfs(
            {
                cid: conn.list_sent()
                for cid, conn in self.env.connections.items()
            }, 'connection')

        # Transform to string to save space. You can use a converter when loading
        if 'visited' in df: df.visited = df.visited.apply(lambda v: str(v))

        return df