Пример #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
    REPORTING_END_TIME                   = sys.argv[4]
    ROUTE_DEFINITION_FILE                = sys.argv[5]
    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)
Пример #5
0
        elif opt == "-l":
            OUTPUT_LINK_SHAPEFILE = arg

    # 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("createSFNetworkFromCubeNetwork.INFO.log",
                     "createSFNetworkFromCubeNetwork.DEBUG.log",
                     logToConsole=True)

    # The rest of San Francisco currently exists as a Cube network.  Initialize it from
    # the Cube network files (which have been exported to dbfs.)
    # This is where we define the :py:class:`dta.Scenario`
    sanfranciscoScenario = dta.DynameqScenario(dta.Time(14, 30),
                                               dta.Time(21, 30))

    # We will have 4 vehicle classes: Car_NoToll, Car_Toll, Truck_NoToll, Truck_Toll
    # We will provide demand matrices for each of these classes
    sanfranciscoScenario.addVehicleClass("Car_NoToll")
    sanfranciscoScenario.addVehicleClass("Car_Toll")
    sanfranciscoScenario.addVehicleClass("Truck_NoToll")
    sanfranciscoScenario.addVehicleClass("Truck_Toll")
    # Transit is an implicit type

    # length is in feet (from above), response time is in seconds, maxSpeed is in mi/hour
    # We have only 2 vehicle types                      Type        VehicleClass    Length  RespTime    MaxSpeed    SpeedRatio
    sanfranciscoScenario.addVehicleType(
        dta.VehicleType("Car", "Car_NoToll", 21, 1, 100.0, 100.0))
    sanfranciscoScenario.addVehicleType(
        dta.VehicleType("Car", "Car_Toll", 21, 1, 100.0, 100.0))
Пример #6
0
            OUTPUT_MOVE_SHAPEFILE = arg
        elif opt == "-l":
            OUTPUT_LINK_SHAPEFILE = arg
        elif opt == "-n":
            OUTPUT_NODE_SHAPEFILE = arg

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

    dta.VehicleType.LENGTH_UNITS = "feet"
    dta.Node.COORDINATE_UNITS = "feet"
    dta.RoadLink.LENGTH_UNITS = "miles"

    # Read the SF scenario and DTA network
    sanfranciscoScenario = dta.DynameqScenario()
    sanfranciscoScenario.read(dir=SF_DYNAMEQ_NET_DIR,
                              file_prefix=SF_DYNAMEQ_NET_PREFIX)

    sanfranciscoDynameqNet = dta.DynameqNetwork(scenario=sanfranciscoScenario)
    sanfranciscoDynameqNet.read(dir=SF_DYNAMEQ_NET_DIR,
                                file_prefix=SF_DYNAMEQ_NET_PREFIX)

    counts_wb = xlwt.Workbook()

    # Instantiate the count dracula reader and do the exports
    # Time slices here are based on what we have available (according to CountDracula's querySanFranciscoCounts.py)

    for suffix in ["all", "all_midweek", "recent", "recent_midweek"]:
        from_year = None
        to_year = None