-
Notifications
You must be signed in to change notification settings - Fork 16
/
example_SCUS.py
79 lines (61 loc) · 1.91 KB
/
example_SCUS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 26 14:11:15 2018
@author: lsalaun
© 2016 - 2020 Nokia
Licensed under Creative Commons Attribution Non Commercial 4.0 International
SPDX-License-Identifier: CC-BY-NC-4.0
"""
import numpy as np
import matplotlib.pyplot as plt
import generate_gains
import channel_allocation_JSPA as ca_jspa
K = 5 # Number of users
L = 1 # Number of subcarriers
Multiplex = 3 # Number of users per subcarrier
# Radius of the cell
Radius = 1000
# Min distance between user and BS = 35 m
rmin = 35
#np.random.seed(1)
G = generate_gains.generateGains(K,L,Radius,rmin)
# B : total bandwidth = 5 MHz
B = 5*10**6
W = np.ones(L)*B/L
# Noise value per Hertz = -174 dBm/Hz
Noise_Hz = 10**((-174-30)/10)
N = np.ones(K*L)*Noise_Hz*B/L
N_G = ca_jspa.computeN_G(G,N)
# Decoding order
pi,pi_inv = ca_jspa.computePi(G,N)
# Random weights
w = np.random.rand(K)
# Considered subcarrier
lsub = 0
# Power budget
Pmax = 1
print('pi =',pi)
print('w =',w)
print('G =\n',G)
print('\n----------------------- TEST SCUS and i-SCUS on a single subcarrier with at most 3 active users out of 5 -----------------------')
espilon = 1e-3
X = np.arange(espilon,Pmax,espilon)
Y_SCUS = np.zeros(X.shape)
Y_SpeedUp_SCUS = np.zeros(X.shape)
# speedUp_SCUS initialization
speedUp_SCUS = ca_jspa.SpeedUpSCUS(K,Multiplex,Pmax,N_G[lsub],lsub,pi,pi_inv,w,W)
for index in range(len(X)):
# SCUS computation
x_f2l = ca_jspa.SCUS_first2last(K,Multiplex,X[index],N_G[lsub],lsub,pi,w,W)
p_f2l = ca_jspa.X2P_sc(x_f2l,pi,K,lsub)
Y_SCUS[index] = np.sum(ca_jspa.computeWSR_sc(K,lsub,N_G[lsub],pi,pi_inv,w,W,p_f2l))
# speedUp_SCUS computation
x,p,wsr = speedUp_SCUS.speedUp_SCUS(X[index])
Y_SpeedUp_SCUS[index] = np.sum(wsr)
plt.figure(0)
plt.plot(X,Y_SCUS,'-',label='SCUS')
plt.plot(X,Y_SpeedUp_SCUS,'o',markevery=0.05,label='i-SCUS (speed up)')
plt.xlabel('Power budget (W)')
plt.ylabel('WSR (bit/s)')
plt.legend()
plt.show()