Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
20 kB
3
Indexable
Never
# -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 18:35:18 2021

@author: TAIHM
"""

import matplotlib.pyplot as plt
import numpy as np
import math
from math import pi
import random as rd
from numpy import random
import cvxpy as cp

#System parameters
No_eMBB = 5
No_uRLLC = 10
No_mMTC = 20

GRID_WIDTH = 500 #meter
GRIG_LENGTH = 500 #meter

GRID_SIZE = 1 #metter

TIME_SLOT = 1 #second
SPEED = 10 #metter per second
BS_HEIGHT = 20 #m

# Communication parameters
f_c= 6e9  #carrier frequency 6GHz
c= 3e8  #speed of light
alpha_eMBB = 2.7 #pathloss exponent 
alpha_uRLLC = 2.7 #pathloss exponent 
alpha_mMTC = 3.7 #pathloss exponent 

B = 1e6 #Hz Robot bandwidth 
P_eMBB = 10 #watt constraint transmit power eMBB service
P_uRLLC = 1 #watt constraint transmit power uRLLC service
P_mMTC = 0.1 #watt constraint transmit power mMTC service

R_eMBB_min = 50 # MBps
R_uRLLC_min = 20 # MBps
R_mMTC_min = 2 # MBps

n_0 =  1e-14 #dBm noise


def normalize(value, minTar, maxTar,minVal=-1,maxVal =1 ):
 	return ((value- minVal)/(maxVal - minVal))*(maxTar - minTar) + minTar

def get_grid(coordinates):
    return [math.ceil(coordinates[0]/GRID_SIZE)-1, math.ceil(coordinates[1]/GRID_SIZE)-1]
def get_coordinates(grid):
    return [grid[0]*GRID_SIZE + GRID_SIZE/2,grid[1]*GRID_SIZE + GRID_SIZE/2]


    
class eMBB:
    def __init__(self, X, Y):
        self.grid = [X,Y]
        self.coordinates = get_coordinates(self.grid)
class uRLLC:
    def __init__(self, X, Y):
        self.grid = [X,Y]
        self.coordinates = get_coordinates(self.grid)
class mMTC:
    def __init__(self, X, Y):
        self.grid = [X,Y]
        self.coordinates = get_coordinates(self.grid)
    

class Network():
    def __init__(self):
        
        self.No_eMBB = No_eMBB
        self.No_uRLLC= No_uRLLC
        self.No_mMTC = No_mMTC
        self.BS = [250,250]
        self.No_RBs = 0
        self.fairness = 0.0
        
        self.X_eMBB = rd.sample(range(GRID_WIDTH), self.No_eMBB)
        self.Y_eMBB = rd.sample(range(GRIG_LENGTH), self.No_eMBB)

        self.X_uRLLC = rd.sample(range(GRID_WIDTH), self.No_uRLLC)
        self.Y_uRLLC = rd.sample(range(GRIG_LENGTH), self.No_uRLLC)
        
        self.X_mMTC = rd.sample(range(GRID_WIDTH), self.No_mMTC)
        self.Y_mMTC = rd.sample(range(GRIG_LENGTH), self.No_mMTC)
        # Init services set
      
        self.eMBBs = [eMBB(self.X_eMBB[i],self.Y_eMBB[i]) for i in range(self.No_eMBB)]
        self.uRLLCs = [uRLLC(self.X_uRLLC[i],self.Y_uRLLC[i]) for i in range(self.No_uRLLC)]
        self.mMTCs = [mMTC(self.X_mMTC[i],self.Y_mMTC[i]) for i in range(self.No_mMTC)]
        
        # Calculate eMBB to BS uplink throughput
        self.dis_eMBB = [np.sqrt(pow(self.eMBBs[i].grid[0] - self.BS[0],2) + pow(self.eMBBs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_eMBB)]
        self.g_eMBB = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_eMBB[i]**(-alpha_eMBB) for i in range(self.No_eMBB)]
        self.eMBB_SINR = [P_eMBB*self.g_eMBB[i]/n_0 for i in range(self.No_eMBB)]
        self.eMBB_RATE = [np.log2(1 + self.eMBB_SINR[i]) for i in range(self.No_eMBB)]
        
        # Calculate uRLLC to BS uplink throughput
        self.dis_uRLLC = [np.sqrt(pow(self.uRLLCs[i].grid[0] - self.BS[0],2) + pow(self.uRLLCs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_uRLLC)]
        self.g_uRLLC = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_uRLLC[i]**(-alpha_uRLLC) for i in range(self.No_uRLLC)]
        self.uRLLC_SINR = [P_uRLLC*self.g_uRLLC[i]/n_0 for i in range(self.No_uRLLC)]
        self.uRLLC_RATE = [np.log2(1 + self.uRLLC_SINR[i]) for i in range(self.No_uRLLC)]
        
        # Calculate mMTC to BS uplink throughput
        self.dis_mMTC = [np.sqrt(pow(self.mMTCs[i].grid[0] - self.BS[0],2) + pow(self.mMTCs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_mMTC)]
        self.g_mMTC = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_mMTC[i]**(-alpha_mMTC) for i in range(self.No_mMTC)]
        self.mMTC_SINR = [P_mMTC*self.g_mMTC[i]/n_0 for i in range(self.No_mMTC)]
        self.mMTC_RATE = [np.log2(1 + self.mMTC_SINR[i]) for i in range(self.No_mMTC)]
       
    def reset(self,eMBB_lambda,uRLLC_lambda,mMTC_lambda ):
        """
        Reset the initial value
        """
        self.No_eMBB = int(No_eMBB*np.random.normal(loc=eMBB_lambda, scale=0.01))
        if self.No_eMBB == 0:
            self.No_eMBB = 1
        self.No_uRLLC= int(No_uRLLC*np.random.normal(loc=uRLLC_lambda, scale=0.01))
        if self.No_uRLLC == 0:
            self.No_uRLLC = 1
        self.No_mMTC = int(No_mMTC*np.random.normal(loc=mMTC_lambda, scale=0.01))
        if self.No_mMTC == 0:
            self.No_mMTC = 1
        self.BS = [250,250]
        self.No_RBs = 0
        self.fairness = 0.0
        
        self.X_eMBB = rd.sample(range(GRID_WIDTH), self.No_eMBB)
        self.Y_eMBB = rd.sample(range(GRIG_LENGTH), self.No_eMBB)

        self.X_uRLLC = rd.sample(range(GRID_WIDTH), self.No_uRLLC)
        self.Y_uRLLC = rd.sample(range(GRIG_LENGTH), self.No_uRLLC)
        
        self.X_mMTC = rd.sample(range(GRID_WIDTH), self.No_mMTC)
        self.Y_mMTC = rd.sample(range(GRIG_LENGTH), self.No_mMTC)
        # Init services set
      
        self.eMBBs = [eMBB(self.X_eMBB[i],self.Y_eMBB[i]) for i in range(self.No_eMBB)]
        self.uRLLCs = [uRLLC(self.X_uRLLC[i],self.Y_uRLLC[i]) for i in range(self.No_uRLLC)]
        self.mMTCs = [mMTC(self.X_mMTC[i],self.Y_mMTC[i]) for i in range(self.No_mMTC)]
        
        # Calculate eMBB to BS uplink throughput
        self.dis_eMBB = [np.sqrt(pow(self.eMBBs[i].grid[0] - self.BS[0],2) + pow(self.eMBBs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_eMBB)]
        self.g_eMBB = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_eMBB[i]**(-alpha_eMBB) for i in range(self.No_eMBB)]
        self.eMBB_SINR = [P_eMBB*self.g_eMBB[i]/n_0 for i in range(self.No_eMBB)]
        self.eMBB_RATE = [np.log2(1 + self.eMBB_SINR[i]) for i in range(self.No_eMBB)]
        self.eMBB_Request = [int(R_eMBB_min/self.eMBB_RATE[i]) for i in range(self.No_eMBB)]
        
        # Calculate uRLLC to BS uplink throughput
        self.dis_uRLLC = [np.sqrt(pow(self.uRLLCs[i].grid[0] - self.BS[0],2) + pow(self.uRLLCs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_uRLLC)]
        self.g_uRLLC = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_uRLLC[i]**(-alpha_uRLLC) for i in range(self.No_uRLLC)]
        self.uRLLC_SINR = [P_uRLLC*self.g_uRLLC[i]/n_0 for i in range(self.No_uRLLC)]
        self.uRLLC_RATE = [np.log2(1 + self.uRLLC_SINR[i]) for i in range(self.No_uRLLC)]
        self.uRLLC_Request = [int(R_uRLLC_min/self.uRLLC_RATE[i]) for i in range(self.No_uRLLC)]
        
        # Calculate mMTC to BS uplink throughput
        self.dis_mMTC = [np.sqrt(pow(self.mMTCs[i].grid[0] - self.BS[0],2) + pow(self.mMTCs[i].grid[1] - self.BS[1],2) 
              + pow(BS_HEIGHT,2)) for i in range(self.No_mMTC)]
        self.g_mMTC = [random.rayleigh(scale=1.0, size=None)*pow(c/(4*pi*f_c),2)*self.dis_mMTC[i]**(-alpha_mMTC) for i in range(self.No_mMTC)]
        self.mMTC_SINR = [P_mMTC*self.g_mMTC[i]/n_0 for i in range(self.No_mMTC)]
        self.mMTC_RATE = [np.log2(1 + self.mMTC_SINR[i]) for i in range(self.No_mMTC)]
        self.mMTC_Request = [int(R_mMTC_min/self.mMTC_RATE[i]) for i in range(self.No_mMTC)]
        
       
        
        self.Sum_Request = sum(self.eMBB_Request ) + sum(self.uRLLC_Request) + sum(self.mMTC_Request)
        return self.Sum_Request
    
    def shapley(self):
        sum_rate = sum(self.eMBB_RATE) + sum(self.uRLLC_RATE) + sum(self.mMTC_RATE)
        sum_request = sum(self.eMBB_Request ) + sum(self.uRLLC_Request) + sum(self.mMTC_Request)
        c_eMBB = max((sum(self.eMBB_RATE)/sum_rate)*(self.No_RBs - sum_request),0)
        c_uRLLC = max((sum(self.uRLLC_RATE)/sum_rate)*(self.No_RBs - sum_request),0)
        c_mMTC = max((sum(self.mMTC_RATE)/sum_rate)*(self.No_RBs - sum_request),0)
        
        
        v_A = max(0, self.No_RBs - sum_request - c_uRLLC - c_mMTC)
        v_B = max(0, self.No_RBs - sum_request - c_eMBB - c_mMTC)
        v_C = max(0, self.No_RBs - sum_request - c_eMBB - c_uRLLC)
        v_AB = max(0, self.No_RBs - sum_request - c_mMTC)
        v_AC = max(0, self.No_RBs - sum_request - c_uRLLC)
        v_BC = max(0, self.No_RBs - sum_request - c_eMBB)
        v_ABC = max(0, self.No_RBs - sum_request)
        
        #pi_ABC = [v_A, v_AB - v_A, v_ABC - v_AB]
        #pi_ACB = [v_A, v_ABC - v_AC, v_AC - v_A]
        #pi_BAC = [v_AB - v_B, v_B, v_ABC - v_AB]
        #pi_BCA = [v_ABC - v_BC, v_B, v_BC - v_B]
        #pi_CAB = [v_AC - v_C, v_ABC - v_AC , v_C]
        #pi_CBA = [v_ABC - v_BC, v_BC - v_C, v_C]
        #shapley_eMBB = (pi_ABC[0] + pi_ACB[0] + pi_BAC[0] + pi_BCA[0] + pi_CAB[0] + pi_CBA[0])/6
        #shapley_uRLLC = (pi_ABC[1] + pi_ACB[1] + pi_BAC[1] + pi_BCA[1] + pi_CAB[1] + pi_CBA[1])/6
        #shapley_mMTC = (pi_ABC[2] + pi_ACB[2] + pi_BAC[2] + pi_BCA[2] + pi_CAB[2] + pi_CBA[2])/6
        
        self.shapley_eMBB = (v_A + v_A + v_AB - v_B + v_ABC - v_BC + v_AC - v_C + v_ABC - v_BC)/6
        self.shapley_uRLLC = (v_AB - v_A + v_ABC - v_AC + v_B + v_B + v_ABC - v_AC + v_BC - v_C)/6
        self.shapley_mMTC = (v_ABC - v_AB + v_AC - v_A + v_ABC - v_AB + v_BC - v_B + v_C + v_C)/6
        
        #lambda_eMBB =  np.where(c_eMBB != 0, self.shapley_eMBB/c_eMBB, 0)
        #lambda_uRLLC = np.where(c_uRLLC != 0, self.shapley_uRLLC/c_uRLLC, 0)
        #lambda_mMTC =  np.where(c_mMTC != 0, self.shapley_mMTC/c_mMTC, 0)
        # if c_eMBB != 0:
        #     lambda_eMBB = self.shapley_eMBB + sum(self.eMBB_Request )
        # else:
        #     lambda_eMBB = 0.0 #sum(self.eMBB_Request )
        # if c_uRLLC != 0:
        #     lambda_uRLLC = self.shapley_uRLLC + sum(self.uRLLC_Request)
        # else:
        #     lambda_uRLLC = 0.0 #sum(self.uRLLC_Request)
        # if c_mMTC != 0:
        #     lambda_mMTC = self.shapley_mMTC + sum(self.mMTC_Request)
        # else:
        #     lambda_mMTC = 0.0 #sum(self.mMTC_Request)
        lambda_eMBB = self.shapley_eMBB + sum(self.eMBB_Request )            
        lambda_uRLLC = self.shapley_uRLLC + sum(self.uRLLC_Request)            
        lambda_mMTC = self.shapley_mMTC + sum(self.mMTC_Request)
        #if ((lambda_mMTC!=0)&(lambda_uRLLC!=0)&(lambda_mMTC!=0)):
        self.fairness = float((lambda_eMBB+lambda_uRLLC+lambda_mMTC)**2/(3*(lambda_eMBB**2+lambda_uRLLC**2+lambda_mMTC**2)))
        self.throughput_eMBB = lambda_eMBB*sum(self.eMBB_RATE)
        self.thoughput_uRLLC = lambda_uRLLC*sum(self.uRLLC_RATE)
        self.thoughput_mMTC = lambda_mMTC*sum(self.mMTC_RATE)
        self.thoughput = lambda_eMBB*sum(self.eMBB_RATE) + lambda_uRLLC*sum(self.uRLLC_RATE) + lambda_mMTC*sum(self.mMTC_RATE)
        
        self.SLA_violation = 0
        for i in range(self.No_eMBB):
            if self.eMBB_RATE[i]*lambda_eMBB/self.No_eMBB < R_eMBB_min:
                self.SLA_violation += 1
        for i in range(self.No_uRLLC):
            if self.uRLLC_RATE[i]*lambda_uRLLC/self.No_uRLLC < R_uRLLC_min:
                self.SLA_violation += 1       
        for i in range(self.No_mMTC):
            if self.mMTC_RATE[i]*lambda_mMTC/self.No_mMTC < R_mMTC_min:
                self.SLA_violation += 1     
        self.SLA_violation  =  self.SLA_violation/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)       
        return np.array([self.shapley_eMBB, self.shapley_uRLLC, self.shapley_mMTC])
    
    def optimal(self):
        N = self.No_eMBB+self.No_mMTC+self.No_uRLLC
        x = cp.Variable(self.No_eMBB)
        y = cp.Variable(self.No_mMTC)
        z = cp.Variable(self.No_uRLLC)
        self.SLA_violation_Opt = 0
        self.optimal_rate = 0
        self.optimal_fairness = 0
        constraints = []
        for i in range(self.No_eMBB):
            constraints.append(x[i]*self.eMBB_RATE[i]>=R_eMBB_min)
            
        for i in range(self.No_mMTC):    
            constraints.append(y[i]*self.mMTC_RATE[i]>=R_mMTC_min)
            
        for i in range(self.No_uRLLC):    
            constraints.append(z[i]*self.uRLLC_RATE[i]>=R_uRLLC_min)

        constraints.append(cp.norm1(x) + cp.norm1(y) + cp.norm1(z) <= self.No_RBs)

        obj = 0
        
        for i in range(self.No_eMBB):
            obj += x[i]*self.eMBB_RATE[i]
        for i in range(self.No_mMTC):
            obj += y[i]*self.mMTC_RATE[i]
        for i in range(self.No_uRLLC):
            obj += z[i]*self.uRLLC_RATE[i]
       
        prob = cp.Problem(cp.Maximize(obj), constraints)

        prob.solve(solver = "MOSEK")
        if x[0].value != None:
            #print("optimal var", x.value, y.value, z.value)
            #print("status:", prob.status)
            #print("optimal value", prob.value)
            self.optimal_rate = sum(x.value)*sum(self.eMBB_RATE) + sum(z.value)*sum(self.uRLLC_RATE) + sum(y.value)*sum(self.mMTC_RATE)
            self.optimal_fairness = float((sum(x.value)+sum(y.value)+sum(z.value))**2/(3*(sum(x.value)**2+sum(y.value)**2+sum(z.value)**2)))

            #print("optimal value:", self.optimal_rate)
            #print("Sum X:", cp.sum(x.value).value)
            #print("norm1 X:", cp.norm1(x.value).value)
            
            
            self.SLA_violation_Opt = 0
            for i in range(self.No_eMBB):
                if self.eMBB_RATE[i]*x[i].value < R_eMBB_min:
                    self.SLA_violation_Opt += 1
            for i in range(self.No_uRLLC):
                if self.uRLLC_RATE[i]*z[i].value < R_uRLLC_min:
                    self.SLA_violation_Opt += 1       
            for i in range(self.No_mMTC):
                if self.mMTC_RATE[i]*y[i].value < R_mMTC_min:
                    self.SLA_violation_Opt += 1     
            self.SLA_violation_Opt  =  self.SLA_violation_Opt/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)   
        else:
            self.SLA_violation_Opt = 1
        
        return self.optimal_rate
    
    ###constrained equal award CEA rule
    def CEA(self,No_RBs):
        eMBB_active = True
        uRLLC_active = True
        mMTC_active = True
        cea_eMBB = 0
        cea_uRLLC = 0
        cea_mMTC = 0
        remain = No_RBs
        while (eMBB_active|uRLLC_active|mMTC_active):
            if eMBB_active:
                cea_eMBB = cea_eMBB + remain/3
            if uRLLC_active:
                cea_uRLLC = cea_uRLLC+ remain/3
            if mMTC_active:
                cea_mMTC = cea_mMTC + remain/3
            if cea_eMBB >= sum(self.eMBB_Request):
                cea_eMBB = sum(self.eMBB_Request)
                eMBB_active = False
            if cea_uRLLC >= sum(self.uRLLC_Request):
                cea_uRLLC = sum(self.uRLLC_Request)
                uRLLC_active = False
            if cea_mMTC >= sum(self.mMTC_Request):
                cea_mMTC = sum(self.mMTC_Request)
                mMTC_active = False
            remain = remain - (cea_eMBB + cea_uRLLC + cea_uRLLC)
            if remain <= 0:
                break
        
        self.SLA_violation_CEA = 0
        for i in range(self.No_eMBB):
            if self.eMBB_RATE[i]*cea_eMBB/self.No_eMBB < R_eMBB_min:
                self.SLA_violation_CEA += 1
        for i in range(self.No_uRLLC):
            if self.uRLLC_RATE[i]*cea_uRLLC/self.No_uRLLC < R_uRLLC_min:
                self.SLA_violation_CEA += 1       
        for i in range(self.No_mMTC):
            if self.mMTC_RATE[i]*cea_mMTC/self.No_mMTC < R_mMTC_min:
                self.SLA_violation_CEA += 1     
        self.SLA_violation_CEA  =  self.SLA_violation_CEA/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)   
        return cea_eMBB, cea_uRLLC, cea_mMTC
    ###constrained equal loss CEL rule:
    def CEL(self,No_RBs):
        eMBB_active = True
        uRLLC_active = True
        mMTC_active = True
        cea_eMBB = sum(self.eMBB_Request)
        cea_uRLLC = sum(self.uRLLC_Request)
        cea_mMTC = sum(self.mMTC_Request)
        remain = No_RBs
        while (eMBB_active|uRLLC_active|mMTC_active):
            if eMBB_active:
                cea_eMBB = cea_eMBB -1
            if uRLLC_active:
                cea_uRLLC = cea_uRLLC -1
            if mMTC_active:
                cea_mMTC = cea_mMTC -1
            if cea_eMBB <= 0:
                eMBB_active = False
            if cea_uRLLC <=0:
                uRLLC_active = False
            if cea_mMTC <=0:
                mMTC_active = False
            
            if cea_eMBB + cea_uRLLC + cea_uRLLC <= No_RBs:
                break
        self.SLA_violation_CEL = 0
        for i in range(self.No_eMBB):
            if self.eMBB_RATE[i]*cea_eMBB/self.No_eMBB < R_eMBB_min:
                self.SLA_violation_CEL += 1
        for i in range(self.No_uRLLC):
            if self.uRLLC_RATE[i]*cea_uRLLC/self.No_uRLLC < R_uRLLC_min:
                self.SLA_violation_CEL += 1       
        for i in range(self.No_mMTC):
            if self.mMTC_RATE[i]*cea_mMTC/self.No_mMTC < R_mMTC_min:
                self.SLA_violation_CEL += 1     
        self.SLA_violation_CEL  =  self.SLA_violation_CEL/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)   
        return cea_eMBB, cea_uRLLC, cea_mMTC
    #### Contested Garment Consistent CGC Rule:
    def CGC(self,No_RBs):
        cgc_eMBB = 0
        cgc_uRLLC = 0
        cgc_mMTC = 0
        if sum(self.eMBB_Request) + sum(self.uRLLC_Request) + sum(self.mMTC_Request)>=   2*No_RBs:
            cgc_eMBB, cgc_uRLLC, cgc_mMTC = self.CEA(No_RBs)
        else:
            cgc_eMBB, cgc_uRLLC, cgc_mMTC = self.CEL(No_RBs)
            
        self.SLA_violation_CGC = 0
        for i in range(self.No_eMBB):
            if self.eMBB_RATE[i]*cgc_eMBB/self.No_eMBB < R_eMBB_min:
                self.SLA_violation_CGC += 1
        for i in range(self.No_uRLLC):
            if self.uRLLC_RATE[i]*cgc_uRLLC/self.No_uRLLC < R_uRLLC_min:
                self.SLA_violation_CGC += 1       
        for i in range(self.No_mMTC):
            if self.mMTC_RATE[i]*cgc_mMTC/self.No_mMTC < R_mMTC_min:
                self.SLA_violation_CGC += 1     
        self.SLA_violation_CGC  =  self.SLA_violation_CGC/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)   
        return cgc_eMBB, cgc_uRLLC, cgc_mMTC
    def propor(self):
        self.Sum_Request = sum(self.eMBB_Request ) + sum(self.uRLLC_Request) + sum(self.mMTC_Request)
        eMBB_propor = sum(self.eMBB_Request)*self.No_RBs/self.Sum_Request
        uRLLC_propor = sum(self.uRLLC_Request)*self.No_RBs/self.Sum_Request
        mMTC_propor = sum(self.mMTC_Request)*self.No_RBs/self.Sum_Request
        fair_prop = float((eMBB_propor+uRLLC_propor+mMTC_propor)**2/(3*((eMBB_propor)**2+(uRLLC_propor)**2+(mMTC_propor)**2)))
        
        self.SLA_violation_propor = 0
        for i in range(self.No_eMBB):
            if self.eMBB_RATE[i]*eMBB_propor/self.No_eMBB < R_eMBB_min:
                self.SLA_violation_propor += 1
        for i in range(self.No_uRLLC):
            if self.uRLLC_RATE[i]*uRLLC_propor/self.No_uRLLC < R_uRLLC_min:
                self.SLA_violation_propor += 1       
        for i in range(self.No_mMTC):
            if self.mMTC_RATE[i]*mMTC_propor/self.No_mMTC < R_mMTC_min:
                self.SLA_violation_propor += 1     
        self.SLA_violation_propor  =  self.SLA_violation_propor/(self.No_eMBB+self.No_mMTC+self.No_uRLLC)   
        return fair_prop
network = Network()
print(network.reset(0.2, 0.2, 0.2) )
network.No_RBs = 100
print(network.propor())
print(network.shapley())