예제 #1
0
    def autoScafMidSeam(self, strands):
        """docstring for autoScafMidSeam"""
        part = self.part()
        strandType = StrandType.Scaffold
        idx = part.activeBaseIndex()
        for i in range(1, len(strands)):
            row1, col1, sSidx1 = strands[i-1]  # previous strand
            row2, col2, sSidx2 = strands[i]  # current strand
            vh1 = part.virtualHelixAtCoord((row1, col1))
            vh2 = part.virtualHelixAtCoord((row2, col2))
            strand1 = vh1.scaffoldStrandSet()._strandList[sSidx1]
            strand2 = vh2.scaffoldStrandSet()._strandList[sSidx2]
            # determine if the pair of strands are neighbors
            neighbors = part.getVirtualHelixNeighbors(vh1)
            if vh2 in neighbors:
                p2 = neighbors.index(vh2)
                if vh2.number() % 2 == 1:
                    # resize and install external xovers
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo = util.nearest(idx, part.getPreXoversHigh(strandType, p2, maxIdx=idx-10))
                        newHi = util.nearest(idx, part.getPreXoversLow(strandType, p2, minIdx=idx+10))
                        if strand1.canResizeTo(newLo, newHi) and \
                           strand2.canResizeTo(newLo, newHi):
                            # do the resize
                            strand1.resize((newLo, newHi))
                            strand2.resize((newLo, newHi))
                            # install xovers
                            part.createXover(strand1, newHi, strand2, newHi)
                            part.createXover(strand2, newLo, strand1, newLo)
                    except ValueError:
                        pass  # nearest not found in the expanded list

                    # go back an install the internal xovers
                    if i > 2:
                        row0, col0, sSidx0 = strands[i-2]  # two strands back
                        vh0 = part.virtualHelixAtCoord((row0, col0))
                        strand0 = vh0.scaffoldStrandSet()._strandList[sSidx0]
                        if vh0 in neighbors:
                            p0 = neighbors.index(vh0)
                            l0, h0 = strand0.idxs()
                            l1, h1 = strand1.idxs()
                            oLow, oHigh = util.overlap(l0, h0, l1, h1)
                            try:
                                lList = filter(lambda x:x>oLow and x<oHigh, part.getPreXoversLow(strandType, p0))
                                lX = lList[len(lList)/2]
                                hList = filter(lambda x:x>oLow and x<oHigh, part.getPreXoversHigh(strandType, p0))
                                hX = hList[len(hList)/2]
                                # install high xover first
                                part.createXover(strand0, hX, strand1, hX)
                                # install low xover after getting new strands
                                # following the breaks caused by the high xover
                                strand3 = vh0.scaffoldStrandSet()._strandList[sSidx0]
                                strand4 = vh1.scaffoldStrandSet()._strandList[sSidx1]
                                part.createXover(strand4, lX, strand3, lX)
                            except IndexError:
                                pass  # filter was unhappy
예제 #2
0
    def autoScafRaster(self, strands):
        """docstring for autoScafRaster"""
        part = self.part()
        idx = part.activeBaseIndex()
        for i in range(1, len(strands)):
            row1, col1, sSidx1 = strands[i-1]  # previous strand
            row2, col2, sSidx2 = strands[i]  # current strand
            vh1 = part.virtualHelixAtCoord((row1, col1))
            vh2 = part.virtualHelixAtCoord((row2, col2))
            strand1 = vh1.scaffoldStrandSet()._strandList[sSidx1]
            strand2 = vh2.scaffoldStrandSet()._strandList[sSidx2]
            # determine if the pair of strands are neighbors
            neighbors = part.getVirtualHelixNeighbors(vh1)
            if vh2 in neighbors:
                p2 = neighbors.index(vh2)
                if vh2.number() % 2 == 1:
                    # resize and install external xovers
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo1 = newLo2 = util.nearest(idx, part.getPreXoversHigh(StrandType.Scaffold, p2, maxIdx=idx-8))
                        newHi = util.nearest(idx, part.getPreXoversLow(StrandType.Scaffold, p2, minIdx=idx+8))

                        if vh1.number() != 0:  # after the first helix
                            newLo1 = strand1.lowIdx()  # leave alone the lowIdx

                        if vh2.number() != len(strands)-1:  # before the last
                            newLo2 = strand2.lowIdx()  # leave alone the lowIdx

                        if strand1.canResizeTo(newLo1, newHi) and \
                           strand2.canResizeTo(newLo2, newHi):
                            strand1.resize((newLo1, newHi))
                            strand2.resize((newLo2, newHi))
                        else:
                            raise ValueError
                        # install xovers
                        part.createXover(strand1, newHi, strand2, newHi)
                    except ValueError:
                        pass  # nearest not found in the expanded list
                else:
                    # resize and install external xovers
                    idx = part.activeBaseIndex()
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo = util.nearest(idx, part.getPreXoversHigh(StrandType.Scaffold, p2, maxIdx=idx-8))

                        if strand1.canResizeTo(newLo, strand1.highIdx()) and \
                           strand2.canResizeTo(newLo, strand2.highIdx()):
                            strand1.resize((newLo, strand1.highIdx()))
                            strand2.resize((newLo, strand2.highIdx()))
                            # install xovers
                            part.createXover(strand1, newLo, strand2, newLo)
                        else:
                            raise ValueError
                    except ValueError:
                        pass  # nearest not found in the expanded list
