Ns = np.array([2, 2, 2]) # np.ones(K) * 2 multiuserchannel = MultiUserChannelMatrix() modulator = PSK(4) SNR = 40 noise_var = 1 / dB2Linear(SNR) print("SNR: {0}".format(SNR)) print("noise_var: {0}".format(noise_var)) multiuserchannel.randomize(Nr, Nt, K) multiuserchannel.noise_var = noise_var ia_solver = algorithms.AlternatingMinIASolver(multiuserchannel) ia_solver2 = algorithms.MMSEIASolver(multiuserchannel) ia_solver3 = algorithms.MaxSinrIASolver(multiuserchannel) ia_solver4 = algorithms.AlternatingMinIASolver(multiuserchannel) # ia_solver.initialize_with_closed_form = True # ia_solver2.initialize_with_closed_form = True # ia_solver3.initialize_with_closed_form = True ia_solver.randomizeF(Ns) ia_solver.max_iterations = 400 ia_solver.solve(Ns) ia_solver2.randomizeF(Ns) ia_solver2.max_iterations = 100 ia_solver2.solve(Ns)
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!")
noise_var = 1 / dB2Linear(SNR) M = 2 NSymbs = 50 rep_max = 300 modulator = fundamental.BPSK() K = 3 Nr = np.ones(K, dtype=int) * 2 Nt = np.ones(K, dtype=int) * 2 Ns = np.ones(K, dtype=int) * 1 multi_user_channel = pyphysim.channels.multiuser.MultiUserChannelMatrix() multi_user_channel_quant = pyphysim.channels.multiuser.MultiUserChannelMatrix( ) multi_user_channel.noise_var = noise_var multi_user_channel_quant.noise_var = noise_var ia_solver = algorithms.MaxSinrIASolver(multi_user_channel_quant) ia_solver.max_iterations = 120 pb = ProgressbarText2(rep_max, '*', message="SNR {0} - {{elapsed_time}}".format(SNR)) symbolErrors = 0 bitErrors = 0 numSymbols = 0 numBits = 0 # xxxxxxxxxx Quantization paramters xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx codebook_size = 512 dimension = 4 codebook = gen_codebook(codebook_size, dimension)