Exemple #1
0
		print "Scratch version set up.  Proceding..."
	
		# 1, update speed, recalculate cost 
		print "Update Speed..."
		inSpeed = "detspd" + str(currentIter - 1) + ".csv"
		ModJoinSpeed.joinSpeed(inSpace, inGdb, inSpeed)
	
		# 2, rebuild network dataset
		print "Speed updated. Rebuild Dataset..."
		ModBuild.build(inSpace, inGdb)
		
		print "Dataset rebuilt. Solve for TT, TD, DT"
		ModSolve.solve(inSpace, inGdb, fcTAZ, fcDet)
		
		print "Predicting flow from gravity equation"
		ModUpdateFlow.update(inSpace, currentIter, inTTp)
	
		print "Flow Allocation"
		inFlow = inSpace + "CSV/TTflow" + str(currentIter) + ".csv"
		flow = ModAlloc.alloc(inSpace, inFlow, currentIter)
	
		#Save TT cost calculated from speed0
		if currentIter == 1:
			shutil.copyfile(inSpace+'CSV/TT.csv', inSpace+'CSV/TT0.csv')
			fd = open(outRelGap,"wb")
			fd.write("Iteration, Relative Gap")
			fd.close()
		#Calculate relative gap
#		relgap = ModRelgap.calc(inSpace, currentIter)
#		relgap = str(currentIter) + ', ' + str(relgap) + ' \n'
#		fd = open(outRelGap,"a")
Exemple #2
0
            print "Iteration", currentIter, "starts on ", time.strftime("%d/%m/%Y - %H:%M:%S")
            print inTTp, ", at", inSpace

            # 0, create temp scratch
            print "Setting up scratch version"
            tempP = temp[:-4] + "-P" + temp[-4:]
            ModSetupWorker.clearOld(base,tempP)
            print "Scratch version set up.  Proceding..."

            print "GIS operations begins."
            ModGIS.GISops_1p(inSpace, inGdb, currentIter, fcTAZ, fcDet)
            print "GIS operations completed."

            print "Predicting flow from gravity equation"
#             Changed ModUpdateFlow line 300 to TTP for now
            ModUpdateFlow.update(inSpace, currentIter, inTTp)    # Gives TTflow1.csv from update (not 2p)

            print "Flow Allocation"
            inFlow = inSpace+"CSV/TTflow"+str(currentIter)+".csv"
            outCSV = inSpace+"CSV/xdetflow.csv"
            ModAlloc.alloc(inSpace, inFlow, outCSV, period="P") # Gives detflow
            
            alpha = 1
#            Loop through DTA:
            savepath = inSpace+"CSV/xdetflow-beforealpha-"+str(currentIter)+".csv"
            shutil.copy(outCSV, savepath)
            while alpha > 0.01:
                alpha = dta_1p(inSpace, inFlow, FL, LIMIT)
                print "alpha:", alpha
                if alpha > 0.999:
                    shutil.copy(inSpace+"CSV/xdetflow"+str(alpha)+".csv", inSpace+"CSV/xdetflow.csv")