def job(data, city, dimension, heuristic_matrices, pname): """ :param data: 起點陣列 :param heuristic_matrices: :param pname: 多線程的編號 :return: """ print('<---Processing ' + str(pname) + ' start--->') adjacency_list = LoadData.load_linking_table(city) count = 0 byte_limit = 1024 * 20 full_path = [] for (src, dst) in data: if src != dst: algorithm = Astar(src, dst, city, dimension, adjacency_list, heuristic_matrices) algorithm.query() path = algorithm.get_shortest_path() if bool(path): full_path.append(tuple(path)) # 輸出檔案,依檔案大小分檔案 if sys.getsizeof(full_path) >= byte_limit: Export.export_a_star(full_path, dimension, city, count) count += 1 full_path = [] print('<---End with ' + str(pname), '--->')
def __init__(self, src, dst, dtype, location, dimension): self.src = int(src) self.dst = int(dst) self.org_node = LoadData.load_org_node(location) self.org_path = LoadData.load_org_path(location, dimension) self.link_table = LoadData.load_linking_table(location) # print('org_node', self.org_node) # print('org_path', self.org_path) # print('self.link_table', self.link_table) self.heap = Heap(dtype) self.quadrant = self.__get_quadrant(self.src, self.dst)
def job(data, all_node, city, heuristic_matrices, pname): """ :param data: 起點陣列 :param all_node:終點陣列 :param heuristic_matrices: :param pname: 多線程的編號 :return: """ print('<---Processing ' + str(pname) + ' start--->') """ # 基本設定 dimension = [Distance, TIme, Dimension3, Dimension4, Dimension5, Dimension6] """ dimension = "Distance" adjacency_list = LoadData.load_linking_table(city) # found_pair = LoadData.load_found_pair(city) count = 0 byte_limit = 1024 * 2 full_path = [] for src in data: for dst in all_node: if src != dst: algorithm = Astar(src, dst, city, dimension, adjacency_list, heuristic_matrices) algorithm.query() path = algorithm.get_shortest_path() if bool(path): full_path.append(tuple(path)) # 輸出檔案,依檔案大小分檔案 if sys.getsizeof(full_path) >= byte_limit: Export.export_a_star(full_path, dimension, city, count) count += 1 full_path = [] print('<---Block', src, '--->') print('<---End with ' + str(pname), '--->')