示例#1
0
def test_paths(projectFolder, prefix, path_list):

    scenario = dta.DynameqScenario(Time(0, 0), Time(12, 0))
    scenario.read(projectFolder, prefix)
    net = dta.DynameqNetwork(scenario)
    net.read(projectFolder, prefix)

    TEST_PATHS = {
        "geary": [],
        "downtown": [{
            "name": "Mission St from 8th St to 1st St",
            "street": "3rd St",
            "from": "Folsom St",
            "to": "Mission St",
            "answer": [2150, 9001847, 9001848, 9001871, 9001872, 2214]
        }],
    }

    TEST_PATHS["sf"] = TEST_PATHS["geary"] + TEST_PATHS["downtown"]

    paths = TEST_PATHS[path_list]

    for p in paths:
        intersection_list = [[p["street"].upper(), p["from"].upper()],
                             [p["street"].upper(), p["to"].upper()]]

        testPath = Path.createPath(net, p["name"], intersection_list)
        testPathLinkList = [l.getId() for l in testPath.iterLinks()]
        print "CODE GOT :", testPathLinkList
        print "ANSWER IS:", p['answer']
        assert p['answer'] == testPathLinkList
示例#2
0
def getGearySubNet():

    projectFolder = os.path.join(mainFolder, 'dynameqNetwork_gearySubset')
    prefix = 'smallTestNet' 

    scenario = dta.DynameqScenario(dta.Time(0,0), dta.Time(12,0))
    scenario.read(projectFolder, prefix) 
    net = dta.DynameqNetwork(scenario) 
    net.read(projectFolder, prefix)

    simStartTimeInMin = 0
    simEndTimeInMin = 60
    simTimeStepInMin = 15
    
    net._simStartTimeInMin = simStartTimeInMin
    net._simEndTimeInMin = simEndTimeInMin
    net._simTimeStepInMin = simTimeStepInMin

    for link in net.iterLinks():
        if link.isVirtualLink():
            continue
        link.simTimeStepInMin = simTimeStepInMin
        link.simStartTimeInMin = simStartTimeInMin
        link.simEndTimeInMin = simEndTimeInMin
        for mov in link.iterOutgoingMovements():
            mov.simTimeStepInMin = simTimeStepInMin
            mov.simStartTimeInMin = simStartTimeInMin
            mov.simEndTimeInMin = simEndTimeInMin

    for link in net.iterLinks():
        if link.isVirtualLink():
            continue
        if link.isConnector():
            continue
        link._label  = str(link.getId())

        link.setObsCount(0, 60, random.randint(150, 450))
        
        for mov in link.iterOutgoingMovements():
            
            mov.setObsCount(0, 60, random.randint(50, 150))
            
            for start, end in izip(range(0, 60, 15), range(15, 61, 15)):
                mov.setSimOutVolume(start, end, random.randint(20, 50))
                mov.setSimInVolume(start, end, random.randint(20, 50))
                mov.cost = link.euclideanLength()
                randInt = random.randint(2,4) 
                tt = mov.getFreeFlowTTInMin() * float(randInt)
                mov.setSimTTInMin(start, end, tt)

    
    return net 
示例#3
0
    def readDTANetwork(self, inputDir, filePrefix, logging_dir='C:/temp'):
        """
        Reads the dynameq files to create a network representation. 
        """
        
        # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths
        dta.VehicleType.LENGTH_UNITS= "feet"
        dta.Node.COORDINATE_UNITS   = "feet"
        dta.RoadLink.LENGTH_UNITS   = "miles"

        dta.setupLogging(logging_dir + "/dta.INFO.log", logging_dir+"/dta.DEBUG.log", logToConsole=False)

        scenario = dta.DynameqScenario()
        scenario.read(inputDir, filePrefix) 
        net = dta.DynameqNetwork(scenario)

        net.read(inputDir, filePrefix)
        
        # initialize costs
        dta.Algorithms.ShortestPaths.initiaxblizeEdgeCostsWithFFTT(net)
        dta.Algorithms.ShortestPaths.initialiseMovementCostsWithFFTT(net)        
        
        self.net = net
示例#4
0
    COUNT_DIR                            = sys.argv[6]
    LINK_COUNT_FILE_15MIN                = sys.argv[7] 
    MOVEMENT_COUNT_FILE_15MIN            = sys.argv[8]
    MOVEMENT_COUNT_FILE_5MIN             = sys.argv[9]
    REPORTS_ROUTE_TRAVEL_TIME_FILE       = sys.argv[10]
    
    # The SanFrancisco network will use feet for vehicle lengths and coordinates, and miles for link lengths
    dta.VehicleType.LENGTH_UNITS= "feet"
    dta.Node.COORDINATE_UNITS   = "feet"
    dta.RoadLink.LENGTH_UNITS   = "miles"

    dta.setupLogging("visualizeDTAResults.INFO.log", "visualizeDTAResults.DEBUG.log", logToConsole=True)

    scenario = dta.DynameqScenario()
    scenario.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX) 
    net = dta.DynameqNetwork(scenario)

    net.read(INPUT_DYNAMEQ_NET_DIR, INPUT_DYNAMEQ_NET_PREFIX)

    #magic numbers here. This information may (or may not) be somewhere in the .dqt files 
    simStartTime = 14 * 60 + 30
    simEndTime = 21 * 60 + 30
    simTimeStep = 5
    net.readSimResults(simStartTime, simEndTime, 5)

    DtaLogger.info("Reading 15-minute link counts")
    net.readObsLinkCounts(COUNT_DIR + "/" + LINK_COUNT_FILE_15MIN)
    DtaLogger.info("Reading 15-minute movement counts")
    net.readObsMovementCounts(COUNT_DIR + "/" + MOVEMENT_COUNT_FILE_15MIN)
    DtaLogger.info("Reading 5-minute movement counts")
    net.readObsMovementCounts(COUNT_DIR + "/" + MOVEMENT_COUNT_FILE_5MIN)
            SF_CUBE_SHAPEFILE,
            "A",
            "B",
            skipEvalStr="(OBJECTID in [3,4,5234,2798]) or (MEDIANDIV==1)")

    # Some special links needing shifts
    addShifts(sanfranciscoCubeNet)

    #Some special links need special response times (in one case to mitigate over-penalizing capacity due to high percent of lane changes)
    addCustomResFac(sanfranciscoCubeNet)

    #Some links may have a toll. Change tollLink field from 0 to 1 if link is tolled
    addTollLink(sanfranciscoCubeNet)

    # Convert the network to a Dynameq DTA network
    sanfranciscoDynameqNet = dta.DynameqNetwork(scenario=sanfranciscoScenario)
    sanfranciscoDynameqNet.deepcopy(sanfranciscoCubeNet)

    # the San Francisco network has a few "HOV stubs" -- links intended to facilitate future coding of HOV lanes
    removeHOVStubs(sanfranciscoDynameqNet)

    # Battery between Bush and Market is a parking garage - forcibly split it
    try:
        battery_sbs = sanfranciscoDynameqNet.findLinksForRoadLabels(
            on_street_label="BATTERY ST",
            on_direction=dta.RoadLink.DIR_SB,
            from_street_label="BUSH ST",
            to_street_label="MARKET ST")
        if len(battery_sbs) == 1:
            sanfranciscoDynameqNet.splitLink(battery_sbs[0])
    except dta.DtaError as e: