From 3f9d51e66ecd44fef7595651c11bd424cea54ed9 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Fri, 24 May 2019 17:02:51 +0800 Subject: =?UTF-8?q?=E5=9C=A8=E9=80=89=E6=8B=A9=E4=B8=8B=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E7=BB=93=E7=82=B9=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8C=E8=80=83?= =?UTF-8?q?=E8=99=91=E8=BD=BD=E9=87=8D=E7=8E=87=E3=80=81=E8=A1=8C=E9=A9=B6?= =?UTF-8?q?=E8=B7=9D=E7=A6=BB=E7=AD=89=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrptw_base.py | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'vrptw_base.py') diff --git a/vrptw_base.py b/vrptw_base.py index 2541842..1647bd9 100644 --- a/vrptw_base.py +++ b/vrptw_base.py @@ -65,11 +65,13 @@ class Ant: self.travel_path = [0] self.arrival_time = [0] self.index_to_visit = list(range(1, node_num)) + self.total_travel_distance = 0 def move_to_next_index(self, graph, vehicle_speed, next_index): # 更新蚂蚁路径 self.travel_path.append(next_index) self.arrival_time.append(self.current_time) + self.total_travel_distance += graph.node_dist_mat[self.current_index][next_index] if next_index == 0: # 如果一下个位置为服务器点,则要将车辆负载等清空 @@ -88,16 +90,3 @@ class Ant: def index_to_visit_empty(self): 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