def extractPostprocessorData(file_base, **kwargs): # Extract the option data refinements = kwargs.pop('refinements', 0) x_name = kwargs.pop('x', 'ndofs') y_name = kwargs.pop('y', 'L2_error') # Initialize the output x = [] y = [] # Steady: Read entire .csv file if refinements == 0: header, data = readCSV(file_base + '.csv') x_idx = header.index(x_name) y_idx = header.index(y_name) for d in data: x.append(float(d[x_idx])) y.append(float(d[y_idx])) # Transient: Read last piece of data for each file else: for i in range(refinements + 1): header, data = readCSV(file_base + '_' + str(i) + '.csv') x_idx = header.index(x_name) y_idx = header.index(y_name) x.append(float(data[-1][x_idx])) y.append(float(data[-1][y_idx])) return numpy.array(x), numpy.array(y)
def extractPhaseOutput(file_base, **kwargs): # Extract the option data refinements = kwargs.pop('refinements', 0) x_name = kwargs.pop('x', 'x') y_name = kwargs.pop('y', 'phi') # Initialize the output x = [] y = [] # Steady: Read entire .csv file if refinements == 0: header, data = readCSV(file_base + '.csv') x_idx = header.index(x_name) y_idx = header.index(y_name) for d in data: x.append(float(d[x_idx])) y.append(float(d[y_idx])) # Transient: Read last piece of data for each file else: for i in range(refinements + 1): header, data = readCSV(file_base + '_' + str(i) + '.csv') x_idx = header.index(x_name) y_idx = header.index(y_name) x.append(float(data[-1][x_idx])) y.append(float(data[-1][y_idx])) return numpy.array(x), numpy.array(y)
def showImg(self): #显示图片 self._selfCheck(self.storeDest1) # 除错图 self._selfCheck(self.storeDest2) if not os.listdir(self.storeDest1) or not os.listdir( self.storeDest2): # 没有图则不做任何操作 return findNew1, imgName1 = new_report(self.storeDest1, self.finalDest1) findNew2, imgName2 = new_report(self.storeDest2, self.finalDest2) #print(findNew1, imgName1, findNew2, imgName2) pygame.mixer.music.stop() self.cropName1 = cropAndSave(imgName1, self.cropedDst1) #print(self.cropName1) self.label_2.setPixmap(QtGui.QPixmap(imgName1)) self.label_2.setScaledContents(True) # 让图片自适应label大小 self.numbers1 = sift(self.cropName1, 1) if self.numbers1 > 500: self.label_2.setStyleSheet("border:2px solid red;") #print(self.numbers1) else: self.label_2.setStyleSheet("border:2px solid black;") self.cropName2 = cropAndSave(imgName2, self.cropedDst2) self.label_3.setPixmap(QtGui.QPixmap(imgName2)) self.label_3.setScaledContents(True) # 让图片自适应label大小 self.numbers2 = sift(self.cropName2, 2) if self.numbers2 > 500: self.label_3.setStyleSheet("border:2px solid red;") else: self.label_3.setStyleSheet("border:2px solid black;") #print(self.numbers1) #print(self.numbers2) if self.numbers1 > 200 or self.numbers2 > 200: #print(2) track = pygame.mixer.music.load(r"./sound/1.mp3") pygame.mixer.music.play() else: #print(1) pygame.mixer.music.stop() pygame.init() #print(self.numbers1, self.numbers2) num, df = readCSV('./database/database.csv') self.updateTable(num, df) str = "当前正面图像为" + imgName1 + "\n" + "当前反面图像为" + imgName2 self.textBrowser.setText(str) self.textBrowser.setFont(QFont("Microsoft YaHei", 15))
SHOWVELOCITY = True # Show velocity and desired velocity of agents SHOWINDEX = True # Show index of agents SHOWTIME = True # Show a clock on the screen SHOWINTELINE = True # Draw a line between interacting agents MODETRAJ = False # Draw trajectory of agents' movement COHESION = False # Enable the cohesive social force SELFREPULSION = True # Enable self repulsion WALLBLOCKHERDING = True TPREMODE = 1 ### Instructinn: 1 -- DesiredV = 0 2 -- Motive Force =0: PAUSE = False SHOWWALLDATA = True # The file to record the some output data of the simulation f = open("out.txt", "w+") agentFeatures = readCSV("agentData2018.csv", 'string') [Num_Agents, Num_Features] = np.shape(agentFeatures) print >> f, 'Number of Agents:', Num_Agents, '\n' print >> f, "Features of Agents\n", agentFeatures, "\n" agents = [] for agentFeature in agentFeatures: agent = Agent() agent.pos = np.array([float(agentFeature[0]), float(agentFeature[1])]) agent.dest = np.array([float(agentFeature[2]), float(agentFeature[3])]) agent.tau = float(agentFeature[4]) agent.tpre = float(agentFeature[5]) agent.p = float(agentFeature[6]) agent.pMode = agentFeature[7] agent.aType = agentFeature[8] agent.interactionRange = float(agentFeature[9])
#!/usr/bin/python2 from readCSV import * import matplotlib.pyplot as plt import sys year = int(sys.argv[1]) month = int(sys.argv[2]) day = int(sys.argv[3]) hour1 = int(sys.argv[4]) minute1 = int(sys.argv[5]) hour2 = int(sys.argv[6]) minute2 = int(sys.argv[7]) title = str(sys.argv[8]) csv2 = readCSV("Files/TRN_2010_2011_50m_18_C.hour.CO2", "\t") csv3 = readCSV("Files/TRN_2010_2011_100m_18_C.hour.CO2", " ") csv4 = readCSV("Files/TRN_2010_2011_180m_18_C.hour.CO2", " ") csv5 = readCSV("Files/FTIR/or_sl_scd-0_2011.vav.ada.aia.oof", " ") listColumns2 = []#Tower50 listColumns3 = []#Tower100 listColumns4 = []#Tower180 listColumns5 = []#FTIR listColumns2.append(csv2.findColumn("co2", 0)) listColumns2.append(csv2.findColumn("Year", 0)) listColumns2.append(csv2.findColumn("Month", 0)) listColumns2.append(csv2.findColumn("Day", 0)) listColumns2.append(csv2.findColumn("Hour", 0)) csv2.getColumns(listColumns2, 1)
# walls.append(wall) #initialize agents #agentFeatures = [] #for line in open("pedTest.txt"): # coords = line.split(',') # agentFeature = [] # agentFeature.append(float(coords[0])) # agentFeature.append(float(coords[1])) # agentFeature.append(float(coords[2])) # agentFeature.append(float(coords[3])) # agentFeatures.append(agentFeature) agentFeatures = readCSV("Agent_Data2018.csv") [Num_Agents, Num_Features] = np.shape(agentFeatures) print >> f, 'Number of Agents:', Num_Agents, '\n' agents = [] for agentFeature in agentFeatures: agent = Agent() agent.pos = np.array([agentFeature[0], agentFeature[1]]) agent.dest = np.array([agentFeature[2], agentFeature[3]]) agents.append(agent) walls = readCSV("Wall_Data2018.csv") #walls = [[3.33, 3.33, 23.97, 3.33], #[3.33, 3.33, 3.33, 30.31],
cityChoices = [city for city in cityList if city != currentPos] # cityChoices = cityList[:] route = [currentPos] visited = [currentPos] # print('cityChoices: ', cityChoices) while len(list(cityChoices)) > 0 : # print('cityChoices length in loop: ', cityChoices) currentPos = probCityPicker(cityChoices, visited, graph, pheromoneTrails) route.append(currentPos) visited.append(currentPos) cityChoices = list(filter(lambda city : city not in visited, cityChoices)) i += 1 subRoutes = getSubRoutes(route) pheromoneTrails = decayPheromones(pheromoneTrails, decayRate) print('subRoutes: ', subRoutes) for edge in subRoutes : sorted(edge) key = str(edge[0]) + str(edge[1]) if edge[0] < edge[1] else str(edge[1]) + str(edge[0]) # print('key: ', key) if key in subRouteFreq : subRouteFreq[key] = (1 + subRouteFreq[key]) else : subRouteFreq[key] = 0 pheromoneTrails = increasePheromones(key, pheromoneTrails, len(route), increaseRate) print('pheromoneTrails: ', pheromoneTrails) print('final route: ', route, ' cost: ', getCostOfRoute(route)) runTSP_3Plus(readCSV())