From 5ea43c019d6bc47d0d28f9768c38be635e846a36 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Fri, 24 May 2019 16:21:44 +0800 Subject: =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=B4=A0=E7=9A=84=E5=87=BD=E6=95=B0=202.=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9B=B4=E6=96=B0rho=E3=80=81q0=E7=9A=84?= =?UTF-8?q?=E5=87=BD=E6=95=B0=203.=20=E4=BF=AE=E5=A4=8Dcost=E7=9A=84?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrptw_base.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'vrptw_base.py') diff --git a/vrptw_base.py b/vrptw_base.py index 798ffc7..2541842 100644 --- a/vrptw_base.py +++ b/vrptw_base.py @@ -87,4 +87,17 @@ class Ant: self.current_index = next_index def index_to_visit_empty(self): - return len(self.index_to_visit) == 0 \ No newline at end of file + return len(self.index_to_visit) == 0 + + def calculate_path_distance(self, graph: VPRTW_Graph): + """ + 计算所有蚂蚁的行走路径的长度 + :param paths: + :return: + """ + distance = 0 + current_index = self.travel_path[0] + for index in self.travel_path[1:]: + distance += graph.node_dist_mat[current_index][index] + current_index = index + return distance -- cgit v1.2.3