Exemplo n.º 1
0
 def uniformMobilePosition(self, tiers):
     """Find mobile position via uniform distribution obeying hexagon borders and minimum distance."""
     outerRadius = self.interHexDistance / math.sqrt(
         3)  # TODO: ISD should not be here
     innerRadius = hexfuns.outer2InnerRadius(outerRadius)
     while True:
         xmin = -innerRadius * (2 * tiers + 1)
         ymin = -outerRadius * (1.5 * tiers + 1)
         xmax = innerRadius * (2 * tiers + 1)
         ymax = outerRadius * (1.5 * tiers + 1)
         position = [
             xmin + (xmax - xmin) * random.random(),
             ymin + (ymax - ymin) * random.random()
         ]
         # If the mobile is too close to a BS, we reroll. If it isn't and is contained in a hex, we break (success).
         if ([
                 bs for bs in self.baseStations if hexfuns.distance(
                     position, bs.position) < self.forbiddenDistance
         ]):
             continue  # mobile too close to a BS
         if ([
                 hexa for hexa in self.hexagons
                 if hexfuns.pointInHex(position, hexa)
         ]):  # implicit booleanness
             break  # at least one hexagon contains the point
     return position
Exemplo n.º 2
0
 def consideredMobiles(self):
     """For interference consideration, we only care about some mobiles in the center."""
     if self._consideredMobiles is None:
         self._consideredMobiles = [
             mob for mob in self.mobiles
             for hexa in self._consideredHexagons
             if hexfuns.pointInHex(mob.position, hexa)
         ]
     return self._consideredMobiles
Exemplo n.º 3
0
 def consideredCells(self):
     """Cells that are considered for data collection"""
     if self._consideredCells is None:
         self._consideredCells = [
             cell for cell in self.cells
             for hexa in self._consideredHexagons
             if hexfuns.pointInHex(cell.center, hexa)
         ]
     return self._consideredCells
Exemplo n.º 4
0
    def placeBaseStations(self):
        """Place the base stations on the map. 
        If the number of sectors is 1, the BS sits in the middle of a hexagon.
        If it is three, then it is located on the edge."""

        listOfBaseStations = []
        
        if self.sectorsPerBS == 1:
            # Only useful for debugging. Produces incorrect SINR profiles.
            for hexa in self.hexagons:
                bs = basestation.BaseStation(hexa.center, p0=self.wconf.p0, m=self.wconf.m, pS=self.wconf.pS)
                listOfBaseStations.append(bs)
                bs.cells.append(cell.Cell(hexa.center, self.PHY, direction=None, sleep_alignment=self.wconf.sleep_alignment))

        elif self.sectorsPerBS == 3:
            """1. Build several large NS hexagons (one per tier), possibly with multiple vertices
            on the edges. 2. Remove those BS that are further out than some large EWHexagon."""
            centerHex = next((hexa for hexa in self.hexagons if abs(linalg.norm(hexa.center-array([0,0]))<1)), 'None') # working around a rounding error
            centralBS = basestation.BaseStation(centerHex.center+[0,centerHex.outerRadius], p0=self.wconf.p0, m=self.wconf.m, pS=self.wconf.pS)
            listOfBaseStations.append(centralBS)
            for tier in range(1,self.tiers+1):
                # build NS hex with outer radius = 3*R*tier
                tempHex = hexagon.NSHexagon(centralBS.position, 3*centerHex.outerRadius*tier)
                for coords in tempHex.vertices():
                    listOfBaseStations.append(basestation.BaseStation(coords, p0=self.wconf.p0, m=self.wconf.m, pS=self.wconf.pS))
                pointList = tempHex.border()
                for currentPoint in pointList[0:-1]: #ignore the last one
                    ## get pieces of the lines connecting two border points
                    ## add those points to the listOfBaseStations
                    for subpointIter in range(1,tier):
                        index = pointList.index(currentPoint)
                        x,y,d,theta = lineDivider(currentPoint,
                                pointList[index+1],tier,subpointIter)
                        listOfBaseStations.append(basestation.BaseStation([x,y], p0=self.wconf.p0, m=self.wconf.m, pS=self.wconf.pS))

            # remove BS that are too far out overall
            inclusionDistance =  (( self.tiers * 2 + 2) * centerHex.innerRadius)
            origin = [0,0]
            for baseStation in listOfBaseStations[:]:
                if not(hexfuns.pointInHex(baseStation.position, hexagon.EWHexagon(origin, inclusionDistance))):
                    listOfBaseStations.remove(baseStation)

            for baseStation in listOfBaseStations:
                for hexa in self.hexagons:
                    if hexfuns.distance(hexa.center, baseStation.position)<hexa.outerRadius+1:
                        baseStation.cells.append(cell.Cell(hexa.center, self.PHY, 
                            initial_power=self.wconf.initial_power, 
                            sleep_alignment=self.wconf.sleep_alignment)) # This is the place where cells are filled TODO: fill direction

        
        return listOfBaseStations
