From 271b4190039abd4aabe4be993eedfc8ba1cdc359 Mon Sep 17 00:00:00 2001 From: JonZhao <1044264932@qq.com> Date: Sat, 25 May 2019 16:35:14 +0800 Subject: 1. add: figure showing 2. fix: fix error about arrive time, the time information in the dataset has been transformed to distance information --- vrptw_base.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vrptw_base.py b/vrptw_base.py index 1647bd9..8de14ce 100644 --- a/vrptw_base.py +++ b/vrptw_base.py @@ -61,29 +61,26 @@ class Ant: self.current_index = 0 self.vehicle_load = 0 self.vehicle_travel_distance = 0 - self.current_time = 0 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): + def move_to_next_index(self, graph, next_index): # 更新蚂蚁路径 self.travel_path.append(next_index) - self.arrival_time.append(self.current_time) + self.arrival_time.append(self.vehicle_travel_distance) self.total_travel_distance += graph.node_dist_mat[self.current_index][next_index] if next_index == 0: # 如果一下个位置为服务器点,则要将车辆负载等清空 self.vehicle_load = 0 self.vehicle_travel_distance = 0 - self.current_time = 0 else: # 更新车辆负载、行驶距离、时间 self.vehicle_load += graph.nodes[next_index].demand - self.vehicle_travel_distance += graph.node_dist_mat[self.current_index][next_index] - self.current_time += (graph.node_dist_mat[self.current_index][next_index] / vehicle_speed + graph.nodes[next_index].service_time) + self.vehicle_travel_distance += graph.node_dist_mat[self.current_index][next_index] + graph.nodes[next_index].service_time self.index_to_visit.remove(next_index) self.current_index = next_index -- cgit v1.2.3