Exemple #1
0
            row["BA_XITB"] = (LAMBDA*row["BA_XITB"])+((1.0-LAMBDA)*prevTad.trnAsgnTable[key]["BA_XITB"])
        
            deltaVol = abs(row["AB_VOL"]-prevTad.trnAsgnTable[key]["AB_VOL"])
        
            #Add absolute diff and total up for convergence calc to follow
            totalDeltaVol   += deltaVol
        except:
            print "An error occurred in MSAing for link [%s]" % key
            print sys.exc_info()
            print "Skipping..."
            
# Convergence criteria: is the change in volume (as a fraction of the total volumes) small enough?
# When we have met the convergence criteria, we do not create a new "trnlink[timeperiod]_ALLMSA.dbf"
criteriaMet = False
pctDiffVol = totalDeltaVol/totVol
if prevTad and pctDiffVol < volDiffCond:
    criteriaMet = True

# Might two different try do do this at the same time?
f = open("RouteLinkMSALog.csv","a")
f.write("%d,%s,%f,%f,%d\n" % (trnAssignIter,timeperiod,totVol,pctDiffVol,criteriaMet))
f.close()

# write the link sum aggregates if it's the last one
linkSumFileName = None
if criteriaMet:
    linkSumFileName=routeFileName.replace(".dbf", "_linksum.dbf")
    
# Write out the assignment
curTad.writeDbfs(asgnFileName=routeFileName, aggregateFileName=linkSumFileName)
Exemple #2
0
class TransitDbfCombiner:
    
    def __init__(self, timeperiod,runDir,outFile,
                 champType='champ4',runType='',includeAll=False):
        """ 
        Interpret the args into my local variables.
        ALL CAPS class variables indicate arg-based constants.
        """
        self.timeperiod = timeperiod
        if self.timeperiod not in ["AM", "MD", "PM", "EV", "EA"]:
            print USAGE
            exit(1)
        if (self.timeperiod == "AM"):
            self.vtypeIdx = 2
        elif (self.timeperiod == "PM"):
            self.vtypeIdx = 3
        else:
            self.vtypeIdx = 4
            
        self.DIR        = runDir
        self.OUTFILE    = outFile
        self.runType    = runType
        self.includeAll=bool(includeAll)
        self.PROFILENODE= 0           
        
        if self.runType not in ["muni","bigBA","all"] and self.runType[0:7] != "profile":
            print "Don't understand runType %s" % self.runType
            print USAGE
            exit(1)
        if self.runType[0:7].lower() == "profile":
            self.PROFILENODE = int(self.runType[7:])
        self.CHAMPTYPE = champType
        if self.CHAMPTYPE not in ["champ3","champ4","champ3-sfonly"]:
            print "Don't understand CHAMPTYPE %s" % CHAMPTYPE
            print USAGE
            exit(1)
        
        logging.info("includeAll= " + str(self.includeAll))
        logging.info("timeperiod = " + self.timeperiod)
        logging.info("DIR        = " + self.DIR)
        logging.info("OUTFILE    = " + self.OUTFILE)
        logging.info("runType    = " + self.runType)
        logging.info("PROFILENODE= " + str(self.PROFILENODE))
        logging.info("CHAMPTYPE  = " + self.CHAMPTYPE)
        
    def readTransitNameMapping(self):
        if self.runType=="muni" or self.runType=="bigBA" or self.runType=="all":
            if self.runType == "muni": 
                system=["SF MUNI"]
                ignoreModes=[11,12,13,14,15,16,17]
            elif self.runType=="bigBA": 
                system = ["SF MUNI", "AC Transit", "SamTrans", "Caltrain", "BART", "Golden Gate Transit", "Ferry", "Presidigo"]
                ignoreModes=[11,12,13,14,15,16,17]
            else: # system == "all":
                system = []
                ignoreModes = []
            
            self.transitCapacity = TransitCapacity(self.DIR)
            self.tad = TransitAssignmentData(directory=self.DIR, 
                                             timeperiod=self.timeperiod,
                                             champtype=self.CHAMPTYPE,
                                             transitCapacity=self.transitCapacity,
                                             ignoreModes=ignoreModes,
                                             system=system)
        else:
            self.tad = TransitAssignmentData(directory=self.DIR, 
                                             timeperiod=self.timeperiod,
                                             champtype=self.CHAMPTYPE,
                                             transitCapacity=self.transitCapacity,
                                             profileNode=self.PROFILENODE)
        
        (aggdir, aggfile) = os.path.split(self.OUTFILE)
        aggfile = "agg_" + aggfile
        self.tad.writeDbfs(self.OUTFILE, os.path.join(aggdir,aggfile))
Exemple #3
0
    try:
        tad = TransitAssignmentData(timeperiod=timeperiod,
                                    modelType=Network.MODEL_TYPE_TM1,
                                    ignoreModes=[1,2,3,4,5,6,7],
                                    tpfactor="constant_with_peaked_muni",
                                    transitCapacity=TransitNetwork.capacity,
                                    lineLevelAggregateFilename=curRouteFileName)
    except Exception, err:
        WranglerLogger.fatal(sys.exc_info()[0])
        WranglerLogger.fatal(sys.exc_info()[1])
        WranglerLogger.fatal(traceback.format_exc())
        sys.exit(2)

    # since we've aggregated, write it out
    if not curRouteFileName:
        tad.writeDbfs(os.path.join(curSubdir, "trnlink{}_ALL.dbf".format(timeperiod)))
        
    currentNet = TransitNetwork(modelType=Network.MODEL_TYPE_TM1, modelVersion=1.5)
    currentNet.parseFile(fullfile=curNetFile)
    originalNet = TransitNetwork(modelType=Network.MODEL_TYPE_TM1, modelVersion=1.5)
    originalNet.parseFile(fullfile=origNetFile)

    # remove out the extra delay so it doesn't get MSA'd in with dwells
    if extraDelayMapping:
        subtractExtraDelayToNet(extraDelayMapping, currentNet, timeperiod)
    
    # report on lines of interest - note that it does not have extraDelay
    updateLinesOfInterest(timeperiod, trnAssignIter, complexAccessModes, currentTad=tad, currentNet=currentNet)
    
    if not criteriaMet:
        originalNet.addDelay(timeperiod=timeperiod,