Beispiel #1
0
def main():
    """Main function.
    """
    K = 3
    Nr = 4
    Nt = 4
    Ns = 2
    SNR = 30.0
    P = 1.0

    # Dependent parameters
    noise_var = 1 / dB2Linear(SNR)

    RepMax = 1
    mmse_sinrs = np.empty([RepMax, K, Ns], dtype=float)
    max_sinr_sinrs = np.empty([RepMax, K, Ns], dtype=float)
    mmse_capacity = np.empty(RepMax, dtype=float)
    max_sinr_capacity = np.empty(RepMax, dtype=float)

    pbar = ProgressbarText(RepMax, message="Simulating for SNR: {0}".format(SNR))

    for rep in range(RepMax):
        # Creat the channel
        multiUserChannel = pyphysim.channels.multiuser.MultiUserChannelMatrix()
        multiUserChannel.randomize(Nr, Nt, K)
        multiUserChannel.noise_var = noise_var

        # Creat the IA solver object
        mmse_ia_solver = algorithms.MMSEIASolver(multiUserChannel)
        max_sinr_ia_solver = algorithms.MaxSinrIASolver(multiUserChannel)

        mmse_ia_solver.randomizeF(Ns, P)

        mmse_ia_solver.initialize_with = 'fix'
        max_sinr_ia_solver.initialize_with = 'fix'
        # noinspection PyProtectedMember
        max_sinr_ia_solver._F = mmse_ia_solver._F

        #mmse_ia_solver.initialize_with = 'fix'

        # We wouldn't need to explicitly set ia_solver.noise_var
        # variable if the multiUserChannel object had the correct value at
        # this point.
        # mmse_ia_solver.noise_var = noise_var
        mmse_ia_solver.max_iterations = 200
        mmse_ia_solver.solve(Ns)

        # max_sinr_ia_solver.noise_var = noise_var
        max_sinr_ia_solver.max_iterations = 200

        max_sinr_ia_solver.solve(Ns)

        mmse_sinrs[rep] = list(map(linear2dB, mmse_ia_solver.calc_SINR()))
        max_sinr_sinrs[rep] = list(map(linear2dB, max_sinr_ia_solver.calc_SINR()))

        mmse_capacity[rep] = np.sum(calc_capacity(mmse_ia_solver.calc_SINR()))
        max_sinr_capacity[rep] = np.sum(calc_capacity(max_sinr_ia_solver.calc_SINR()))

        # print "MMSE Alt. SINRs:\n{0}".format(np.vstack(mmse_sinrs[rep]))
        # print "Max SINR Alg. SINRs:\n{0}".format(np.vstack(max_sinr_sinrs[rep]))

        # print "MMSE Alt. Capacity: {0}".format(np.sum(calc_capacity(mmse_sinrs[rep])))
        # print "Max SINR Alg. Capacity: {0}".format(np.sum(calc_capacity(max_sinr_sinrs[rep])))
        # print

        pbar.progress(rep)

    print("MMSE Average SINRs:\n{0}".format(mmse_sinrs.mean(0)))
    print("Max SINR Average SINRs:\n{0}".format(max_sinr_sinrs.mean(0)))
    print("MMSE Average Capacity: {0}".format(mmse_capacity.mean()))
    print("Max SINR Average Capacity: {0}".format(max_sinr_capacity.mean()))

    print("\nEnd!")
Beispiel #2
0
        # print "\nMax SINR"
        (max_sinr_SINRs[rep], max_sinr_capacity[rep],
         max_sinr_sum_capacity[rep]) = calc_SINRs_and_capacity(max_sinr_solver)
        # print "SINRs:\n{0}".format(max_sinr_SINRs[rep])
        # print "Capacity:\n{0}".format(max_sinr_capacity[rep])
        # print "Sum_Capacity: {0}".format(max_sinr_sum_capacity[rep])

        # print "\nMMSE"
        (mmse_SINRs[rep], mmse_capacity[rep],
         mmse_sum_capacity[rep]) = calc_SINRs_and_capacity(mmse_solver)
        # print "SINRs:\n{0}".format(mmse_SINRs[rep])
        # print "Capacity:\n{0}".format(mmse_capacity[rep])
        # print "Sum_Capacity: {0}".format(mmse_sum_capacity[rep])

        pbar.progress(rep)

    df = DataFrame({
        'Min. Leakage': alt_min_sum_capacity,
        'Max SINR': max_sinr_sum_capacity,
        'MMSE': mmse_sum_capacity
    })
    df.to_csv(
        'sum_capacity_{Nr}x{Nt}_{Ns}_SNR_{SNR}_{initialize_with}_init.txt'.
        format(Nr=Nr, Ns=Ns, Nt=Nt, SNR=SNR, initialize_with=initialize_with),
        index_label="Index")

    plt.plot([sum(alt_min_capacity[a]) for a in range(50)])
    plt.plot([sum(max_sinr_capacity[a]) for a in range(50)])
    plt.plot([sum(mmse_capacity[a]) for a in range(50)])
    plt.legend(["Min Leakage", "Max SINR", "MMSE"])
