Ejemplo n.º 1
0
AllMapFile = 'C:/Users/Bikiran/Google Drive/Bus Mapping Project Original/Donut Hole Approach/Donut Hole v2/' + 'AllMappedLog.txt'
ManualMappingDict = {
}  # dict constructed from the entries given in the manual map file
autoMapDict = {}  # dictionary which generates mapping
autoMappedSet = set()
changeDictNewToOld = {}
changeDictOldToNew = {}
mismatchBusSet345 = set()
noMismatch345Set = set(
)  # set of 345 buses (not including fict midpoints) which show no mismatch
ComedCAPESet345 = set()
MapDict = {
}  # dict containing all CAPE bus maps (the bus numbers all include the latest numbers, ie, include 75xxxxx and 27xxxxx)
#matchLines = [] # set of 345 bus data which show no mismatch (with the exception of tf midpoints)

BranchDictCAPE, BranchDataDictCAPE = generateNeighbours(CAPERaw)
BranchDictPlanning, BranchDataDictPlanning = generateNeighbours(planningRaw)

# get a set of 345 buses showing no mismatch
with open(changeLog, 'r') as f:
    filecontent = f.read()
    fileLines = filecontent.split('\n')
    for line in fileLines:
        if 'CAPE' in line:
            continue
        words = line.split('->')
        if len(words) < 2:
            continue
        OldBus = words[0].strip()
        NewBus = words[1].strip()
        changeDictNewToOld[NewBus] = OldBus
Ejemplo n.º 2
0
mismatchBusSet345 = set()
noMismatch345Set = set(
)  # set of 345 buses (not including fict midpoints) which show no mismatch
ComedCAPESet345 = set()
MapDict = {
}  # dict containing all CAPE bus maps (the bus numbers all include the latest numbers, ie, include 75xxxxx and 27xxxxx)
maxDepth = 3  # max depth in CAPE for impedance branch comparison
planningUnmappedList = []
explored = set()
planningExplored = set()
#################################

# get all the ties to buses which have no mismatch
BranchGroupDict = makeBranchGroups(CAPERaw)  # every value here is a set
#_, BranchDataDictCAPE = generateNeighbours(CAPERaw)
_, BranchDataDictPlanning = generateNeighbours(planningRaw)
BusDataDict = getBusData(CAPERaw)
BranchGroupDictPlanning = makeBranchGroups(planningRaw)


def printUsefulMappingOutput(originBus, CAPEneighbour, planningBus,
                             planningNeighbour, searchDepth):
    # output mapping info which helps in checking its validity, originBus: CAPE origin bus, CAPEneighbour: CAPE to bus, planningBus: planning from Bus, planningNeighbour: planning to bus
    # searchDepth: depth from CAPE to and from bus
    print CAPEneighbour + '->' + str(
        autoMapDict[CAPEneighbour]
    ) + '\t' + planningBus + ',' + planningNeighbour + ',' + originBus + ',' + CAPEneighbour + ',' + str(
        searchDepth)


