diff options
| author | JonZhao <[email protected]> | 2019-05-25 16:35:14 +0800 |
|---|---|---|
| committer | JonZhao <[email protected]> | 2019-05-25 16:35:14 +0800 |
| commit | 271b4190039abd4aabe4be993eedfc8ba1cdc359 (patch) | |
| tree | c35b07af3766938704a6ec99ee3663aaf7f50522 /vrptw_base.py | |
| parent | 901cf0b2a99dc19a386514139a49ff34c89ecb74 (diff) | |
| download | VRPTW-ACO-python-271b4190039abd4aabe4be993eedfc8ba1cdc359.tar.gz VRPTW-ACO-python-271b4190039abd4aabe4be993eedfc8ba1cdc359.tar.bz2 VRPTW-ACO-python-271b4190039abd4aabe4be993eedfc8ba1cdc359.zip | |
1. add: figure showing
2. fix: fix error about arrive time, the time information in the dataset has been transformed to distance information
Diffstat (limited to 'vrptw_base.py')
| -rw-r--r-- | vrptw_base.py | 9 |
1 files 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 |
