From 1b2e26d831e075770baa8c2c27ef965b1c7743b2 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Mon, 27 May 2019 22:45:10 +0800 Subject: 移除复制多个depot的graph创建方法,使用更加原始的,如果没有可以达到的下一个客户结点,则回到depot,取得了不错的效果,带接下来继续测试 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrptw_base.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'vrptw_base.py') diff --git a/vrptw_base.py b/vrptw_base.py index 0ce20d9..ba86128 100644 --- a/vrptw_base.py +++ b/vrptw_base.py @@ -39,25 +39,9 @@ class VrptwGraph: # 启发式信息矩阵 self.heuristic_info_mat = 1 / self.node_dist_mat - def construct_graph_with_duplicated_depot(self, vehicle_num, init_pheromone_val): + def copy(self, init_pheromone_val): new_graph = copy.deepcopy(self) - new_graph.node_num += vehicle_num-1 - for i in range(vehicle_num-1): - new_graph.nodes.insert(0, copy.deepcopy(new_graph.nodes[0])) - - # 从新计算距离 - new_graph.node_dist_mat = np.zeros((new_graph.node_num, new_graph.node_num)) - for i in range(new_graph.node_num): - original_i = max(0, i - vehicle_num + 1) - - for j in range(i + 1, new_graph.node_num): - original_j = max(0, j - vehicle_num + 1) - new_graph.node_dist_mat[i][j] = self.node_dist_mat[original_i][original_j] - new_graph.node_dist_mat[j][i] = new_graph.node_dist_mat[i][j] - - # 启发式信息 - new_graph.heuristic_info_mat = 1 / new_graph.node_dist_mat # 信息素 new_graph.init_pheromone_val = init_pheromone_val new_graph.pheromone_mat = np.ones((new_graph.node_num, new_graph.node_num)) * init_pheromone_val -- cgit v1.2.3