<commit_before>__author__ = '<NAME>, <NAME>'

import math
import csv
import numpy as np

class NetworkDevice:
    """Network device, needed for inheritance"""
    def __init__(self):
        self.x = 0
        self.y = 0

class UE(NetworkDevice):
    """UE"""
    def __init__(self):
        self.ID = 0
        self.connectedToBS = 0
        self.inside = True

    def distanceToBS(self, BS):
        return math.sqrt((self.x-BS.x)**2+(self.y-BS.y)**2)

    def isSeenFromBS(self, BS):
        if BS.omnidirectionalAntenna == True:
            return True
        #returns true if angle allow signal receive, else False
        a_y = BS.y-self.y
        distance_bs_ue = self.distanceToBS(BS)
        if distance_bs_ue == 0 or BS.turnedOn == False:
            return False
        ue_angle_rad = math.acos(a_y/distance_bs_ue)
        ue_angle = math.degrees(ue_angle_rad)
        if self.x <= BS.x:
            ue_angle = 360 - ue_angle
        if BS.angle > ue_angle:
            alpha_diff = BS.angle - ue_angle
        else:
            alpha_diff = ue_angle - BS.angle
        if alpha_diff <= 60 or alpha_diff >= 300:
            return True
        else:
            return False

    def connectToNearestBS(self, BS_vector):
        closestDistance = -1
        foundBS = -1
        for bs in BS_vector:
            if self.isSeenFromBS(bs):
                currentDistance = self.distanceToBS(bs)
                if currentDistance < closestDistance or foundBS == -1:
                    closestDistance = currentDistance
                    foundBS = bs.ID
        self.connectedToBS = foundBS

    def connectToTheBestBS(self, BS_vector, obstacleVector = None):
        theBestSINR = -1000
        foundBS = -1
        for bs in BS_vector:
            if self.isSeenFromBS(bs):
                self.connectedToBS = bs.ID
                currentSINR = self.calculateSINR(BS_vector, obstacleVector)
                if theBestSINR < currentSINR or foundBS == -1:
                    theBestSINR = currentSINR
                    foundBS = bs.ID
        self.connectedToBS = foundBS

    def calculateWallLoss(self, BS_vector, obstacleVector):
        wallLoss = 0
        for obstacle in obstacleVector:
            s10_x = self.x - BS_vector[self.connectedToBS].x
            s10_y = self.y - BS_vector[self.connectedToBS].y
            s32_x = obstacle[2] - obstacle[0]
            s32_y = obstacle[3] - obstacle[1]

            denom = s10_x * s32_y - s32_x * s10_y

            if denom == 0 :
                continue

            denom_is_positive = denom > 0

            s02_x = BS_vector[self.connectedToBS].x - obstacle[0]
            s02_y = BS_vector[self.connectedToBS].y - obstacle[1]

            s_numer = s10_x * s02_y - s10_y * s02_x

            if (s_numer < 0) == denom_is_positive:
                continue

            t_numer = s32_x * s02_y - s32_y * s02_x

            if (t_numer < 0) == denom_is_positive:
                continue

            if (s_numer > denom) == denom_is_positive or (t_numer > denom) == denom_is_positive :
                continue


            wallLoss = wallLoss + obstacle[4]
        return wallLoss

    def calculateReceivedPower(self, pSend, distance):
        R = distance
        lambda_val = 0.142758313333
        a = 4.0
        b = 0.0065
        c = 17.1
        d = 10.8
        s = 9.6

        ht = 40
        hr = 1.5
        f = 2.1
        gamma = a - b*ht + c/ht
        Xf = 6 * math.log10( f/2 )
        Xh = -d * math.log10( hr/2 )

        R0 = 100.0
        R0p = R0 * pow(10.0,-( (Xf+Xh) / (10*gamma) ))<commit_msg>Changed 's' parameter in the received power calculation.<commit_after>__author__ = '<NAME>, <NAME>'

import math
import csv
import numpy as np

