def convert_to_iclique_data_from_mesh_cloak(): map_data = Map() map_data.read_map(option.MAP_PATH, option.MAP_FILE) f = open(option.QUERY_PATH + option.QUERY_FILE, "r") fstr = f.read() f.close() # f = open(option.QUERY_PATH + "iclique_" + option.QUERY_FILE, "w") timestamp = 0 LARGE_STEP = 90 #60,90,120 seconds : for separating time steps NUM_RANGES = 10 #5,10 : for sub-dividing in each time step SMALL_STEP = LARGE_STEP / NUM_RANGES #ranges NUM_USERS = 5000 REQUESTS_PER_RANGE = NUM_USERS / NUM_RANGES request_id = 0 for line in fstr.split("\n"): if line == "": # EOF break items = line.split("\t") ### 1 - FOR Brinkhoff generator # # timestamp # timestamp = int(items[4]) # if timestamp > 5: # break # # # area min (generated randomly from range 0.00005-0.0001) # a_min_ratio = generate_a_min_ratio() # a_min = map_data.area * a_min_ratio # # # # timestep = timestamp * LARGE_STEP + (request_id % NUM_USERS) / REQUESTS_PER_RANGE * SMALL_STEP # f.write("%s\t%s\t%s\t%d\t%s\t%s\t%f"%(items[1],items[5],items[6],timestep,items[7],items[10],a_min)) ### 2 - FOR TraceGenerator # timestamp timestamp = int(items[1]) if timestamp > 5: break # area min (generated randomly from range 0.00005-0.0001) a_min_ratio = generate_a_min_ratio() a_min = map_data.area * a_min_ratio # timestep = timestamp * LARGE_STEP + ( request_id % NUM_USERS) / REQUESTS_PER_RANGE * SMALL_STEP f.write("%s\t%s\t%s\t%d\t%s\t%s\t%f" % (items[0], items[2], items[3], timestep, items[4], items[7], a_min)) # (End) 2 - FOR TraceGenerator f.write("\n") request_id += 1 f.close()
def convert_to_iclique_data(): map_data = Map() map_data.read_map(MAP_PATH, MAP_FILE) f = open(QUERY_PATH + QUERY_FILE, "r") fstr = f.read() f.close() # f = open(QUERY_PATH + "iclique_" + QUERY_FILE, "w") timestamp = 0 for line in fstr.split("\n"): if line == "": # EOF break items = line.split("\t") # timestamp timestamp = int(items[4]) # area min (generated a_min_ratio = float(items[11]) a_min = map_data.area * a_min_ratio #### #f.write("%s\t%s\t%s\t%s\t%s\t%s\t%f"%(items[1],items[5],items[6],items[4],items[7],items[10],a_min)) f.write("%s\t%s\t%s\t%d\t%s\t%s\t%f" % (items[1], items[5], items[6], timestamp * 60, items[7], items[10], a_min)) #f.write("%s\t%s\t%s\t%d\t%s\t%s\t%f"%(items[1],items[5],items[6],timestamp,items[7],items[10],a_min)) #timestamp += 1 f.write("\n") f.close()
####################################################### # MAIN (test) ####################################################### if __name__ == "__main__": # mc_set_1 = [set([1,2,3]), set([1,3,4])] # mc_set_2 = [set([1,5,6]), set([1,4,5]), set([1,3,4])] # # Graph.intersect_mc_set(mc_set_1, mc_set_2) start_time = time.clock() map_data = Map() map_data.read_map(option.MAP_PATH, option.MAP_FILE) print "Load Map : DONE" query_log = QueryLog(map_data) query_log.read_query(option.QUERY_PATH, option.QUERY_FILE, max_time_stamp = 10) print "Load Query : DONE" print "max_speed = ", query_log.max_speed print "elapsed : ", (time.clock() - start_time) graph = Graph(0, map_data, query_log, None) graph.init_mc_set() #TEST # graph.run_timestamps(0,5)
option.DISTANCE_CONSTRAINT = int(sys.argv[3]) if len(sys.argv) > 4: option.K_GLOBAL = int(sys.argv[4]) if len(sys.argv) > 5: option.INIT_COVER_KEEP_RATIO = float(sys.argv[5]) if len(sys.argv) > 6: option.NEXT_COVER_KEEP_RATIO = float(sys.argv[6]) # start_time = time.clock() map_data = Map() map_data.read_map(option.MAP_PATH, option.MAP_FILE) print "Load Map : DONE" query_log = QueryLog(map_data) query_log.read_query( option.QUERY_PATH, option.QUERY_FILE, max_time_stamp=40 ) # default: max_time_stamp = 10 (40: only for attack) print "Load Query : DONE" print "max_speed = ", query_log.max_speed print "elapsed : ", (time.clock() - start_time) graph = Graph(0, map_data, query_log, None) #TEST graph.run_timestamps(0, timestep) print "graph.run_timestamps - DONE"
####################################################### def draw_rectangle(self, x1, y1, x2, y2, color): self.draw_line(x1, y1, x1, y2, color) self.draw_line(x2, y1, x2, y2, color) self.draw_line(x1, y1, x2, y1, color) self.draw_line(x1, y2, x2, y2, color) ####################################################### # MAIN (test) ####################################################### if __name__ == "__main__": map_data = Map() map_data.read_map( "D:/Documents/Paper-code/Network-based-Generator-of-Moving-Objects/DataFiles/", "oldenburgGen") query_log = QueryLog(map_data) query_log.read_query( "D:/Documents/Paper-code/Network-based-Generator-of-Moving-Objects/DataFiles/oldenburgGen/", "oldenburgGen.txt") # master = Tk() width = 700 map_visualizer = MapVisualizer(map_data, query_log, width) w = Canvas(master, width=map_visualizer.width,
####################################################### def draw_rectangle(self, x1, y1, x2, y2, color): self.draw_line(x1, y1, x1, y2, color) self.draw_line(x2, y1, x2, y2, color) self.draw_line(x1, y1, x2, y1, color) self.draw_line(x1, y2, x2, y2, color) ####################################################### # MAIN (test) ####################################################### if __name__ == "__main__": map_data = Map() map_data.read_map("D:/Documents/Paper-code/Network-based-Generator-of-Moving-Objects/DataFiles/", "oldenburgGen") query_log = QueryLog(map_data) query_log.read_query("D:/Documents/Paper-code/Network-based-Generator-of-Moving-Objects/DataFiles/oldenburgGen/", "oldenburgGen.txt") # master = Tk() width = 700 map_visualizer = MapVisualizer(map_data, query_log, width) w = Canvas(master, width=map_visualizer.width, height=map_visualizer.height) w.pack()