def scanNeighbourDepth(MultDepthBranchDataDict, CAPEBus, currentDepth,
Ejemplo n.º 3
0
def getNeighboursDepthN(OriginBus, Raw, maxDepth):
    MultDepthBranchDataDict = {}  # the output dict of this fn
    explored = set()  # used for the BFS algorithm

    class multDepthBranchData(object):
        # to store all the branch data
        def __init__(self):
            self.toBus = []
            self.R = []
            self.X = []
            self.Z = []
            self.depth = []  # topology depth
            self.Path = []  # Path from Origin to current neighbour

    _, DepthOneBranchDataDict = generateNeighbours(
        Raw)  # DepthOneBranchDataDict contains all the required info

    MultDepthBranchDataDict[OriginBus] = multDepthBranchData()

    # BFS algorithm to extract and organize all the data
    frontier = Queue(maxsize=0)
    frontier.put(OriginBus)

    while not frontier.empty():
        currentBus = frontier.get()
        frontier.task_done()
        NeighbourList = DepthOneBranchDataDict[currentBus].toBus
        if currentBus not in explored:
            explored.add(currentBus)

        #### initialization
        if currentBus == OriginBus:
            # get the details from the Depth One Branch Dictionary
            MultDepthBranchDataDict[OriginBus].toBus = DepthOneBranchDataDict[
                OriginBus].toBus
            MultDepthBranchDataDict[OriginBus].R = DepthOneBranchDataDict[
                OriginBus].R
            MultDepthBranchDataDict[OriginBus].X = DepthOneBranchDataDict[
                OriginBus].X
            #MultDepthBranchDataDict[OriginBus].cktID = DepthOneBranchDataDict[OriginBus].cktID
            MultDepthBranchDataDict[OriginBus].Z = DepthOneBranchDataDict[
                OriginBus].Z

            # make lists of size equal to no. of branch neighbours of the origin bus
            for n in range(len(NeighbourList)):
                MultDepthBranchDataDict[OriginBus].depth.append(1)
                MultDepthBranchDataDict[OriginBus].Path.append('')

            # generate path strings of depth 1 neighbours
            for neighbour in NeighbourList:
                PathStr = currentBus + '->' + neighbour
                ind = MultDepthBranchDataDict[OriginBus].toBus.index(neighbour)
                MultDepthBranchDataDict[OriginBus].Path[ind] = PathStr
                frontier.put(neighbour)

            continue

###############

# scan all neighbours of current bus and extract all data if the neighbour is within maxDepth
        for neighbour in NeighbourList:
            if neighbour not in explored:
                ParentInd = MultDepthBranchDataDict[OriginBus].toBus.index(
                    currentBus)
                # generate neighbour depth
                ParentDepth = MultDepthBranchDataDict[OriginBus].depth[
                    ParentInd]
                neighbourDepth = ParentDepth + 1
                # generate neighbour path from origin
                ParentPathStr = MultDepthBranchDataDict[OriginBus].Path[
                    ParentInd]
                neighbourPathStr = ParentPathStr + '->' + neighbour

                neighbourInd = DepthOneBranchDataDict[currentBus].toBus.index(
                    neighbour)
                # get total R from origin to current neighbour
                neighbourR = DepthOneBranchDataDict[currentBus].R[neighbourInd]
                ParentR = MultDepthBranchDataDict[OriginBus].R[ParentInd]
                totalR = neighbourR + ParentR

                # get total X from origin to current neighbour
                neighbourX = DepthOneBranchDataDict[currentBus].X[neighbourInd]
                ParentX = MultDepthBranchDataDict[OriginBus].X[ParentInd]
                totalX = neighbourX + ParentX

                # get total Z from origin to current neighbour
                neighbourZ = DepthOneBranchDataDict[currentBus].Z[neighbourInd]
                ParentZ = MultDepthBranchDataDict[OriginBus].Z[ParentInd]
                totalZ = neighbourZ + ParentZ

                # get cktID
                #neighbourcktID = DepthOneBranchDataDict[currentBus].cktID[neighbourInd]

                if neighbourDepth <= maxDepth and neighbourPathStr not in MultDepthBranchDataDict[
                        OriginBus].Path:  # dont add if path has already been included
                    # append all data
                    MultDepthBranchDataDict[OriginBus].toBus.append(neighbour)
                    MultDepthBranchDataDict[OriginBus].depth.append(
                        neighbourDepth)
                    MultDepthBranchDataDict[OriginBus].Path.append(
                        neighbourPathStr)
                    #MultDepthBranchDataDict[OriginBus].cktID.append(neighbourcktID)
                    MultDepthBranchDataDict[OriginBus].R.append(totalR)
                    MultDepthBranchDataDict[OriginBus].X.append(totalX)
                    MultDepthBranchDataDict[OriginBus].Z.append(totalZ)
                    frontier.put(neighbour)

    return MultDepthBranchDataDict