def removeVarWithLowPotency(scenario, allCEVarList):
    hataSRD = MathUtil.HataSRDModel()

    maxDistanceCEAndClients = []

    for ce in scenario.cm.ceList:
        clientDistanceList = []

        for ceClient in ce.clientList:
            distanceBetween = MathUtil.calculateDistanceBetweenGeoPoints(
                ce.geoPoint, ceClient.geoPoint)
            clientDistanceList.append(distanceBetween)

        maxClientDistance = max(clientDistanceList)
        maxDistanceCEAndClients.append(maxClientDistance)

    newCEVarList = []

    for ceVar in allCEVarList:
        ceVarNameSplit = ceVar.name.split('_')

        ceId = int(ceVarNameSplit[1])
        cePotency = int(ceVarNameSplit[3])

        ceAntenna = scenario.cm.ceList[ceId].antenna
        channelFrequency = next(c.frequency for c in scenario.channels
                                if (c.channelNumber == ce.channel))

        ceSignalDistance = hataSRD.getDistance(ceAntenna, channelFrequency,
                                               cePotency, -60)

        if (ceSignalDistance >= maxDistanceCEAndClients[ceId]):
            newCEVarList.append(ceVar)

    return newCEVarList
def getInterferenceList(scenario, allCEVarList):
    hataSRD = MathUtil.HataSRDModel()
    interferenceList = []

    for ceVar in allCEVarList:
        ceVarNameSplit = ceVar.name.split('_')

        ceId = int(ceVarNameSplit[1])
        ceChannel = int(ceVarNameSplit[2])
        cePotency = int(ceVarNameSplit[3])

        ce = scenario.cm.ceList[ceId]
        channel = next(c for c in scenario.channels
                       if c.channelNumber == ceChannel)
        ceSignalDistance = hataSRD.getDistance(ce.antenna, channel.frequency,
                                               cePotency, -60)

        ceTotalInterference = 0.0
        ceInterferenceList = []

        for otherCEVar in allCEVarList:
            otherCEVarNameSplit = otherCEVar.name.split('_')

            otherCEId = int(otherCEVarNameSplit[1])
            otherCEChannel = int(otherCEVarNameSplit[2])

            if (otherCEId != ceId):
                otherCE = scenario.cm.ceList[otherCEId]
                distanceBetweenCEs = MathUtil.calculateDistanceBetweenGeoPoints(
                    ce.geoPoint, otherCE.geoPoint)
                signalLevel = MathUtil.dbm2Double(
                    hataSRD.getSignalLevel(ce.antenna, channel.frequency,
                                           cePotency, distanceBetweenCEs))

                if (ceSignalDistance >= distanceBetweenCEs):
                    if (otherCEChannel == ceChannel):
                        signalLevel = 1.0 * signalLevel
                        ceTotalInterference += signalLevel
                        ceInterferenceList.append(signalLevel)
                    elif (otherCEChannel
                          == (ceChannel - 1)) or (otherCEChannel
                                                  == (ceChannel + 1)):
                        signalLevel = 0.7 * signalLevel
                        ceTotalInterference += signalLevel
                        ceInterferenceList.append(signalLevel)
                    elif (otherCEChannel
                          == (ceChannel - 2)) or (otherCEChannel
                                                  == (ceChannel + 2)):
                        signalLevel = 0.3 * signalLevel
                        ceTotalInterference += signalLevel
                        ceInterferenceList.append(signalLevel)

        interferenceList.append(
            (ceVar, ceTotalInterference, ceInterferenceList))

    return interferenceList