class NetworkDevice:
    """Network device, needed for inheritance"""
    def __init__(self):
        self.x = 0
        self.y = 0

class UE(NetworkDevice):
    """UE"""
    def __init__(self):
        self.ID = 0
        self.connectedToBS = 0
        self.inside = True

    def distanceToBS(self, BS):
        return math.sqrt((self.x-BS.x)**2+(self.y-BS.y)**2)

    def isSeenFromBS(self, BS):
        if BS.omnidirectionalAntenna == True:
            return True
        #returns true if angle allow signal receive, else False
        a_y = BS.y-self.y
        distance_bs_ue = self.distanceToBS(BS)
        if distance_bs_ue == 0 or BS.turnedOn == False:
            return False
        ue_angle_rad = math.acos(a_y/distance_bs_ue)
        ue_angle = math.degrees(ue_angle_rad)
        if self.x <= BS.x:
            ue_angle = 360 - ue_angle
        if BS.angle > ue_angle:
            alpha_diff = BS.angle - ue_angle
        else:
            alpha_diff = ue_angle - BS.angle
        if alpha_diff <= 60 or alpha_diff >= 300:
            return True
        else:
            return False

    def connectToNearestBS(self, BS_vector):
        closestDistance = -1
        foundBS = -1
        for bs in BS_vector:
            if self.isSeenFromBS(bs):
                currentDistance = self.distanceToBS(bs)
                if currentDistance < closestDistance or foundBS == -1:
                    closestDistance = currentDistance
                    foundBS = bs.ID
        self.connectedToBS = foundBS

    def connectToTheBestBS(self, BS_vector, obstacleVector = None):
        theBestSINR = -1000
        foundBS = -1
        for bs in BS_vector:
            if self.isSeenFromBS(bs):
                self.connectedToBS = bs.ID
                currentSINR = self.calculateSINR(BS_vector, obstacleVector)
                if theBestSINR < currentSINR or foundBS == -1:
                    theBestSINR = currentSINR
                    foundBS = bs.ID
        self.connectedToBS = foundBS

    def calculateWallLoss(self, BS_vector, obstacleVector):
        wallLoss = 0
        for obstacle in obstacleVector:
            s10_x = self.x - BS_vector[self.connectedToBS].x
            s10_y = self.y - BS_vector[self.connectedToBS].y
            s32_x = obstacle[2] - obstacle[0]
            s32_y = obstacle[3] - obstacle[1]

            denom = s10_x * s32_y - s32_x * s10_y

            if denom == 0 :
                continue

            denom_is_positive = denom > 0

            s02_x = BS_vector[self.connectedToBS].x - obstacle[0]
            s02_y = BS_vector[self.connectedToBS].y - obstacle[1]

            s_numer = s10_x * s02_y - s10_y * s02_x

            if (s_numer < 0) == denom_is_positive:
                continue

            t_numer = s32_x * s02_y - s32_y * s02_x

            if (t_numer < 0) == denom_is_positive:
                continue

            if (s_numer > denom) == denom_is_positive or (t_numer > denom) == denom_is_positive :
                continue


            wallLoss = wallLoss + obstacle[4]
        return wallLoss

    def calculateReceivedPower(self, pSend, distance):
        R = distance
        lambda_val = 0.142758313333
        a = 4.0
        b = 0.0065
        c = 17.1
        d = 10.8
        s = 15,8

        ht = 40
        hr = 1.5
        f = 2.1
        gamma = a - b*ht + c/ht
        Xf = 6 * math.log10( f/2 )
        Xh = -d * math.log10( hr/2 )

        R0 = 100.0
        R0p = R0 * pow(10.0,-( (Xf+Xh) / (10*gamma) ))
{'fraction_non_alphanumeric': 0.09255172413793103, 'fraction_numerical': 0.03462068965517241, 'mean_word_length': 1.6026561378320172, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '612246', 'n_tokens_mistral': 2553, 'n_tokens_neox': 2299, 'n_words': 559}