table3.append(json.loads(line)) plt.subplot(2, 1, 1) plt.semilogy(table[7], [10**i for i in table[8]], 'r-o', label="Channel_p=design_p") plt.semilogy(table2[9], [10**i for i in table2[10]], 'b-o', label="Rateless KRX") plt.semilogy(table3[11], [10**i for i in table3[12]], 'g-o', label="Rateless LTPT") plt.xlabel('Achieved Rate') plt.ylabel('Frame Error rate.') plt.title('FER vs Rate Rateless LTPT design \nN=1024,channel_p=' + str(p) + ',Capacity=' + str(pl.CapacityBSC(1, p))) plt.legend(loc="best") plt.grid(True) plt.figtext( 0.005, 0.03, "Compound Channel=[0.04,0.15,0.2,0.25]\n" + filename1 + "\n" + filename2 + "\n" + filename3) plt.subplot(2, 1, 2) print table3[10] print table3[11] plt.plot(table3[10], table3[11], 'g-o', label="Rateless LTPT") plt.plot(table2[8], table2[9], 'b-o', label="Rateless KRX") plt.title("Sent rate vs achieved rate") plt.ylabel('Achieved Rate') plt.xlabel('Sent Rate')
#=================================================================simulation #------------Number of good channels = capacity Nlist = [1024] #Nlist=[2048] #Nlist=[4096] design_plist = [0.25] #,0.15,0.2,0.25] deratelist = np.arange(0.1, 1.1, 0.1) #using ZCK FER_dict = {} runsim = 10 for N in Nlist: for design_p in design_plist: C = pl.CapacityBSC(N, design_p) stamp = datetime.now().strftime("%y-%m-%d_%H-%M-%S") f1 = open( "./simresults/polarchannel_FERvsR_derate_pch" + str(N) + "_" + str(design_p) + "_" + stamp + ".txt", 'w') print "RATE Vs FER REPORT derate pch" print "-----------------------------" print "N=" + str(N) print "p_design=" + str(design_p) print "capacity*N:" + str(C) print "sim ran :" + str(runsim) json.dump("RATE Vs FER REPORT derate pch", f1) f1.write("\n") json.dump("-----------------------------", f1)
channel_plist = [0.04, 0.15, 0.2, 0.25] channel_plist.sort() lesser_channel_p = channel_plist[1] design_p = min(channel_plist) #design agrressively runsim = 1000 LT = 30 theta1 = 59 theta2 = 59 stamp = datetime.now().strftime("%y-%m-%d_%H-%M-%S") f1 = open("./simresults/lambda_theta_LT" + stamp + ".txt", 'w') #---------------------------------------------------------------design: C = pl.CapacityBSC(N, design_p) deratepercentage = 10 tolerable_error = -2 if designbyrate: #K=int((100-deratepercentage)*C/100) K = int(C) try: I = pcon.getGCHsim('ZK', N, design_p, K) RI = pcon.getGChsim('ZK', design_p, N, N) except: (I, E) = pcon.getGChZCK(design_p, N, K) (RI, E) = pcon.getGChZCK(design_p, N, N)
# Name: capplotter.py # Purpose: plotter for capacity and achieved rate # # Author: soumya # # Created: 19/08/2017 #---------------------------------------- import matplotlib.pyplot as plt import json import numpy as np import problib as pl #-------------------------------------------Capacity p = [0.04, 0.15, 0.2, 0.25] Cap = [pl.CapacityBSC(1, i) for i in p] reln1 = [0.590455, 0.244918, 0.165899, 0.108582] reln1LTPT = [0.597722, 0.216538, 0.130841, 0.072411] reln1KRX = [0.59, 0.190323, 0.117742] #--------------nonRateless #~ #0.2 #~ r3=[0.02734375, 0.0546875, 0.0830078125, 0.1103515625, 0.138671875, 0.166015625, 0.1943359375, 0.2216796875, 0.25, 0.27734375] #~ e3=[float("inf"), float("inf"), float("inf"), -2.886056647693163, -1.6575773191777938, -0.9867413347164835, -0.4487940562520938, -0.18889439298206961, -0.05070759858797432, -0.00718147993332044] #~ #0.04 #~ r1=[0.0751953125, 0.1513671875, 0.2265625, 0.302734375, 0.3779296875, 0.4541015625, 0.5302734375, 0.60546875, 0.681640625, 0.7568359375] #~ e1=[float("inf"), float("inf"), float("inf"), float("inf"), float("inf"), -3.5228787452803374, -1.5044556624535514, -0.5705707356182124, -0.08788427092114617, -0.0012612837441822772] #~ #0.15 #~ r2=[0.0380859375, 0.0771484375, 0.1162109375, 0.1552734375, 0.1943359375, 0.2333984375, 0.2724609375, 0.3115234375, 0.3505859375, 0.3896484375] #~ e2=[float("inf"), float("inf"), float("inf"), -4.0, -2.1191864077192086, -1.1944991418415998, -0.5775743236287953, -0.21070138884055886, -0.04662694927330402, -0.0039263455147246756] #~ #0.25
def getRatelist(plist, derate): #insert derating Ratelist = [pl.CapacityBSC(1, p) * derate for p in plist] return Ratelist
plist = [0.05, 0.07, 0.1, 0.2, 0.3, 0.4] p = 0.05 #design agrressively tolerable_error = -1 K = 16 runsim = 10 stamp = datetime.now().strftime("%y-%m-%d_%H-%M-%S") f1 = open("./simresults/lambda_avg" + stamp + ".txt", 'w') #==========================================================Construction print "LLR Lambda REPORT" print "---------------------------" print "N=" + str(N) print "design_p=" + str(p) PotGCh = int(ma.floor(pl.CapacityBSC(N, p))) print "Capacity for " + str(N) + "channels:" + str(PotGCh) print "tolerable error exponent:" + str(tolerable_error) print "sim ran :" + str(runsim) #-----------------------------------------ZC #(I,E)=pcon.getGChZCL(p,N,tolerable_error) #(I,E)=pcon.getGChZCK(p,N,K) I = pcon.getGCHsim("MK_ALL", N, p, K) print "Good Channels:" print I print "Number of good channels:" print len(I) R = float(len(I)) / N print "R=" + str(R) print "Frozen channels:" B = list(set(range(N)) - set(I))
table3 = [] with open(filename3, 'r') as f: for line in f: table3.append(json.loads(line)) #~ table4 = [] #~ with open(filename4,'r') as f: #~ for line in f: #~ table4.append(json.loads(line)) plt.semilogy(table1[7], [10**i for i in table1[8]], 'r-o', label="derate ") #~ plt.semilogy(table2[7],[10**i for i in table2[8]],'b-o',label="derate pch") plt.semilogy(table3[7], [10**i for i in table3[8]], 'g-o', label="sendpolar") #~ plt.semilogy(table4[7],[10**i for i in table4[8]],'k-o',label="1ITER") #plt.semilogy(table3[11],[10**i for i in table3[12]],'g-o',label="Rateless LTPT") plt.xlabel('Achieved Rate') plt.ylabel('Frame Error rate.') plt.title('0p04 resolver \nN=1024,channel_p=' + str(p) + ',Capacity=' + str(pl.CapacityBSC(1, p))) plt.legend(loc="best") plt.grid(True) plt.figtext( 0.005, 0.03, "Compound Channel=[0.04,0.15,0.2,0.25]\n" + filename1 + "\n" + filename3) plt.show() #------------------------------------------------------------------