def update(self):
        """Execute the action"""
        if self.skip_update():
	        return

        levels = self.experiment.data['resources'][self.resource]['levels']
        row = [self.experiment.epoch, mean(levels), std(levels), int(self.res.available)]
        self.writer.writerow(row)
    def update(self):
        """Execute the Action"""
        if self.skip_update():
	        return

        g = self.experiment.population.topology.graph
        cluster_counts = [0] * len(self.types)
        cluster_sizes = {}

        for i in range(len(self.types) + 1):
            cluster_sizes[i] = []

        unvisited = g.nodes()

        while len(unvisited) > 0:
            node = random.choice(unvisited)
            type = g.node[node]["cell"].type

            c = cluster(g, node)
            c_size = len(c)
            cluster_counts[type] += 1
            cluster_sizes[type].append(c_size)
            cluster_sizes[len(self.types)].append(c_size)

            [unvisited.remove(x) for x in c]

        row = { 'epoch' : self.experiment.epoch,
                'total_clusters' : sum(cluster_counts),
                'total_size_mean' : mean(cluster_sizes[len(self.types)]),
                'total_size_std' : std(cluster_sizes[len(self.types)]) }

        for index, t in enumerate(self.types):
            if cluster_counts[index] == 0:
                row['%s_clusters' % (t)] = 0
                row['%s_size_mean' % (t)] = 0
                row['%s_size_std' % (t)] = 0
            else:
                row['%s_clusters' % (t)] = cluster_counts[index]
                row['%s_size_mean' % (t)] = mean(cluster_sizes[index])
                row['%s_size_std' % (t)] = std(cluster_sizes[index])

        self.writer.writerow(row)
示例#3
0
    def update(self):
        """Execute the action"""
        if self.skip_update():
	        return

        levels = self.experiment.data['resources'][self.resource]['levels']
        row = { 'epoch' : self.experiment.epoch,
                'mean' : mean(levels),
                'standard_deviation' : std(levels),
                'available' : int(self.res.available)}
        self.writer.writerow(row)
示例#4
0
    def update(self):
        """Execute the action"""
        if self.skip_update():
            return

        levels = self.experiment.data['resources'][self.resource]['levels']
        row = [
            self.experiment.epoch,
            mean(levels),
            std(levels),
            int(self.res.available)
        ]
        self.writer.writerow(row)
    def update(self):
        """Execute the Action"""
        if self.skip_update():
	        return

        g = self.experiment.population.topology.graph
        cluster_counts = [0] * len(self.types)
        cluster_sizes = {}

        for i in range(len(self.types) + 1):
            cluster_sizes[i] = []

        unvisited = g.nodes()

        while len(unvisited) > 0:
            node = random.choice(unvisited)
            type = g.node[node]["cell"].type

            c = cluster(g, node)
            c_size = len(c)
            cluster_counts[type] += 1
            cluster_sizes[type].append(c_size)
            cluster_sizes[len(self.types)].append(c_size)

            [unvisited.remove(x) for x in c]

        row = [self.experiment.epoch]
        row.append(sum(cluster_counts))
        row.append(mean(cluster_sizes[len(self.types)]))
        row.append(std(cluster_sizes[len(self.types)]))

        for t in range(len(self.types)):
            row.append(cluster_counts[t])
            row.append(mean(cluster_sizes[t]))
            row.append(std(cluster_sizes[t]))

        self.writer.writerow(row)
    def update(self):
        """Execute the Action"""
        if self.skip_update():
	        return

        g = self.experiment.population.topology.graph
        degrees = list(nx.degree(g).values())
        row = { 'epoch' : self.experiment.epoch,
                'nodes' : nx.number_of_nodes(g),
                'edges' : nx.number_of_edges(g),
                'avg_degree' : mean(degrees),
                'std_degree' : std(degrees),
                'avg_clustering_coefficient' : nx.average_clustering(g),
                'diameter' : nx.diameter(g),
                'num_connected_components' : nx.number_connected_components(g)}
        self.writer.writerow(row)
    def update(self):
        """Execute the Action"""
        if self.skip_update():
            return

        g = self.experiment.population.topology.graph
        degrees = list(nx.degree(g).values())
        row = [
            self.experiment.epoch,
            nx.number_of_nodes(g),
            nx.number_of_edges(g),
            mean(degrees),
            std(degrees),
            nx.average_clustering(g),
            nx.diameter(g),
            nx.number_connected_components(g)
        ]
        self.writer.writerow(row)
    def update(self):
        """Execute the Action"""
        if self.skip_update():
	        return

        g = self.experiment.population.topology.graph
        degrees = list(nx.degree(g).values())
        row = [self.experiment.epoch, nx.number_of_nodes(g), nx.number_of_edges(g), mean(degrees), std(degrees), nx.average_clustering(g), nx.diameter(g), nx.number_connected_components(g)]
        self.writer.writerow(row)