Last active
January 17, 2019 12:59
-
-
Save imandarabi/3d1f69ceabbbece02f4ea18a9c028d95 to your computer and use it in GitHub Desktop.
Energy-efficient resource assignment and power allocation / simulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from numpy.random import randint, uniform # generate random matrix | |
from math import log, hypot # log base 2 => log(num,2) | |
from copy import deepcopy | |
from Two_tier_HCRAN import Two_tier_HCRAN | |
from One_tire_HPN import One_tire_HPN | |
from One_tire_CRAN import One_tire_CRAN | |
from Two_tier_overlaid_HETNET import Two_tier_overlaid_HETNET | |
def run_Two_tier_HCRAN(): | |
tt_hcran = Two_tier_HCRAN() | |
ot_hpn = One_tire_HPN() | |
ot_cran = One_tire_CRAN() | |
tt_overlaid_HETNET = Two_tier_overlaid_HETNET() | |
tt_hcran.init_RRH_RB_PW_H_PL() | |
ot_hpn.init_RRH_RB_PW_H_PL() | |
ot_cran.init_RRH_RB_PW_H_PL() | |
tt_overlaid_HETNET.init_RRH_RB_PW_H_PL() | |
res_tt_hcran , res_ot_hpn, res_ot_cran, res_tt_overlaid_HETNET = [], [], [], [] | |
SUM_res_tt_hcran , SUM_res_ot_hpn, SUM_res_ot_cran, SUM_res_tt_overlaid_HETNET = (([0]*16) for i in range(4)) | |
# print '\n\nsum data rate is : ', tt_hcran.sum_data_rate_RRH() | |
iteration = 1000 | |
for k in range(iteration): | |
for i in range(1,16): | |
tt_hcran.RUE_M = i | |
ot_hpn.RUE_M = i | |
ot_cran.RUE_M = i | |
tt_overlaid_HETNET.RUE_M = i | |
res_tt_hcran.append(tt_hcran.problem_1()) | |
res_ot_cran.append(ot_cran.problem_1()) | |
res_ot_hpn.append(ot_hpn.problem_1()) | |
res_tt_overlaid_HETNET.append(tt_overlaid_HETNET.problem_1()) | |
SUM_res_tt_hcran = [ x+y for x,y in zip(SUM_res_tt_hcran, res_tt_hcran)] | |
SUM_res_ot_cran = [ x+y for x,y in zip(SUM_res_ot_cran, res_ot_cran)] | |
SUM_res_ot_hpn = [ x+y for x,y in zip(SUM_res_ot_hpn, res_ot_hpn)] | |
SUM_res_tt_overlaid_HETNET = [ x+y for x,y in zip(SUM_res_tt_overlaid_HETNET, res_tt_overlaid_HETNET)] | |
SUM_res_tt_hcran = [round(x/iteration, 5) for x in SUM_res_tt_hcran] | |
SUM_res_ot_cran = [round(x/iteration, 5) for x in SUM_res_ot_cran] | |
SUM_res_ot_hpn = [round(x/iteration, 5) for x in SUM_res_ot_hpn] | |
SUM_res_tt_overlaid_HETNET = [round(x/iteration, 5) for x in SUM_res_tt_overlaid_HETNET] | |
print "Two_tier_HCRAN: ", SUM_res_tt_hcran, '\n' | |
print "One_tire_CRAN: ", SUM_res_ot_cran, '\n' | |
print "One_tire_HPN: ", SUM_res_ot_hpn, '\n' | |
print "Two_tier_overlaid_HETNET: ", SUM_res_tt_overlaid_HETNET, '\n' | |
if __name__ == '__main__': | |
print '__main__ program... ' | |
run_Two_tier_HCRAN() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from numpy.random import randint, uniform # generate random matrix | |
from math import log, hypot # log base 2 => log(num,2) | |
from copy import deepcopy | |
class One_tire_CRAN (object): | |
def __init__ (self): | |
self.sigma = None | |
self.RUE_N = 10 # Number of RUE's located in each RRH with the high-rate-constrained QOS. (cell center zone UEs) | |
self.RUE_M = 1 # cell edge zone UEs | |
self.d_Pn1 = 50 # In case of (1 <= n <= N) | |
self.d_Mn1 = 450 # In case of (1 <= n <= N) | |
self.d_Pn2 = 75 # In case of (N+1 <= n <= N+M) | |
self.d_Mn2 = 375 # In case of (N+1 <= n <= N+M) | |
self.d_R2M = 125 # the distance between the reference RRH and HUE who reuse the kth RB | |
self.P_bh = 0.2 # the power consumtion of the fronthaul link P_bh, and the backhaul link between the HPN and the BBU pool P_bh. | |
#self.omega_1 = range(self.N_cell_center_zone_UEs) # There are RUE_N per RRH occupying ther RB set omega_1 ( Ω1 ) | |
#self.omega_2 = range(self.M_cell_edge_zone_UEs) # ( Ω2 ) | |
feasible_RB = None # a[n,k] is defined as the RB allocation indicator, which can only be 1 or 0. | |
pw_allo_policy = None # p[n,k] denotes the transmit power allocated to RUE n on the kth RB. | |
self.K = 25 # The number of total RBs is K=25, and the system bandwidth is B0=5 MHz. | |
self.B0 = 5 # In the OFDMA-based download H-CRANs, there are total K RBs (denoted as ΩT) with bandwidth B0 (MHz). | |
self.N0 = 0.00001 # the estimated power spectrum density of both the sum of noise and weak inter-RRH interference( in dBm/Hz) | |
self.P_M =43 # Is the allowed transmit power allocated on each RB in HPN (dBm). and it's equally allocated on all RBs. | |
def init_RRH_RB_PW_H_PL (self): | |
""" | |
RB => N=2, M=1, K=4 | |
[[1 1 0 1] | |
[0 0 1 0] | |
[0 0 0 0]] | |
PW => N=2, M=1, K=4 | |
[[0.15 0.93 0. 0.77] | |
[ 0. 0. 0.52 0. ] | |
[ 0. 0. 0. 0. ]] | |
""" | |
self.feasible_RB = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = self.feasible_PW.astype(float) | |
self.PATH_LOSS_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_RRH_RUE = self.feasible_PW.astype(float) | |
self.PATH_LOSS_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_HPN_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_RRH_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_HPN_RUE = self.feasible_PW.astype(float) | |
for i in range(self.K): | |
tmp = randint(self.RUE_N+self.RUE_M) | |
self.feasible_RB[tmp][i] = 1 | |
self.feasible_PW[tmp][i] = uniform(0,1) | |
for i in range(self.RUE_N+self.RUE_M): | |
for j in range(self.K): | |
if self.feasible_RB[i][j] == 1: | |
if i <= self.RUE_N: # so the RUE is in the high-rate-constrained QOS and allocated by the orthogonal RB set Ω1 | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 35.0 * log(self.d_Pn1,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn1,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn1 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn1 ** 3) | |
else: | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 35.0 * log(self.d_Pn2,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn2,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn2 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn2 ** 3) | |
return self.feasible_RB, self.feasible_PW, self.PATH_LOSS_RRH_RUE, self.PATH_LOSS_HPN_RUE | |
def cinr( self, PATH_LOSS_RRH_RUE, PATH_LOSS_HPN_RUE, | |
CHAN_GAIN_RRH_RUE, CHAN_GAIN_HPN_RUE, | |
omega): # channel-to-interference-plus-noise ratio | |
if omega == 1: | |
return ( (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.B0 * self.N0) ) | |
elif omega == 2: | |
return (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.P_M * PATH_LOSS_HPN_RUE * CHAN_GAIN_HPN_RUE + self.B0 * self.N0) | |
return None | |
def sum_data_rate_RRH(self): # C(a,p) | |
sum = 0 | |
for n in range(len(self.feasible_RB)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_RB[0])): # column of feasible_RB Matrix | |
omega = 1 | |
if n > self.RUE_N: omega = 2 | |
sigma = self.cinr(self.PATH_LOSS_RRH_RUE[n,k], self.PATH_LOSS_HPN_RUE[n,k], | |
self.CHAN_GAIN_RRH_RUE[n,k], self.CHAN_GAIN_HPN_RUE[n,k], omega) | |
sum += self.feasible_RB[n,k] * self.B0 * log(1 + sigma * self.feasible_PW[n,k] ,2) | |
return sum | |
def total_pw_HCRAN(self): | |
PHI_eff = 2 | |
PR_c = 0.1 # Watt | |
Pb_h = 0.2 # Watt | |
sum = 0 | |
for n in range(len(self.feasible_PW)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_PW[0])): # column of feasible_RB Matrix | |
sum += (self.feasible_RB[n,k] * self.feasible_PW[n,k] + PR_c + Pb_h) | |
return PHI_eff * sum | |
def init_HPN_RB_PW_H_PL(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def sum_data_rate_HPN(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def problem_1 (self): | |
gamma , gamma_star = (0,0) | |
epsilon = 0 | |
I_max = 1000 | |
for i in range(I_max): | |
self.init_RRH_RB_PW_H_PL() | |
C = self.sum_data_rate_RRH() | |
P = self.total_pw_HCRAN() | |
if C - gamma*P < epsilon : | |
feasible_RB_star = self.feasible_RB.copy() | |
feasible_PW_star = self.feasible_PW.copy() | |
gamma_star = gamma | |
break | |
else: | |
gamma = C / P | |
return gamma_star | |
# print 'gamma_star is: ', gamma_star | |
# print 'feasible_RB_star:\n ' , feasible_RB_star | |
# print 'feasible_PW_star:\n ' , feasible_PW_star | |
def problem_2 (self): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from numpy.random import randint, uniform # generate random matrix | |
from math import log, hypot # log base 2 => log(num,2) | |
from copy import deepcopy | |
class One_tire_HPN (object): | |
def __init__ (self): | |
self.sigma = None | |
self.RUE_N = 10 # Number of RUE's located in each RRH with the high-rate-constrained QOS. (cell center zone UEs) | |
self.RUE_M = 1 # cell edge zone UEs | |
self.d_Pn1 = 50 # In case of (1 <= n <= N) | |
self.d_Mn1 = 450 # In case of (1 <= n <= N) | |
self.d_Pn2 = 75 # In case of (N+1 <= n <= N+M) | |
self.d_Mn2 = 375 # In case of (N+1 <= n <= N+M) | |
self.d_R2M = 125 # the distance between the reference RRH and HUE who reuse the kth RB | |
self.P_bh = 0.2 # the power consumtion of the fronthaul link P_bh, and the backhaul link between the HPN and the BBU pool P_bh. | |
self.P_Mbh = 0.2 # the power consumtion of the fronthaul link P_bh, and the backhaul link between the HPN and the BBU pool P_bh. | |
#self.omega_1 = range(self.N_cell_center_zone_UEs) # There are RUE_N per RRH occupying ther RB set omega_1 ( Ω1 ) | |
#self.omega_2 = range(self.M_cell_edge_zone_UEs) # ( Ω2 ) | |
feasible_RB = None # a[n,k] is defined as the RB allocation indicator, which can only be 1 or 0. | |
pw_allo_policy = None # p[n,k] denotes the transmit power allocated to RUE n on the kth RB. | |
self.K = 25 # The number of total RBs is K=25, and the system bandwidth is B0=5 MHz. | |
self.B0 = 5 # In the OFDMA-based download H-CRANs, there are total K RBs (denoted as ΩT) with bandwidth B0 (MHz). | |
self.N0 = 0.00001 # the estimated power spectrum density of both the sum of noise and weak inter-RRH interference( in dBm/Hz) | |
self.P_M =43 # Is the allowed transmit power allocated on each RB in HPN (dBm). and it's equally allocated on all RBs. | |
def init_RRH_RB_PW_H_PL (self): | |
""" | |
RB => N=2, M=1, K=4 | |
[[1 1 0 1] | |
[0 0 1 0] | |
[0 0 0 0]] | |
PW => N=2, M=1, K=4 | |
[[0.15 0.93 0. 0.77] | |
[ 0. 0. 0.52 0. ] | |
[ 0. 0. 0. 0. ]] | |
""" | |
self.feasible_RB = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = self.feasible_PW.astype(float) | |
self.PATH_LOSS_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_RRH_RUE = self.feasible_PW.astype(float) | |
self.PATH_LOSS_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_HPN_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_RRH_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_HPN_RUE = self.feasible_PW.astype(float) | |
for i in range(self.K): | |
tmp = randint(self.RUE_N+self.RUE_M) | |
self.feasible_RB[tmp][i] = 1 | |
self.feasible_PW[tmp][i] = uniform(0,1) | |
for i in range(self.RUE_N+self.RUE_M): | |
for j in range(self.K): | |
if self.feasible_RB[i][j] == 1: | |
if i <= self.RUE_N: # so the RUE is in the high-rate-constrained QOS and allocated by the orthogonal RB set Ω1 | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn1,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn1,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn1 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn1 ** 3) | |
else: | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn2,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn2,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn2 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn2 ** 3) | |
return self.feasible_RB, self.feasible_PW, self.PATH_LOSS_RRH_RUE, self.PATH_LOSS_HPN_RUE | |
def cinr( self, PATH_LOSS_RRH_RUE, PATH_LOSS_HPN_RUE, | |
CHAN_GAIN_RRH_RUE, CHAN_GAIN_HPN_RUE, | |
omega): # channel-to-interference-plus-noise ratio | |
if omega == 1: | |
return ( (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.B0 * self.N0) ) | |
elif omega == 2: | |
return (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.P_M * PATH_LOSS_HPN_RUE * CHAN_GAIN_HPN_RUE + self.B0 * self.N0) | |
return None | |
def sum_data_rate_RRH(self): # C(a,p) | |
sum = 0 | |
for n in range(len(self.feasible_RB)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_RB[0])): # column of feasible_RB Matrix | |
omega = 1 | |
if n > self.RUE_N: omega = 2 | |
sigma = self.cinr(self.PATH_LOSS_RRH_RUE[n,k], self.PATH_LOSS_HPN_RUE[n,k], | |
self.CHAN_GAIN_RRH_RUE[n,k], self.CHAN_GAIN_HPN_RUE[n,k], omega) | |
sum += self.feasible_RB[n,k] * self.B0 * log(1 + sigma * self.feasible_PW[n,k] ,2) | |
return sum | |
def total_pw_HCRAN(self): | |
PHI_eff = 4 | |
PM_c = 10 # Watt | |
Pb_h = 0.2 # Watt | |
sum = 0 | |
for n in range(len(self.feasible_PW)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_PW[0])): # column of feasible_RB Matrix | |
sum += (self.feasible_RB[n,k] * self.feasible_PW[n,k] + PM_c + Pb_h) | |
return PHI_eff * sum | |
def problem_1 (self): | |
gamma , gamma_star = (0,0) | |
epsilon = 0 | |
I_max = 1000 | |
for i in range(I_max): | |
self.init_RRH_RB_PW_H_PL() | |
C = self.sum_data_rate_RRH() | |
P = self.total_pw_HCRAN() | |
if C - gamma*P < epsilon : | |
feasible_RB_star = self.feasible_RB.copy() | |
feasible_PW_star = self.feasible_PW.copy() | |
gamma_star = gamma | |
break | |
else: | |
gamma = C / P | |
return gamma_star | |
# print 'gamma_star is: ', gamma_star | |
# print 'feasible_RB_star:\n ' , feasible_RB_star | |
# print 'feasible_PW_star:\n ' , feasible_PW_star |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from numpy.random import randint, uniform # generate random matrix | |
from math import log, hypot # log base 2 => log(num,2) | |
from copy import deepcopy | |
class Two_tier_HCRAN (object): | |
def __init__ (self): | |
self.sigma = None | |
self.RUE_N = 10 # Number of RUE's located in each RRH with the high-rate-constrained QOS. (cell center zone UEs) | |
self.RUE_M = 1 # cell edge zone UEs | |
self.d_Pn1 = 50 # In case of (1 <= n <= N) | |
self.d_Mn1 = 450 # In case of (1 <= n <= N) | |
self.d_Pn2 = 75 # In case of (N+1 <= n <= N+M) | |
self.d_Mn2 = 375 # In case of (N+1 <= n <= N+M) | |
self.d_R2M = 125 # the distance between the reference RRH and HUE who reuse the kth RB | |
self.P_bh = 0.2 # the power consumtion of the fronthaul link P_bh, and the backhaul link between the HPN and the BBU pool P_bh. | |
#self.omega_1 = range(self.N_cell_center_zone_UEs) # There are RUE_N per RRH occupying ther RB set omega_1 ( Ω1 ) | |
#self.omega_2 = range(self.M_cell_edge_zone_UEs) # ( Ω2 ) | |
feasible_RB = None # a[n,k] is defined as the RB allocation indicator, which can only be 1 or 0. | |
pw_allo_policy = None # p[n,k] denotes the transmit power allocated to RUE n on the kth RB. | |
self.K = 25 # The number of total RBs is K=25, and the system bandwidth is B0=5 MHz. | |
self.B0 = 5 # In the OFDMA-based download H-CRANs, there are total K RBs (denoted as ΩT) with bandwidth B0 (MHz). | |
self.N0 = 0.00001 # the estimated power spectrum density of both the sum of noise and weak inter-RRH interference( in dBm/Hz) | |
self.P_M =43 # Is the allowed transmit power allocated on each RB in HPN (dBm). and it's equally allocated on all RBs. | |
def init_RRH_RB_PW_H_PL (self): | |
""" | |
RB => N=2, M=1, K=4 | |
[[1 1 0 1] | |
[0 0 1 0] | |
[0 0 0 0]] | |
PW => N=2, M=1, K=4 | |
[[0.15 0.93 0. 0.77] | |
[ 0. 0. 0.52 0. ] | |
[ 0. 0. 0. 0. ]] | |
""" | |
self.feasible_RB = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = self.feasible_PW.astype(float) | |
self.PATH_LOSS_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_RRH_RUE = self.feasible_PW.astype(float) | |
self.PATH_LOSS_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_HPN_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_RRH_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_HPN_RUE = self.feasible_PW.astype(float) | |
for i in range(self.K): | |
tmp = randint(self.RUE_N+self.RUE_M) | |
self.feasible_RB[tmp][i] = 1 | |
self.feasible_PW[tmp][i] = uniform(0,1) | |
for i in range(self.RUE_N+self.RUE_M): | |
for j in range(self.K): | |
if self.feasible_RB[i][j] == 1: | |
if i <= self.RUE_N: # so the RUE is in the high-rate-constrained QOS and allocated by the orthogonal RB set Ω1 | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn1,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn1,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn1 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn1 ** 3) | |
else: | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn2,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn2,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn2 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn2 ** 3) | |
return self.feasible_RB, self.feasible_PW, self.PATH_LOSS_RRH_RUE, self.PATH_LOSS_HPN_RUE | |
def cinr( self, PATH_LOSS_RRH_RUE, PATH_LOSS_HPN_RUE, | |
CHAN_GAIN_RRH_RUE, CHAN_GAIN_HPN_RUE, | |
omega): # channel-to-interference-plus-noise ratio | |
if omega == 1: | |
return ( (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.B0 * self.N0) ) | |
elif omega == 2: | |
return (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.P_M * PATH_LOSS_HPN_RUE * CHAN_GAIN_HPN_RUE + self.B0 * self.N0) | |
return None | |
def sum_data_rate_RRH(self): # C(a,p) | |
sum = 0 | |
for n in range(len(self.feasible_RB)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_RB[0])): # column of feasible_RB Matrix | |
omega = 1 | |
if n > self.RUE_N: omega = 2 | |
sigma = self.cinr(self.PATH_LOSS_RRH_RUE[n,k], self.PATH_LOSS_HPN_RUE[n,k], | |
self.CHAN_GAIN_RRH_RUE[n,k], self.CHAN_GAIN_HPN_RUE[n,k], omega) | |
sum += self.feasible_RB[n,k] * self.B0 * log(1 + sigma * self.feasible_PW[n,k] ,2) | |
return sum | |
def total_pw_HCRAN(self): | |
PHI_eff = 2 | |
PR_c = 0.1 # Watt | |
Pb_h = 0.2 # Watt | |
sum = 0 | |
for n in range(len(self.feasible_PW)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_PW[0])): # column of feasible_RB Matrix | |
sum += (self.feasible_RB[n,k] * self.feasible_PW[n,k] + PR_c + Pb_h) | |
return PHI_eff * sum | |
def init_HPN_RB_PW_H_PL(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def sum_data_rate_HPN(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def problem_1 (self): | |
gamma , gamma_star = (0,0) | |
epsilon = 0 | |
I_max = 1000 | |
for i in range(I_max): | |
self.init_RRH_RB_PW_H_PL() | |
C = self.sum_data_rate_RRH() | |
P = self.total_pw_HCRAN() | |
if C - gamma*P < epsilon : | |
feasible_RB_star = self.feasible_RB.copy() | |
feasible_PW_star = self.feasible_PW.copy() | |
gamma_star = gamma | |
break | |
else: | |
gamma = C / P | |
return gamma_star | |
# print 'gamma_star is: ', gamma_star | |
# print 'feasible_RB_star:\n ' , feasible_RB_star | |
# print 'feasible_PW_star:\n ' , feasible_PW_star | |
def problem_2 (self): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from numpy.random import randint, uniform # generate random matrix | |
from math import log, hypot # log base 2 => log(num,2) | |
from copy import deepcopy | |
class Two_tier_overlaid_HETNET (object): | |
def __init__ (self): | |
self.sigma = None | |
self.RUE_N = 10 # Number of RUE's located in each RRH with the high-rate-constrained QOS. (cell center zone UEs) | |
self.RUE_M = 1 # cell edge zone UEs | |
self.d_Pn1 = 50 # In case of (1 <= n <= N) | |
self.d_Mn1 = 450 # In case of (1 <= n <= N) | |
self.d_Pn2 = 75 # In case of (N+1 <= n <= N+M) | |
self.d_Mn2 = 375 # In case of (N+1 <= n <= N+M) | |
self.d_R2M = 125 # the distance between the reference RRH and HUE who reuse the kth RB | |
self.P_bh = 0.2 # the power consumtion of the fronthaul link P_bh, and the backhaul link between the HPN and the BBU pool P_bh. | |
#self.omega_1 = range(self.N_cell_center_zone_UEs) # There are RUE_N per RRH occupying ther RB set omega_1 ( Ω1 ) | |
#self.omega_2 = range(self.M_cell_edge_zone_UEs) # ( Ω2 ) | |
feasible_RB = None # a[n,k] is defined as the RB allocation indicator, which can only be 1 or 0. | |
pw_allo_policy = None # p[n,k] denotes the transmit power allocated to RUE n on the kth RB. | |
self.K = 25 # The number of total RBs is K=25, and the system bandwidth is B0=5 MHz. | |
self.B0 = 5 # In the OFDMA-based download H-CRANs, there are total K RBs (denoted as ΩT) with bandwidth B0 (MHz). | |
self.N0 = 0.00001 # the estimated power spectrum density of both the sum of noise and weak inter-RRH interference( in dBm/Hz) | |
self.P_M =43 # Is the allowed transmit power allocated on each RB in HPN (dBm). and it's equally allocated on all RBs. | |
def init_RRH_RB_PW_H_PL (self): | |
""" | |
RB => N=2, M=1, K=4 | |
[[1 1 0 1] | |
[0 0 1 0] | |
[0 0 0 0]] | |
PW => N=2, M=1, K=4 | |
[[0.15 0.93 0. 0.77] | |
[ 0. 0. 0.52 0. ] | |
[ 0. 0. 0. 0. ]] | |
""" | |
self.feasible_RB = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = randint(1, size=(self.RUE_N+self.RUE_M , self.K)) | |
self.feasible_PW = self.feasible_PW.astype(float) | |
self.PATH_LOSS_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_RRH_RUE = self.feasible_PW.astype(float) | |
self.PATH_LOSS_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.PATH_LOSS_HPN_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_RRH_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_RRH_RUE = self.feasible_PW.astype(float) | |
self.CHAN_GAIN_HPN_RUE = randint(1, size=(self.RUE_N+self.RUE_M, self.K)) | |
self.CHAN_GAIN_HPN_RUE = self.feasible_PW.astype(float) | |
for i in range(self.K): | |
tmp = randint(self.RUE_N+self.RUE_M) | |
self.feasible_RB[tmp][i] = 1 | |
self.feasible_PW[tmp][i] = uniform(0,1) | |
for i in range(self.RUE_N+self.RUE_M): | |
for j in range(self.K): | |
if self.feasible_RB[i][j] == 1: | |
if i <= self.RUE_N: # so the RUE is in the high-rate-constrained QOS and allocated by the orthogonal RB set Ω1 | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn1,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn1,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn1 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn1 ** 3) | |
else: | |
self.PATH_LOSS_RRH_RUE[i][j] = 31.5 + 40.0 * log(self.d_Pn2,10) | |
self.PATH_LOSS_HPN_RUE[i][j] = 31.5 + 35.0 * log(self.d_Mn2,10) | |
self.CHAN_GAIN_RRH_RUE[i][j] = 0.09 / (self.d_Pn2 ** 3) | |
self.CHAN_GAIN_HPN_RUE[i][j] = 0.09 / (self.d_Mn2 ** 3) | |
return self.feasible_RB, self.feasible_PW, self.PATH_LOSS_RRH_RUE, self.PATH_LOSS_HPN_RUE | |
def cinr( self, PATH_LOSS_RRH_RUE, PATH_LOSS_HPN_RUE, | |
CHAN_GAIN_RRH_RUE, CHAN_GAIN_HPN_RUE, | |
omega): # channel-to-interference-plus-noise ratio | |
if omega == 1: | |
return ( (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.B0 * self.N0) ) | |
elif omega == 2: | |
return (PATH_LOSS_RRH_RUE * CHAN_GAIN_RRH_RUE) / (self.P_M * PATH_LOSS_HPN_RUE * CHAN_GAIN_HPN_RUE + self.B0 * self.N0) | |
return None | |
def sum_data_rate_RRH(self): # C(a,p) | |
sum = 0 | |
for n in range(len(self.feasible_RB)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_RB[0])): # column of feasible_RB Matrix | |
omega = 1 | |
if n > self.RUE_N: omega = 2 | |
sigma = self.cinr(self.PATH_LOSS_RRH_RUE[n,k], self.PATH_LOSS_HPN_RUE[n,k], | |
self.CHAN_GAIN_RRH_RUE[n,k], self.CHAN_GAIN_HPN_RUE[n,k], omega) | |
sum += self.feasible_RB[n,k] * self.B0 * log(1 + sigma * self.feasible_PW[n,k] ,2) | |
return sum | |
def total_pw_HCRAN(self): | |
PHI_eff = 4 | |
PP_c = 6.8 # Watt | |
Pb_h = 0.2 # Watt | |
sum = 0 | |
for n in range(len(self.feasible_PW)): # row of feasible_RB Matrix | |
for k in range(len(self.feasible_PW[0])): # column of feasible_RB Matrix | |
sum += (self.feasible_RB[n,k] * self.feasible_PW[n,k] + PP_c + Pb_h) | |
return PHI_eff * sum | |
def init_HPN_RB_PW_H_PL(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def sum_data_rate_HPN(self): | |
pass # we don't need this func, because ... . (check description of formula 7 in article) | |
def problem_1 (self): | |
gamma , gamma_star = (0,0) | |
epsilon = 0 | |
I_max = 1000 | |
for i in range(I_max): | |
self.init_RRH_RB_PW_H_PL() | |
C = self.sum_data_rate_RRH() | |
P = self.total_pw_HCRAN() | |
if C - gamma*P < epsilon : | |
feasible_RB_star = self.feasible_RB.copy() | |
feasible_PW_star = self.feasible_PW.copy() | |
gamma_star = gamma | |
break | |
else: | |
gamma = C / P | |
return gamma_star | |
# print 'gamma_star is: ', gamma_star | |
# print 'feasible_RB_star:\n ' , feasible_RB_star | |
# print 'feasible_PW_star:\n ' , feasible_PW_star | |
def problem_2 (self): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment