示例#1
0
class SensorNetwork:
    def __init__(self, nodes=None, channel=None):
        self.nodes = [Node()] if nodes is None else nodes
        self.channel = Channel() if channel is None else channel
        self.last_ack = None

    def step(self):
        trx_and_reward = [node.step(self.last_ack[i_n] if self.last_ack is not None else None) for i_n, node in enumerate(self.nodes)]  # make decisions
        trx = [ele[0] for ele in trx_and_reward]
        rewards = [ele[1] for ele in trx_and_reward]
        ack = self.channel.communicate(trx)
        self.last_ack = ack
        return rewards

    def reset(self):
        map(Node.reset, self.nodes)
        self.channel.reset()
        self.last_ack = None
示例#2
0
 def __init__(self, nodes=None, channel=None):
     self.nodes = [Node()] if nodes is None else nodes
     self.channel = Channel() if channel is None else channel
     self.last_ack = None
示例#3
0
 def __init__(self, nodes=None, channel=None):
     self.nodes = [Node()] if nodes is None else nodes
     self.channel = Channel() if channel is None else channel
     self.last_ack = None