def __init__(self): self.Num_AP = 1 self.Num_UE = 50 self.channel = [1] self.oriTHO = np.zeros([1, self.Num_AP]) loss_cal = env.Scenario(self.Num_AP, self.Num_UE, freq=2, avr_ap=1) self.contact, self.placeAP, self.placeUE, self.Loss = loss_cal.sendout( ) self.action_space = spaces.Box(low=-0.2, high=0.2, shape=(self.Num_AP, ), dtype=np.float32) self.observation_space = spaces.Box(low=-0, high=1, shape=(self.Num_AP, ), dtype=np.float32) self.state = self.Num_AP * [0.5] envir = tho.ThoughtOutCal(self.channel, self.state * 60, self.Num_AP, self.Num_UE) RSSI, Speed, self.connection = envir.subspeed(self.Loss) thought_out_ue, P = envir.thomain(Speed, self.connection) # 将UE的转化为AP的 thought_out_AP = np.zeros([self.Num_AP]) for kki in range(0, self.Num_AP): tempN = np.argwhere(self.connection == kki) for kkj in tempN: thought_out_AP[kki] += thought_out_ue[kkj] self.oriTHO[:] = thought_out_AP[:]
unused = np.squeeze(unused, axis=1) placeUE = np.delete(placeUE, unused, axis=1) connection = np.delete(connection, unused) for UEloop in range(0, len(connection)): plt.plot([placeUE[0, UEloop], placeAP[0, int(connection[UEloop])]], [placeUE[1, UEloop], placeAP[1, int(connection[UEloop])]], color=color[int(connection[UEloop])]) if __name__ == '__main__': Num_AP = 9 Num_UE = 100 channel = [1, 2, 1, 2, 2, 3, 2, 1, 1] # power = 9*[40] # env part env = env.Scenario(Num_AP=Num_AP, Num_UE=Num_UE, freq=2, avr_ap=1) contact, placeAP, placeUE, Loss = env.sendout() with open('thought结果.csv', 'w') as f: csvwrite = csv.writer(f, dialect='excel') # csvwrite.writerow(['time=2019-1-3']) # with open('SNR结果.csv', 'w') as f: # uw = csv.writer(f, dialect='excel') # uw.writerow(['time=2019-1-3']) # power = np.random.randint(0, 50, Num_AP) # tho = ThoughtOutCal(channel, power, Num_AP, Num_UE) # RSSI, Speed, connection = tho.subspeed(Loss) # thought_out_simulate, P = tho.thomain(Speed, connection) # ending = np.sum(thought_out_simulate) # thought_out_AP = thAP(thought_out_simulate, connection, Num_AP)