Exemplo n.º 5
0
 def uniformMobilePosition(self, tiers):
     """Find mobile position via uniform distribution obeying hexagon borders and minimum distance."""
     outerRadius = self.interHexDistance / math.sqrt(3) # TODO: ISD should not be here
     innerRadius = hexfuns.outer2InnerRadius(outerRadius)
     while True: 
         xmin = -innerRadius*(2*tiers + 1)
         ymin = -outerRadius*(1.5*tiers + 1)
         xmax = innerRadius*(2*tiers + 1)
         ymax = outerRadius*(1.5*tiers + 1)
         position = [ xmin + (xmax-xmin)*random.random(), ymin + (ymax-ymin)*random.random() ]
         # If the mobile is too close to a BS, we reroll. If it isn't and is contained in a hex, we break (success).
         if ([ bs for bs in self.baseStations if hexfuns.distance(position, bs.position)<self.forbiddenDistance]):
             continue # mobile too close to a BS
         if ([ hexa for hexa in self.hexagons if hexfuns.pointInHex(position, hexa) ]): # implicit booleanness
             break # at least one hexagon contains the point
     return position
Exemplo n.º 6
0
 def consideredMobiles(self):
     """For interference consideration, we only care about some mobiles in the center."""
     if self._consideredMobiles is None:
         self._consideredMobiles = [ mob for mob in self.mobiles for hexa in self._consideredHexagons if hexfuns.pointInHex(mob.position, hexa) ]
     return self._consideredMobiles
Exemplo n.º 7
0
 def consideredCells(self):
     """Cells that are considered for data collection"""
     if self._consideredCells is None:
         self._consideredCells = [ cell for cell in self.cells for hexa in self._consideredHexagons if hexfuns.pointInHex(cell.center, hexa) ]
     return self._consideredCells
Exemplo n.º 8
0
    def placeBaseStations(self):
        """Place the base stations on the map. 
        If the number of sectors is 1, the BS sits in the middle of a hexagon.
        If it is three, then it is located on the edge."""

        listOfBaseStations = []

        if self.sectorsPerBS == 1:
            # Only useful for debugging. Produces incorrect SINR profiles.
            for hexa in self.hexagons:
                bs = basestation.BaseStation(hexa.center,
                                             p0=self.wconf.p0,
                                             m=self.wconf.m,
                                             pS=self.wconf.pS)
                listOfBaseStations.append(bs)
                bs.cells.append(
                    cell.Cell(hexa.center,
                              self.PHY,
                              direction=None,
                              sleep_alignment=self.wconf.sleep_alignment))

        elif self.sectorsPerBS == 3:
            """1. Build several large NS hexagons (one per tier), possibly with multiple vertices
            on the edges. 2. Remove those BS that are further out than some large EWHexagon."""
            centerHex = next(
                (hexa for hexa in self.hexagons
                 if abs(linalg.norm(hexa.center - array([0, 0])) < 1)),
                'None')  # working around a rounding error
            centralBS = basestation.BaseStation(centerHex.center +
                                                [0, centerHex.outerRadius],
                                                p0=self.wconf.p0,
                                                m=self.wconf.m,
                                                pS=self.wconf.pS)
            listOfBaseStations.append(centralBS)
            for tier in range(1, self.tiers + 1):
                # build NS hex with outer radius = 3*R*tier
                tempHex = hexagon.NSHexagon(centralBS.position,
                                            3 * centerHex.outerRadius * tier)
                for coords in tempHex.vertices():
                    listOfBaseStations.append(
                        basestation.BaseStation(coords,
                                                p0=self.wconf.p0,
                                                m=self.wconf.m,
                                                pS=self.wconf.pS))
                pointList = tempHex.border()
                for currentPoint in pointList[0:-1]:  #ignore the last one
                    ## get pieces of the lines connecting two border points
                    ## add those points to the listOfBaseStations
                    for subpointIter in range(1, tier):
                        index = pointList.index(currentPoint)
                        x, y, d, theta = lineDivider(currentPoint,
                                                     pointList[index + 1],
                                                     tier, subpointIter)
                        listOfBaseStations.append(
                            basestation.BaseStation([x, y],
                                                    p0=self.wconf.p0,
                                                    m=self.wconf.m,
                                                    pS=self.wconf.pS))

            # remove BS that are too far out overall
            inclusionDistance = ((self.tiers * 2 + 2) * centerHex.innerRadius)
            origin = [0, 0]
            for baseStation in listOfBaseStations[:]:
                if not (hexfuns.pointInHex(
                        baseStation.position,
                        hexagon.EWHexagon(origin, inclusionDistance))):
                    listOfBaseStations.remove(baseStation)

            for baseStation in listOfBaseStations:
                for hexa in self.hexagons:
                    if hexfuns.distance(
                            hexa.center,
                            baseStation.position) < hexa.outerRadius + 1:
                        baseStation.cells.append(
                            cell.Cell(
                                hexa.center,
                                self.PHY,
                                initial_power=self.wconf.initial_power,
                                sleep_alignment=self.wconf.sleep_alignment)
                        )  # This is the place where cells are filled TODO: fill direction

        return listOfBaseStations