Beispiel #3
0
def main():
    """Main function.
    """
    K = 3
    Nr = 4
    Nt = 4
    Ns = 2
    SNR = 30.0
    P = 1.0

    # Dependent parameters
    noise_var = 1 / dB2Linear(SNR)

    RepMax = 1
    mmse_sinrs = np.empty([RepMax, K, Ns], dtype=float)
    max_sinr_sinrs = np.empty([RepMax, K, Ns], dtype=float)
    mmse_capacity = np.empty(RepMax, dtype=float)
    max_sinr_capacity = np.empty(RepMax, dtype=float)

    pbar = ProgressbarText(RepMax, message="Simulating for SNR: {0}".format(SNR))

    for rep in range(RepMax):
        # Creat the channel
        multiUserChannel = pyphysim.channels.multiuser.MultiUserChannelMatrix()
        multiUserChannel.randomize(Nr, Nt, K)
        multiUserChannel.noise_var = noise_var

        # Creat the IA solver object
        mmse_ia_solver = algorithms.MMSEIASolver(multiUserChannel)
        max_sinr_ia_solver = algorithms.MaxSinrIASolver(multiUserChannel)

        mmse_ia_solver.randomizeF(Ns, P)

        mmse_ia_solver.initialize_with = "fix"
        max_sinr_ia_solver.initialize_with = "fix"
        # noinspection PyProtectedMember
        max_sinr_ia_solver._F = mmse_ia_solver._F

        # mmse_ia_solver.initialize_with = 'fix'

        # We wouldn't need to explicitly set ia_solver.noise_var
        # variable if the multiUserChannel object had the correct value at
        # this point.
        # mmse_ia_solver.noise_var = noise_var
        mmse_ia_solver.max_iterations = 200
        mmse_ia_solver.solve(Ns)

        # max_sinr_ia_solver.noise_var = noise_var
        max_sinr_ia_solver.max_iterations = 200

        max_sinr_ia_solver.solve(Ns)

        mmse_sinrs[rep] = list(map(linear2dB, mmse_ia_solver.calc_SINR()))
        max_sinr_sinrs[rep] = list(map(linear2dB, max_sinr_ia_solver.calc_SINR()))

        mmse_capacity[rep] = np.sum(calc_capacity(mmse_ia_solver.calc_SINR()))
        max_sinr_capacity[rep] = np.sum(calc_capacity(max_sinr_ia_solver.calc_SINR()))

        # print "MMSE Alt. SINRs:\n{0}".format(np.vstack(mmse_sinrs[rep]))
        # print "Max SINR Alg. SINRs:\n{0}".format(np.vstack(max_sinr_sinrs[rep]))

        # print "MMSE Alt. Capacity: {0}".format(np.sum(calc_capacity(mmse_sinrs[rep])))
        # print "Max SINR Alg. Capacity: {0}".format(np.sum(calc_capacity(max_sinr_sinrs[rep])))
        # print

        pbar.progress(rep)

    print("MMSE Average SINRs:\n{0}".format(mmse_sinrs.mean(0)))
    print("Max SINR Average SINRs:\n{0}".format(max_sinr_sinrs.mean(0)))
    print("MMSE Average Capacity: {0}".format(mmse_capacity.mean()))
    print("Max SINR Average Capacity: {0}".format(max_sinr_capacity.mean()))

    print("\nEnd!")
        (max_sinr_SINRs[rep],
         max_sinr_capacity[rep],
         max_sinr_sum_capacity[rep]) = calc_SINRs_and_capacity(max_sinr_solver)
        # print "SINRs:\n{0}".format(max_sinr_SINRs[rep])
        # print "Capacity:\n{0}".format(max_sinr_capacity[rep])
        # print "Sum_Capacity: {0}".format(max_sinr_sum_capacity[rep])

        # print "\nMMSE"
        (mmse_SINRs[rep],
         mmse_capacity[rep],
         mmse_sum_capacity[rep]) = calc_SINRs_and_capacity(mmse_solver)
        # print "SINRs:\n{0}".format(mmse_SINRs[rep])
        # print "Capacity:\n{0}".format(mmse_capacity[rep])
        # print "Sum_Capacity: {0}".format(mmse_sum_capacity[rep])

        pbar.progress(rep)


    df = DataFrame({'Min. Leakage':alt_min_sum_capacity,
                    'Max SINR': max_sinr_sum_capacity,
                    'MMSE': mmse_sum_capacity})
    df.to_csv(
        'sum_capacity_{Nr}x{Nt}_{Ns}_SNR_{SNR}_{initialize_with}_init.txt'.format(
            Nr=Nr, Ns=Ns, Nt=Nt, SNR=SNR, initialize_with=initialize_with),
        index_label="Index")

    plt.plot([sum(alt_min_capacity[a]) for a in range(50)])
    plt.plot([sum(max_sinr_capacity[a]) for a in range(50)])
    plt.plot([sum(mmse_capacity[a]) for a in range(50)])
    plt.legend(["Min Leakage", "Max SINR", "MMSE"])