From 1b2e26d831e075770baa8c2c27ef965b1c7743b2 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Mon, 27 May 2019 22:45:10 +0800 Subject: =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=A4=8D=E5=88=B6=E5=A4=9A=E4=B8=AAd?= =?UTF-8?q?epot=E7=9A=84graph=E5=88=9B=E5=BB=BA=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=9B=B4=E5=8A=A0=E5=8E=9F=E5=A7=8B=E7=9A=84?= =?UTF-8?q?=EF=BC=8C=E5=A6=82=E6=9E=9C=E6=B2=A1=E6=9C=89=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=BE=BE=E5=88=B0=E7=9A=84=E4=B8=8B=E4=B8=80=E4=B8=AA=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=BB=93=E7=82=B9=EF=BC=8C=E5=88=99=E5=9B=9E=E5=88=B0?= =?UTF-8?q?depot=EF=BC=8C=E5=8F=96=E5=BE=97=E4=BA=86=E4=B8=8D=E9=94=99?= =?UTF-8?q?=E7=9A=84=E6=95=88=E6=9E=9C=EF=BC=8C=E5=B8=A6=E6=8E=A5=E4=B8=8B?= =?UTF-8?q?=E6=9D=A5=E7=BB=A7=E7=BB=AD=E6=B5=8B=E8=AF=95?= 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