예제 #3
0
    def __init__(self, id, type, pos, radius, grid, bw = 1.4):
        self._id = id
        self.type = type
        #BS or RRH
        if type == self.BS_ID:
            self.power = self.POWER_BS
            self._radius = self.BS_RADIUS
        else:
            self.power = self.POWER_RRH
            self._radius = self.RRH_RADIUS
        self.antenna_in_range = []
        self.user_in_range = []
        self.resources = []
        # position tupe
        self._pos = pos
        # antenna coverage radius
        self._radius = radius
        # Grid object
        self._grid = grid
        # Channel bw (none in the start)
        self._cur_ch_bw =bw
        self._cur_rb_cap = Antenna.BW_RB_MAP[bw]
        # Channel BW required
        self._ch_bw_required = None
        # List of connected UEs
        self._ues = []
        self._rb_map = {}

        # Register to the closest BBU
        self._bbu = util.nearest(self, grid.bbus)
        self._bbu.register(self)
예제 #4
0
def predict(element, tree):
    if type(tree) is Leaf:
        return tree.answer

    if is_continuous(element[tree.attr]):
        return predict(element, tree.sons[nearest(element[tree.attr],
                                                  list(tree.sons.keys()),
                                                  precision=PRECISION)])

    return predict(element, tree.sons[element[tree.attr]])
예제 #5
0
    def __init__(self, id, type, pos, radius, grid, bw = 1.4):
        self._id = id
        self.type = type
        #BS or RRH
        if type == Antenna.BS_ID:
            self.power = threeGPP.POWER_BS
            self._radius = threeGPP.BS_RADIUS
        else:
            self.power = threeGPP.POWER_RRH
            self._radius = threeGPP.RRH_RADIUS
        self.antenna_in_range = []
        self.user_in_range = []
        # List of connected UEs
        self.connected_ues = []

        self.prev_n_ues = 0

        self.resources = []
        # position tupe
        self._pos = pos
        # antenna coverage radius
        self._radius = radius
        # Grid object
        self._grid = grid
        # Channel bw (none in the start)
        self._cur_ch_bw =bw
        self._cur_rb_cap = Antenna.BW_RB_MAP[bw]
        # Channel BW required
        self._ch_bw_required = None

        self._rb_map = {}

        # Register to the closest BBU
        self._bbu = util.nearest(self, grid.bbus)
        self._bbu.register(self)

        self.i                         = None
        self.a                         = None
        self.p                         = None
        self.energy_efficient          = None 
        self.consumition               = None 
        self.datarate                  = None
        self.user_datarate             = None
        self.fairness                  = None
        self.meet_users                = None
        self.datarate_constraint       = None
        self.backup_i                  = None
        self.backup_a                  = None
        self.backup_p                  = None
        self.backup_energy_efficient   = None 
        self.backup_consumition        = None 
        self.backup_datarate           = None
        self.backup_user_datarate      = None
        self.backup_fairness           = None
        self.backup_meet_users         = None
        self.history_i                 = None
        self.history_a                 = None
        self.history_p                 = None
        self.history_energy_efficient  = None
        self.history_consumition       = None
        self.history_datarate          = None
        self.history_user_datarate     = None
        self.history_fairness          = None
        self.history_meet_users        = None