コード例 #1
0
    ##
    ##            # this picks the next nodenow
    ##            # grab all the nodes the are within the localarea and pick one randomly (that hasn't already been
    ##            #    chosen). If all within the localarea have been chosen, take the next closest node outside it.
    ##            localnodes = set([i for i,j in alldists[nodenow] if j <= localareas])
    ##            localnodes = localnodes - set(usedupnodes)
    ##            if localnodes:
    ##                nodenow = rnd.choice(list(localnodes))
    ##            else:
    ##                for nn,nd in alldists[nodenow]:
    ##                    # list is sorted, just grab the 1st node past localarea that hasn't been picked before
    ##                    if nd > localareas and nn not in usedupnodes:
    ##                        nodenow = nn
    ##                        break
    ##
    ##            dbgcount += 1






if __name__=="__main__":
    import networkGenerator as ngen
    testnet = ngen.networkGenerator(qpick("dinet_run_1332283427_orig.pickle")[0])
    seng = simulationEngine()
    seng.generate_distributions(testnet.dinet, 6)
    pass


コード例 #2
0
ファイル: parsers.py プロジェクト: GanymedeH/Python_projects
    # arc keys: capacity, linetype (main/supply/switch/feed/delivery), temp (T/F), weight (1/0)
    #           linetype: main -> hub to hub; supply -> supply to any; switch -> relay connects;
    #                     feed -> else to terminus; delivery -> hub to terminus;
    arcids = []
    arccap = []
    arclts = []
    arctmp = []
    arcwts = []
    for k, v in arcdata.iteritems():
        arcids.append((int(v[0]), int(v[1])))
        arccap.append(int(v[4]))
        # linetype needs to know which nodes its connecting, which isn't done until arcs are placed
        arctmp.append(False)
        arcwts.append(0)

    netobj = ngen.networkGenerator()
    netobj.construct_network(nodeids, nodecxn, nodedem, nodedst, nodepos, nodetyp, arcids, arccap, arclts, arctmp,\
                             arcwts, giveStructure=True)

    # the temp network is the exact original network, just set the temp and weight values accordingly
    # the copy operation is expensive, but it only happens once and i'm lazy
    netobj.tnet = netobj.dinet.copy()
    for i, j, d in netobj.tnet.edges_iter(data=True):
        d["temp"] = True
##        d["weight"] = 1

    netobj.save_network(filename="NewC_network_data.pickle")

    print "done."
コード例 #3
0
ファイル: parsers.py プロジェクト: GanymedeH/Python_projects
    #           linetype: main -> hub to hub; supply -> supply to any; switch -> relay connects;
    #                     feed -> else to terminus; delivery -> hub to terminus;
    arcids = []
    arccap = []
    arclts = []
    arctmp = []
    arcwts = []
    for k,v in arcdata.iteritems():
        arcids.append( (int(v[0]),int(v[1])) )
        arccap.append(int(v[4]))
        # linetype needs to know which nodes its connecting, which isn't done until arcs are placed
        arctmp.append(False)
        arcwts.append(0)


    netobj = ngen.networkGenerator()
    netobj.construct_network(nodeids, nodecxn, nodedem, nodedst, nodepos, nodetyp, arcids, arccap, arclts, arctmp,\
                             arcwts, giveStructure=True)

    # the temp network is the exact original network, just set the temp and weight values accordingly
    # the copy operation is expensive, but it only happens once and i'm lazy
    netobj.tnet = netobj.dinet.copy()
    for i,j,d in netobj.tnet.edges_iter(data=True):
        d["temp"] = True
##        d["weight"] = 1

    netobj.save_network(filename="NewC_network_data.pickle")

    print "done."