summaryrefslogtreecommitdiffstats
path: root/vrptw_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'vrptw_base.py')
-rw-r--r--vrptw_base.py15
1 files changed, 14 insertions, 1 deletions
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