示例#1
0
文件: read_cdf.py 项目: piannucci/rlp
def get_known_cdf_time(n_f):
    time = np.zeros((lsnr.size, n_f.size), float)
    for j, n in enumerate(n_f):
        for i, c in enumerate(ccdf):
            st = strategizer(c, x_cdf).summary(n)
            t, p = strategy_time(st, c, x_cdf, n, False)
            time[i, j] = t/p
    return time
示例#2
0
文件: read_cdf.py 项目: piannucci/rlp
def get_arq_time(n_f, after_n):
    time = np.zeros((lsnr.size, n_f.size), float)
    for j, n in enumerate(n_f):
        for i, c in enumerate(ccdf):
            st = [after_n]
            t, p = strategy_time(st, c, x_cdf, n, False)
            time[i, j] = t/p
    return time
示例#3
0
文件: read_cdf.py 项目: piannucci/rlp
def get_cdf_trace(Fs, t, lsnr_trace, n_f, length, known_cdfs, alpha):
    out_throughput = np.zeros(10000)
    out_time = np.zeros(10000)
    if not known_cdfs:
        learner = gaussian_ccdf_learner(x_cdf, alpha)
    time = 0.
    i = 0
    while time < t[-1]:
        # get the current ccdf
        current_lsnr = lsnr_trace[np.nonzero(t>=time)[0][0]]
        idx = np.clip(current_lsnr-np.amin(lsnr), 0, lsnr.size-1)
        c = ccdf[int(idx)]
        if int(idx)+1 < lsnr.size:
            a = idx - int(idx)
            c = c + a * (ccdf[int(idx)+1] - c)
        # pick a strategy
        if known_cdfs:
            st = strategizer(c, x_cdf).summary(n_f)
        else:
            st = strategizer(learner.getstate(), x_cdf).summary(n_f)
        # follow the strategy for one transmission
        if not known_cdfs:
            r = np.random.random()
            n_success = x_cdf[np.where(r > c)[0]]
            n_success = n_success[0] if n_success.size else x_cdf[-1]
            learner.learn(n_success)
        time_, p_success_ = strategy_time(st, c, x_cdf, n_f, False)
        # time is in half symbols
        time += time_/Fs/2
        throughput = Fs*length*p_success_/(time_/2)
        i += 1
        if i % 100 == 0:
            replace_line('known_cdfs=%s alpha=%.2f t=%5.1f ms  SNR=%5.2f dB  throughput=%4.1f Mbps  capacity=%4.1f Mbps' % (known_cdfs, alpha, 1000*time, current_lsnr, throughput*1e-6, 12*np.log2(1+10.**(.1*current_lsnr))))
        if i >= out_throughput.size:
            out_throughput = np.r_[out_throughput, np.zeros(10000)]
            out_time = np.r_[out_time, np.zeros(10000)]
        out_throughput[i] = throughput
        out_time[i] = time
    replace_line('')
    return out_throughput[:i], out_time[:i]